loacleisation scripts doneeee
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"ostream": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ function localeString(code)
|
||||
{
|
||||
let strings = JSON.parse(localStorage.getItem('locale-strings'));
|
||||
let whatstring = strings[code];
|
||||
if (!whatstring || whatstring == '') whatstring = strings['en'];
|
||||
let locale = whatstring[localStorage.getItem('locale')];
|
||||
|
||||
return locale;
|
||||
|
||||
@@ -11,3 +11,8 @@ Sometimes context clues may be neccesary for an accurate translation, everything
|
||||
```Code:Translation/Text;Context```
|
||||
|
||||
Capitalisation is also important, if the english words are capitalised, the translations need to be capitalised in the same (if it makes sense) place
|
||||
|
||||
|
||||
#### development
|
||||
|
||||
For development look for the scripts folder, there are scripts to translate the lang files to the locale file and vice verse
|
||||
|
||||
@@ -56,4 +56,4 @@ status-connected:Connected
|
||||
status-connected-as:Connected as
|
||||
status-disconnected:Disconnected
|
||||
username:Username
|
||||
visibility:Visibility
|
||||
visibility:Visibility
|
||||
@@ -56,4 +56,4 @@ status-connected:Conectado(a)
|
||||
status-connected-as:Conectado/a como
|
||||
status-disconnected:Desconectado/a
|
||||
username:Nombre de usuario
|
||||
visibility:Visibilidad
|
||||
visibility:Visibilidad
|
||||
436
data/locale.json
436
data/locale.json
@@ -1,38 +1,8 @@
|
||||
{
|
||||
"scrabble-name": {
|
||||
"en": "Scrabble",
|
||||
"es": "Scrabble",
|
||||
"pt": "Scrabble"
|
||||
},
|
||||
"game-lobby": {
|
||||
"en": "create or join a game",
|
||||
"es": "crea o conecta a un juego",
|
||||
"pt": "crie ou entre em um jogo"
|
||||
},
|
||||
"name": {
|
||||
"en": "name",
|
||||
"es": "nombre",
|
||||
"pt": "nome"
|
||||
},
|
||||
"username": {
|
||||
"en": "Username",
|
||||
"es": "Nombre de usuario",
|
||||
"pt": "Nome de usuàrio"
|
||||
},
|
||||
"players": {
|
||||
"en": "Players",
|
||||
"es": "Jugadores",
|
||||
"pt": "Jogadores"
|
||||
},
|
||||
"button-singleplayer": {
|
||||
"en": "Play singleplayer",
|
||||
"es": "Jugar a un(a) jugador(a)",
|
||||
"pt": "Jogar singleplayer"
|
||||
},
|
||||
"button-submit": {
|
||||
"en": "Submit",
|
||||
"es": "Enviar",
|
||||
"pt": "Enviar"
|
||||
"button-back": {
|
||||
"en": "back",
|
||||
"es": "regresar",
|
||||
"pt": "voltar"
|
||||
},
|
||||
"button-create": {
|
||||
"en": "create",
|
||||
@@ -44,113 +14,130 @@
|
||||
"es": "participar",
|
||||
"pt": "entrar"
|
||||
},
|
||||
"button-back": {
|
||||
"en": "back",
|
||||
"es": "regresar",
|
||||
"pt": "voltar"
|
||||
"button-leave-lobby": {
|
||||
"en": "Leave Lobby",
|
||||
"es": "Salir del Lobby",
|
||||
"pt": "Sair do Lobby"
|
||||
},
|
||||
|
||||
"status-connected": {
|
||||
"en": "Connected",
|
||||
"es": "Conectado(a)",
|
||||
"pt": "Conectado(a)"
|
||||
"button-send": {
|
||||
"en": "send",
|
||||
"es": "enviar",
|
||||
"pt": "enviar"
|
||||
},
|
||||
"status-connected-as": {
|
||||
"en": "Connected as ",
|
||||
"es": "Conectado/a como ",
|
||||
"pt": "Conectado/a como "
|
||||
"button-singleplayer": {
|
||||
"en": "Play singleplayer",
|
||||
"es": "Jugar a un(a) jugador(a)",
|
||||
"pt": "Jogar singleplayer"
|
||||
},
|
||||
"status-disconnected": {
|
||||
"en": "Disconnected",
|
||||
"es": "Desconectado/a",
|
||||
"pt": "Desconectado/a"
|
||||
"button-start-game": {
|
||||
"en": "Start Game",
|
||||
"es": "Empezar Juego",
|
||||
"pt": "Começar Jogo"
|
||||
},
|
||||
"button-submit": {
|
||||
"en": "Submit",
|
||||
"es": "Enviar",
|
||||
"pt": "Enviar"
|
||||
},
|
||||
"connection-waiting": {
|
||||
"en": "Waiting for connection",
|
||||
"es": "Esperando la conexión",
|
||||
"pt": "Aguardando conexão"
|
||||
},
|
||||
|
||||
"message": {
|
||||
"en": "message",
|
||||
"es": "mensaje",
|
||||
"pt": "mensagem"
|
||||
"error-bad-intent": {
|
||||
"en": "Client has no intent",
|
||||
"es": "Cliente no tiene intención",
|
||||
"pt": "Cliente não tem intenção"
|
||||
},
|
||||
"log-console": {
|
||||
"en": "log console",
|
||||
"es": "consola de log",
|
||||
"pt": "console de log"
|
||||
"error-bold": {
|
||||
"en": "ERROR",
|
||||
"es": "ERRO",
|
||||
"pt": "ERROR"
|
||||
},
|
||||
"button-send": {
|
||||
"en": "send",
|
||||
"es": "enviar",
|
||||
"pt": "enviar"
|
||||
"error-cannot-join-lobby": {
|
||||
"en": "Cannot join lobby",
|
||||
"es": "No se puede unir al lobby",
|
||||
"pt": "Não é possível entrar no lobby"
|
||||
},
|
||||
|
||||
"lobby": {
|
||||
"en": "Lobby",
|
||||
"es": "Lobby",
|
||||
"pt": "Lobby"
|
||||
"error-creating-lobby": {
|
||||
"en": "An error occurred while creating the lobby",
|
||||
"es": "Ocurrió un error al crear el lobby",
|
||||
"pt": "Ocorreu um erro ao criar o lobby"
|
||||
},
|
||||
"lobby-create": {
|
||||
"en": "Create Lobby",
|
||||
"es": "Crear Lobby",
|
||||
"pt": "Criar Lobby"
|
||||
"error-illegal-lobby": {
|
||||
"en": "Illegal lobby",
|
||||
"es": "Lobby ilegal",
|
||||
"pt": "Lobby ilegal"
|
||||
},
|
||||
"lobby-join": {
|
||||
"en": "Join Lobby",
|
||||
"es": "Conectarse al Lobby",
|
||||
"pt": "Conectar ao Lobby"
|
||||
"error-illegal-user": {
|
||||
"en": "Illegal user",
|
||||
"es": "Usuario ilegal",
|
||||
"pt": "Usuário ilegal"
|
||||
},
|
||||
"lobby-join-code": {
|
||||
"en": "Join Code",
|
||||
"es": "Código para Conectar",
|
||||
"pt": "Código para Conectar"
|
||||
"error-invalid-username": {
|
||||
"en": "Invalid username",
|
||||
"es": "Nombre de usuario no es válido",
|
||||
"pt": "Nome de usuário Inválido"
|
||||
},
|
||||
"lobby-code": {
|
||||
"en": "lobby code",
|
||||
"es": "código de lobby",
|
||||
"pt": "código do lobby"
|
||||
"error-lobby-id-required": {
|
||||
"en": "A lobby ID is required",
|
||||
"es": "Se requiere un lobby ID",
|
||||
"pt": "É necessário um lobby ID"
|
||||
},
|
||||
"lobby-private": {
|
||||
"en": "private lobby",
|
||||
"es": "lobby privado",
|
||||
"pt": "lobby privado"
|
||||
"error-lobby-joining": {
|
||||
"en": "An error occurred while joining the lobby",
|
||||
"es": "Ocurrió un error al conectarse al lobby",
|
||||
"pt": "Ocorreu um erro ao entrar no lobby"
|
||||
},
|
||||
"lobby-allow-spectators": {
|
||||
"en": "allow spectators",
|
||||
"es": "permitir espectadores",
|
||||
"pt": "permitir espectadores"
|
||||
"error-lobby-name-required": {
|
||||
"en": "A name is requred",
|
||||
"es": "Se requiere un nombre",
|
||||
"pt": "Um nome é obrigatório"
|
||||
},
|
||||
"lobby-join-spectator": {
|
||||
"en": "join as spectator",
|
||||
"es": "conectar como espectador(a)",
|
||||
"pt": "junte-se como espectador"
|
||||
"error-lobby-not-exist": {
|
||||
"en": "Lobby does not exist",
|
||||
"es": "Lobby no existe",
|
||||
"pt": "Lobby não existe"
|
||||
},
|
||||
"lobby-created-joining": {
|
||||
"en": "Lobby created, Joining...",
|
||||
"es": "Lobby creado, Conectando...",
|
||||
"pt": "Lobby criaso, Juntando-se..."
|
||||
"error-malformed-lobby": {
|
||||
"en": "Lobby malformed",
|
||||
"es": "Lobby malformado",
|
||||
"pt": "Lobby malformado"
|
||||
},
|
||||
"lobby-created": {
|
||||
"en": "created lobby",
|
||||
"es": "lobby creado",
|
||||
"pt": "Lobby criado"
|
||||
"error-no-username": {
|
||||
"en": "Username not present",
|
||||
"es": "Nombre de usuario no esta presente",
|
||||
"pt": "Nome de usuário não esta presente"
|
||||
},
|
||||
"lobby-joining": {
|
||||
"en": "joining lobby",
|
||||
"es": "entrando al lobby",
|
||||
"pt": "entrando no lobby"
|
||||
"error-taken-lobby-ownership": {
|
||||
"en": "User already owns lobby",
|
||||
"es": "Usuario ya tiene lobby",
|
||||
"pt": "Usuário já tem um lobby"
|
||||
},
|
||||
"lobby-joined": {
|
||||
"en": "joined lobby",
|
||||
"es": "entró en el lobby",
|
||||
"pt": "entrou no lobby"
|
||||
"error-taken-user-connection": {
|
||||
"en": "User already connected",
|
||||
"es": "Usuario ya está conectado/a",
|
||||
"pt": "Usuário já está conectado/a"
|
||||
},
|
||||
"lobby-deleted": {
|
||||
"en": "deleted lobby",
|
||||
"es": "lobby eliminado",
|
||||
"pt": "lobby apagado"
|
||||
"error-taken-username": {
|
||||
"en": "Username taken",
|
||||
"es": "Nombre de usuario no esta disponible",
|
||||
"pt": "Nome de usuário já está em uso"
|
||||
},
|
||||
"error-too-many-clients": {
|
||||
"en": "Too many connections",
|
||||
"es": "Demasiadas conexiones",
|
||||
"pt": "Demasiadas conexões"
|
||||
},
|
||||
"error-unknown-uid": {
|
||||
"en": "Unknown user ID",
|
||||
"es": "ID de usuario desconocido",
|
||||
"pt": "ID de usuário desconhecido"
|
||||
},
|
||||
"game-lobby": {
|
||||
"en": "create or join a game",
|
||||
"es": "crea o conecta a un juego",
|
||||
"pt": "crie ou entre em um jogo"
|
||||
},
|
||||
"joined": {
|
||||
"en": "joined",
|
||||
@@ -167,122 +154,129 @@
|
||||
"es": "salió del lobby",
|
||||
"pt": "saiu do lobby"
|
||||
},
|
||||
|
||||
"lobby": {
|
||||
"en": "Lobby",
|
||||
"es": "Lobby",
|
||||
"pt": "Lobby"
|
||||
},
|
||||
"lobby-allow-spectators": {
|
||||
"en": "allow spectators",
|
||||
"es": "permitir espectadores",
|
||||
"pt": "permitir espectadores"
|
||||
},
|
||||
"lobby-code": {
|
||||
"en": "lobby code",
|
||||
"es": "código de lobby",
|
||||
"pt": "código do lobby"
|
||||
},
|
||||
"lobby-create": {
|
||||
"en": "Create Lobby",
|
||||
"es": "Crear Lobby",
|
||||
"pt": "Criar Lobby"
|
||||
},
|
||||
"lobby-created": {
|
||||
"en": "created lobby",
|
||||
"es": "lobby creado",
|
||||
"pt": "Lobby criado"
|
||||
},
|
||||
"lobby-created-joining": {
|
||||
"en": "Lobby created, Joining...",
|
||||
"es": "Lobby creado, Conectando...",
|
||||
"pt": "Lobby criaso, Juntando-se..."
|
||||
},
|
||||
"lobby-deleted": {
|
||||
"en": "deleted lobby",
|
||||
"es": "lobby eliminado",
|
||||
"pt": "lobby apagado"
|
||||
},
|
||||
"lobby-join": {
|
||||
"en": "Join Lobby",
|
||||
"es": "Conectarse al Lobby",
|
||||
"pt": "Conectar ao Lobby"
|
||||
},
|
||||
"lobby-join-code": {
|
||||
"en": "Join Code",
|
||||
"es": "Código para Conectar",
|
||||
"pt": "Código para Conectar"
|
||||
},
|
||||
"lobby-join-spectator": {
|
||||
"en": "join as spectator",
|
||||
"es": "conectar como espectador(a)",
|
||||
"pt": "junte-se como espectador"
|
||||
},
|
||||
"lobby-joined": {
|
||||
"en": "joined lobby",
|
||||
"es": "entró en el lobby",
|
||||
"pt": "entrou no lobby"
|
||||
},
|
||||
"lobby-joining": {
|
||||
"en": "joining lobby",
|
||||
"es": "entrando al lobby",
|
||||
"pt": "entrando no lobby"
|
||||
},
|
||||
"lobby-private": {
|
||||
"en": "private lobby",
|
||||
"es": "lobby privado",
|
||||
"pt": "lobby privado"
|
||||
},
|
||||
"log-console": {
|
||||
"en": "log console",
|
||||
"es": "consola de log",
|
||||
"pt": "console de log"
|
||||
},
|
||||
"message": {
|
||||
"en": "message",
|
||||
"es": "mensaje",
|
||||
"pt": "mensagem"
|
||||
},
|
||||
"name": {
|
||||
"en": "name",
|
||||
"es": "nombre",
|
||||
"pt": "nome"
|
||||
},
|
||||
"players": {
|
||||
"en": "Players",
|
||||
"es": "Jugadores",
|
||||
"pt": "Jogadores"
|
||||
},
|
||||
"scrabble-name": {
|
||||
"en": "Scrabble",
|
||||
"es": "Scrabble",
|
||||
"pt": "Scrabble"
|
||||
},
|
||||
"spectators": {
|
||||
"en": "Spectators",
|
||||
"es": "Espectadores",
|
||||
"pt": "Espectadores"
|
||||
},
|
||||
"visibility": {
|
||||
"en": "Visibility",
|
||||
"es": "Visibilidad",
|
||||
"pt": "Visibilidade"
|
||||
},
|
||||
"status": {
|
||||
"en": "Status",
|
||||
"es": "Status",
|
||||
"pt": "Status"
|
||||
},
|
||||
"button-start-game": {
|
||||
"en": "Start Game",
|
||||
"es": "Empezar Juego",
|
||||
"pt": "Começar Jogo"
|
||||
"status-connected": {
|
||||
"en": "Connected",
|
||||
"es": "Conectado(a)",
|
||||
"pt": "Conectado(a)"
|
||||
},
|
||||
"button-leave-lobby": {
|
||||
"en": "Leave Lobby",
|
||||
"es": "Salir del Lobby",
|
||||
"pt": "Sair do Lobby"
|
||||
"status-connected-as": {
|
||||
"en": "Connected as",
|
||||
"es": "Conectado/a como",
|
||||
"pt": "Conectado/a como"
|
||||
},
|
||||
|
||||
|
||||
"error-bold": {
|
||||
"en": "ERROR",
|
||||
"es": "ERRO",
|
||||
"pt": "ERROR"
|
||||
"status-disconnected": {
|
||||
"en": "Disconnected",
|
||||
"es": "Desconectado/a",
|
||||
"pt": "Desconectado/a"
|
||||
},
|
||||
"error-no-username": {
|
||||
"en": "Username not present",
|
||||
"es": "Nombre de usuario no esta presente",
|
||||
"pt": "Nome de usuário não esta presente"
|
||||
"username": {
|
||||
"en": "Username",
|
||||
"es": "Nombre de usuario",
|
||||
"pt": "Nome de usuàrio"
|
||||
},
|
||||
"error-invalid-username": {
|
||||
"en": "Invalid username",
|
||||
"es": "Nombre de usuario no es válido",
|
||||
"pt": "Nome de usuário Inválido"
|
||||
},
|
||||
"error-taken-username": {
|
||||
"en": "Username taken",
|
||||
"es": "Nombre de usuario no esta disponible",
|
||||
"pt": "Nome de usuário já está em uso"
|
||||
},
|
||||
"error-too-many-clients": {
|
||||
"en": "Too many connections",
|
||||
"es": "Demasiadas conexiones",
|
||||
"pt": "Demasiadas conexões"
|
||||
},
|
||||
"error-bad-intent": {
|
||||
"en": "Client has no intent",
|
||||
"es": "Cliente no tiene intención",
|
||||
"pt": "Cliente não tem intenção"
|
||||
},
|
||||
"error-unknown-uid": {
|
||||
"en": "Unknown user ID",
|
||||
"es": "ID de usuario desconocido",
|
||||
"pt": "ID de usuário desconhecido"
|
||||
},
|
||||
"error-taken-user-connection": {
|
||||
"en": "User already connected",
|
||||
"es": "Usuario ya está conectado/a",
|
||||
"pt": "Usuário já está conectado/a"
|
||||
},
|
||||
"error-illegal-user": {
|
||||
"en": "Illegal user",
|
||||
"es": "Usuario ilegal",
|
||||
"pt": "Usuário ilegal"
|
||||
},
|
||||
"error-malformed-lobby": {
|
||||
"en": "Lobby malformed",
|
||||
"es": "Lobby malformado",
|
||||
"pt": "Lobby malformado"
|
||||
},
|
||||
"error-taken-lobby-ownership": {
|
||||
"en": "User already owns lobby",
|
||||
"es": "Usuario ya tiene lobby",
|
||||
"pt": "Usuário já tem um lobby"
|
||||
},
|
||||
"error-illegal-lobby": {
|
||||
"en": "Illegal lobby",
|
||||
"es": "Lobby ilegal",
|
||||
"pt": "Lobby ilegal"
|
||||
},
|
||||
"error-cannot-join-lobby": {
|
||||
"en": "Cannot join lobby",
|
||||
"es": "No se puede unir al lobby",
|
||||
"pt": "Não é possível entrar no lobby"
|
||||
},
|
||||
"error-lobby-not-exist": {
|
||||
"en": "Lobby does not exist",
|
||||
"es": "Lobby no existe",
|
||||
"pt": "Lobby não existe"
|
||||
},
|
||||
"error-lobby-name-required": {
|
||||
"en": "A name is requred",
|
||||
"es": "Se requiere un nombre",
|
||||
"pt": "Um nome é obrigatório"
|
||||
},
|
||||
"error-creating-lobby": {
|
||||
"en": "An error occurred while creating the lobby",
|
||||
"es": "Ocurrió un error al crear el lobby",
|
||||
"pt": "Ocorreu um erro ao criar o lobby"
|
||||
},
|
||||
"error-lobby-id-required": {
|
||||
"en": "A lobby ID is required",
|
||||
"es": "Se requiere un lobby ID",
|
||||
"pt": "É necessário um lobby ID"
|
||||
},
|
||||
"error-lobby-joining": {
|
||||
"en": "An error occurred while joining the lobby",
|
||||
"es": "Ocurrió un error al conectarse al lobby",
|
||||
"pt": "Ocorreu um erro ao entrar no lobby"
|
||||
"visibility": {
|
||||
"en": "Visibility",
|
||||
"es": "Visibilidad",
|
||||
"pt": "Visibilidade"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,4 @@ status-connected:Conectado(a)
|
||||
status-connected-as:Conectado/a como
|
||||
status-disconnected:Desconectado/a
|
||||
username:Nome de usuàrio
|
||||
visibility:Visibilidade
|
||||
visibility:Visibilidade
|
||||
15
scripts/addLocale.js
Normal file
15
scripts/addLocale.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// called with CLI args to add a locale code (with english translation & meaning) to the en.lang
|
||||
// calls updateLocaleFromEnglish to update the other language files
|
||||
// calls langParser to update the locale.json with the newly updated files
|
||||
|
||||
// call as node ./addLocale.js [locale-code] [english translation of the sentence]
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const localeName = process.argv.slice(2)[0];
|
||||
const localeString = process.argv.slice(3).join(' ');
|
||||
|
||||
fs.appendFileSync('../data/en.lang', '\n' + localeName + ':' + localeString);
|
||||
|
||||
require('./updateLocaleFromEnglish.js');
|
||||
require('./langParser.js');
|
||||
@@ -0,0 +1,47 @@
|
||||
// parses the lang files and generates a locale.json file
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
let languages = [];
|
||||
fs.readdirSync('../data/').map(e => {
|
||||
if (e.endsWith('.lang')) languages.push(e.split('.')[0]);
|
||||
});
|
||||
|
||||
let localeCodes = [];
|
||||
let translations = {};
|
||||
|
||||
// extract data from language files
|
||||
for (let lang in languages)
|
||||
{
|
||||
let codesToTranslations = fs.readFileSync(`../data/${languages[lang]}.lang`).toString()
|
||||
.split('----')[1]
|
||||
.split('\n')
|
||||
.filter(e => e != null && e != '')
|
||||
.map(e => new Array(e.split(':')[0], e.split(':')[1]));
|
||||
translations[languages[lang]] = codesToTranslations;
|
||||
|
||||
// build list of localeCodes
|
||||
for (const code in codesToTranslations)
|
||||
{
|
||||
if (!localeCodes.includes(codesToTranslations[code][0])) localeCodes.push(codesToTranslations[code][0]);
|
||||
}
|
||||
}
|
||||
|
||||
let output = {};
|
||||
|
||||
for (const code of localeCodes)
|
||||
{
|
||||
output[code] = {}
|
||||
|
||||
for (const lang of languages)
|
||||
{
|
||||
// do not default to english - client will do that
|
||||
// remove whitespace and notes
|
||||
if (translations[lang].find(e => e[0] == code))
|
||||
output[code][lang] = translations[lang].find(e => e[0] == code)[1].trim().split(';')[0];
|
||||
else
|
||||
output[code][lang] = "";
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync('../data/locale.json', JSON.stringify(output, null, 4))
|
||||
|
||||
14
scripts/newLanguage.js
Normal file
14
scripts/newLanguage.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// simple script to make a new, blank language file for filling in based on the english one
|
||||
|
||||
// call as node newLocale.js fr
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileToMake = process.argv.slice(2)[0];
|
||||
|
||||
// load english
|
||||
const englishLocaleCodes = fs.readFileSync('../data/en.lang').toString().split('----')[1].split('\n').filter(e => e != null && e != '').map(e => e.split(':')[0]);
|
||||
const output = `language:${fileToMake}\n----\n` + englishLocaleCodes.reduce((p, e) => p += e + ':\n').toString();
|
||||
|
||||
fs.writeFileSync(`../data/${fileToMake}.lang`, output);
|
||||
|
||||
@@ -1,2 +1,73 @@
|
||||
// to update all other languages files based on the english file (for new locale codes)
|
||||
|
||||
// warning: sphagettie code
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
let languagesNotEn = [];
|
||||
fs.readdirSync('../data/').map(e => {
|
||||
if (e.endsWith('.lang') && !e.includes('en')) languagesNotEn.push(e.split('.')[0]);
|
||||
});
|
||||
|
||||
const newEnHeader = fs.readFileSync('../data/en.lang').toString().split('----')[0] + '----';
|
||||
const sortedKeyValueEn = fs.readFileSync('../data/en.lang').toString()
|
||||
.split('----')[1]
|
||||
.split('\n')
|
||||
.sort((a, b) => {
|
||||
// sort by code only
|
||||
a = a.split(':')[0];
|
||||
b = b.split(':')[0];
|
||||
if (a < b)
|
||||
return -1;
|
||||
if (a > b)
|
||||
return 1;
|
||||
return 0;
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
fs.writeFileSync('../data/en.lang', (newEnHeader + sortedKeyValueEn));
|
||||
|
||||
const codesInEn = fs.readFileSync('../data/en.lang').toString()
|
||||
.split('----')[1]
|
||||
.split('\n')
|
||||
.map(e => e.split(':')[0])
|
||||
.filter(e => e != null && e != '')
|
||||
.sort();
|
||||
|
||||
for (const lang of languagesNotEn)
|
||||
{
|
||||
const newLangHeader = fs.readFileSync(`../data/${lang}.lang`).toString().split('----')[0] + '----\n';
|
||||
const codesInLang = fs.readFileSync(`../data/${lang}.lang`).toString()
|
||||
.split('----')[1]
|
||||
.split('\n')
|
||||
.map(e => e.split(':')[0])
|
||||
.filter(e => e != null && e != '')
|
||||
.sort();
|
||||
|
||||
let output = fs.readFileSync(`../data/${lang}.lang`).toString().split('----')[1];
|
||||
|
||||
let newCodes = [];
|
||||
for (const code in codesInEn)
|
||||
{
|
||||
if (!codesInLang.includes(codesInEn[code]))
|
||||
{
|
||||
newCodes.push(codesInEn[code]);
|
||||
}
|
||||
}
|
||||
|
||||
for (const code of newCodes)
|
||||
output += '\n' + code + ':\n';
|
||||
|
||||
output = output.split('\n').sort((a, b) => {
|
||||
// sort by code only
|
||||
a = a.split(':')[0];
|
||||
b = b.split(':')[0];
|
||||
if (a < b)
|
||||
return -1;
|
||||
if (a > b)
|
||||
return 1;
|
||||
return 0;
|
||||
}).filter(e => e != null && e != '').join('\n');
|
||||
|
||||
fs.writeFileSync(`../data/${lang}.lang`, newLangHeader + output);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user