mirror of
https://github.com/misenhower/splatoon2.ink.git
synced 2026-03-21 17:24:37 -05:00
Add a helper script for retrieving language data from SplatNet
This will help for manually-specified translations.
This commit is contained in:
parent
88e09ba293
commit
be38bc4cea
36
src/updater/getSplatNetLanguageFiles.js
Normal file
36
src/updater/getSplatNetLanguageFiles.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// This is a helper used to retrieve language files from SplatNet.
|
||||
// These files aren't used directly, but are just downloaded for help with updating manual translation files.
|
||||
|
||||
require('./bootstrap');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const mkdirp = require('mkdirp');
|
||||
const axios = require('axios');
|
||||
const { writeFormattedJson } = require('./utilities');
|
||||
const { languages } = require('../js/regions');
|
||||
const SplatNet = require('./splatnet');
|
||||
|
||||
const outputPath = path.resolve('storage/lang');
|
||||
|
||||
mkdirp(outputPath);
|
||||
|
||||
(async () => {
|
||||
for (let { region, language } of languages) {
|
||||
let splatnet = new SplatNet(region, language);
|
||||
let client = splatnet.getClient();
|
||||
client.defaults.baseURL = 'https://app.splatoon2.nintendo.net';
|
||||
|
||||
// Get the main SplatNet page
|
||||
let response = await client.get('/');
|
||||
// The first script tag on the page is the localization file
|
||||
let matches = response.data.match(/script src="(.*)"/);
|
||||
// Download the localization file
|
||||
response = await client.get(matches[1]);
|
||||
// Set up a fake "window" to store the translations and run the downloaded file
|
||||
let window = {};
|
||||
eval(response.data);
|
||||
// The localization data is now in window.LocalizedMessage
|
||||
// Store the data to a JSON file
|
||||
writeFormattedJson(`${outputPath}/${region}-${language}.json`, window.LocalizedMessage);
|
||||
}
|
||||
})();
|
||||
Loading…
Reference in New Issue
Block a user