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 strings = JSON.parse(localStorage.getItem('locale-strings'));
|
||||||
let whatstring = strings[code];
|
let whatstring = strings[code];
|
||||||
|
if (!whatstring || whatstring == '') whatstring = strings['en'];
|
||||||
let locale = whatstring[localStorage.getItem('locale')];
|
let locale = whatstring[localStorage.getItem('locale')];
|
||||||
|
|
||||||
return locale;
|
return locale;
|
||||||
|
|||||||
@@ -11,3 +11,8 @@ Sometimes context clues may be neccesary for an accurate translation, everything
|
|||||||
```Code:Translation/Text;Context```
|
```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
|
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-connected-as:Connected as
|
||||||
status-disconnected:Disconnected
|
status-disconnected:Disconnected
|
||||||
username:Username
|
username:Username
|
||||||
visibility:Visibility
|
visibility:Visibility
|
||||||
@@ -56,4 +56,4 @@ status-connected:Conectado(a)
|
|||||||
status-connected-as:Conectado/a como
|
status-connected-as:Conectado/a como
|
||||||
status-disconnected:Desconectado/a
|
status-disconnected:Desconectado/a
|
||||||
username:Nombre de usuario
|
username:Nombre de usuario
|
||||||
visibility:Visibilidad
|
visibility:Visibilidad
|
||||||
436
data/locale.json
436
data/locale.json
@@ -1,38 +1,8 @@
|
|||||||
{
|
{
|
||||||
"scrabble-name": {
|
"button-back": {
|
||||||
"en": "Scrabble",
|
"en": "back",
|
||||||
"es": "Scrabble",
|
"es": "regresar",
|
||||||
"pt": "Scrabble"
|
"pt": "voltar"
|
||||||
},
|
|
||||||
"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-create": {
|
"button-create": {
|
||||||
"en": "create",
|
"en": "create",
|
||||||
@@ -44,113 +14,130 @@
|
|||||||
"es": "participar",
|
"es": "participar",
|
||||||
"pt": "entrar"
|
"pt": "entrar"
|
||||||
},
|
},
|
||||||
"button-back": {
|
"button-leave-lobby": {
|
||||||
"en": "back",
|
"en": "Leave Lobby",
|
||||||
"es": "regresar",
|
"es": "Salir del Lobby",
|
||||||
"pt": "voltar"
|
"pt": "Sair do Lobby"
|
||||||
},
|
},
|
||||||
|
"button-send": {
|
||||||
"status-connected": {
|
"en": "send",
|
||||||
"en": "Connected",
|
"es": "enviar",
|
||||||
"es": "Conectado(a)",
|
"pt": "enviar"
|
||||||
"pt": "Conectado(a)"
|
|
||||||
},
|
},
|
||||||
"status-connected-as": {
|
"button-singleplayer": {
|
||||||
"en": "Connected as ",
|
"en": "Play singleplayer",
|
||||||
"es": "Conectado/a como ",
|
"es": "Jugar a un(a) jugador(a)",
|
||||||
"pt": "Conectado/a como "
|
"pt": "Jogar singleplayer"
|
||||||
},
|
},
|
||||||
"status-disconnected": {
|
"button-start-game": {
|
||||||
"en": "Disconnected",
|
"en": "Start Game",
|
||||||
"es": "Desconectado/a",
|
"es": "Empezar Juego",
|
||||||
"pt": "Desconectado/a"
|
"pt": "Começar Jogo"
|
||||||
|
},
|
||||||
|
"button-submit": {
|
||||||
|
"en": "Submit",
|
||||||
|
"es": "Enviar",
|
||||||
|
"pt": "Enviar"
|
||||||
},
|
},
|
||||||
"connection-waiting": {
|
"connection-waiting": {
|
||||||
"en": "Waiting for connection",
|
"en": "Waiting for connection",
|
||||||
"es": "Esperando la conexión",
|
"es": "Esperando la conexión",
|
||||||
"pt": "Aguardando conexão"
|
"pt": "Aguardando conexão"
|
||||||
},
|
},
|
||||||
|
"error-bad-intent": {
|
||||||
"message": {
|
"en": "Client has no intent",
|
||||||
"en": "message",
|
"es": "Cliente no tiene intención",
|
||||||
"es": "mensaje",
|
"pt": "Cliente não tem intenção"
|
||||||
"pt": "mensagem"
|
|
||||||
},
|
},
|
||||||
"log-console": {
|
"error-bold": {
|
||||||
"en": "log console",
|
"en": "ERROR",
|
||||||
"es": "consola de log",
|
"es": "ERRO",
|
||||||
"pt": "console de log"
|
"pt": "ERROR"
|
||||||
},
|
},
|
||||||
"button-send": {
|
"error-cannot-join-lobby": {
|
||||||
"en": "send",
|
"en": "Cannot join lobby",
|
||||||
"es": "enviar",
|
"es": "No se puede unir al lobby",
|
||||||
"pt": "enviar"
|
"pt": "Não é possível entrar no lobby"
|
||||||
},
|
},
|
||||||
|
"error-creating-lobby": {
|
||||||
"lobby": {
|
"en": "An error occurred while creating the lobby",
|
||||||
"en": "Lobby",
|
"es": "Ocurrió un error al crear el lobby",
|
||||||
"es": "Lobby",
|
"pt": "Ocorreu um erro ao criar o lobby"
|
||||||
"pt": "Lobby"
|
|
||||||
},
|
},
|
||||||
"lobby-create": {
|
"error-illegal-lobby": {
|
||||||
"en": "Create Lobby",
|
"en": "Illegal lobby",
|
||||||
"es": "Crear Lobby",
|
"es": "Lobby ilegal",
|
||||||
"pt": "Criar Lobby"
|
"pt": "Lobby ilegal"
|
||||||
},
|
},
|
||||||
"lobby-join": {
|
"error-illegal-user": {
|
||||||
"en": "Join Lobby",
|
"en": "Illegal user",
|
||||||
"es": "Conectarse al Lobby",
|
"es": "Usuario ilegal",
|
||||||
"pt": "Conectar ao Lobby"
|
"pt": "Usuário ilegal"
|
||||||
},
|
},
|
||||||
"lobby-join-code": {
|
"error-invalid-username": {
|
||||||
"en": "Join Code",
|
"en": "Invalid username",
|
||||||
"es": "Código para Conectar",
|
"es": "Nombre de usuario no es válido",
|
||||||
"pt": "Código para Conectar"
|
"pt": "Nome de usuário Inválido"
|
||||||
},
|
},
|
||||||
"lobby-code": {
|
"error-lobby-id-required": {
|
||||||
"en": "lobby code",
|
"en": "A lobby ID is required",
|
||||||
"es": "código de lobby",
|
"es": "Se requiere un lobby ID",
|
||||||
"pt": "código do lobby"
|
"pt": "É necessário um lobby ID"
|
||||||
},
|
},
|
||||||
"lobby-private": {
|
"error-lobby-joining": {
|
||||||
"en": "private lobby",
|
"en": "An error occurred while joining the lobby",
|
||||||
"es": "lobby privado",
|
"es": "Ocurrió un error al conectarse al lobby",
|
||||||
"pt": "lobby privado"
|
"pt": "Ocorreu um erro ao entrar no lobby"
|
||||||
},
|
},
|
||||||
"lobby-allow-spectators": {
|
"error-lobby-name-required": {
|
||||||
"en": "allow spectators",
|
"en": "A name is requred",
|
||||||
"es": "permitir espectadores",
|
"es": "Se requiere un nombre",
|
||||||
"pt": "permitir espectadores"
|
"pt": "Um nome é obrigatório"
|
||||||
},
|
},
|
||||||
"lobby-join-spectator": {
|
"error-lobby-not-exist": {
|
||||||
"en": "join as spectator",
|
"en": "Lobby does not exist",
|
||||||
"es": "conectar como espectador(a)",
|
"es": "Lobby no existe",
|
||||||
"pt": "junte-se como espectador"
|
"pt": "Lobby não existe"
|
||||||
},
|
},
|
||||||
"lobby-created-joining": {
|
"error-malformed-lobby": {
|
||||||
"en": "Lobby created, Joining...",
|
"en": "Lobby malformed",
|
||||||
"es": "Lobby creado, Conectando...",
|
"es": "Lobby malformado",
|
||||||
"pt": "Lobby criaso, Juntando-se..."
|
"pt": "Lobby malformado"
|
||||||
},
|
},
|
||||||
"lobby-created": {
|
"error-no-username": {
|
||||||
"en": "created lobby",
|
"en": "Username not present",
|
||||||
"es": "lobby creado",
|
"es": "Nombre de usuario no esta presente",
|
||||||
"pt": "Lobby criado"
|
"pt": "Nome de usuário não esta presente"
|
||||||
},
|
},
|
||||||
"lobby-joining": {
|
"error-taken-lobby-ownership": {
|
||||||
"en": "joining lobby",
|
"en": "User already owns lobby",
|
||||||
"es": "entrando al lobby",
|
"es": "Usuario ya tiene lobby",
|
||||||
"pt": "entrando no lobby"
|
"pt": "Usuário já tem um lobby"
|
||||||
},
|
},
|
||||||
"lobby-joined": {
|
"error-taken-user-connection": {
|
||||||
"en": "joined lobby",
|
"en": "User already connected",
|
||||||
"es": "entró en el lobby",
|
"es": "Usuario ya está conectado/a",
|
||||||
"pt": "entrou no lobby"
|
"pt": "Usuário já está conectado/a"
|
||||||
},
|
},
|
||||||
"lobby-deleted": {
|
"error-taken-username": {
|
||||||
"en": "deleted lobby",
|
"en": "Username taken",
|
||||||
"es": "lobby eliminado",
|
"es": "Nombre de usuario no esta disponible",
|
||||||
"pt": "lobby apagado"
|
"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": {
|
"joined": {
|
||||||
"en": "joined",
|
"en": "joined",
|
||||||
@@ -167,122 +154,129 @@
|
|||||||
"es": "salió del lobby",
|
"es": "salió del lobby",
|
||||||
"pt": "saiu do 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": {
|
"spectators": {
|
||||||
"en": "Spectators",
|
"en": "Spectators",
|
||||||
"es": "Espectadores",
|
"es": "Espectadores",
|
||||||
"pt": "Espectadores"
|
"pt": "Espectadores"
|
||||||
},
|
},
|
||||||
"visibility": {
|
|
||||||
"en": "Visibility",
|
|
||||||
"es": "Visibilidad",
|
|
||||||
"pt": "Visibilidade"
|
|
||||||
},
|
|
||||||
"status": {
|
"status": {
|
||||||
"en": "Status",
|
"en": "Status",
|
||||||
"es": "Status",
|
"es": "Status",
|
||||||
"pt": "Status"
|
"pt": "Status"
|
||||||
},
|
},
|
||||||
"button-start-game": {
|
"status-connected": {
|
||||||
"en": "Start Game",
|
"en": "Connected",
|
||||||
"es": "Empezar Juego",
|
"es": "Conectado(a)",
|
||||||
"pt": "Começar Jogo"
|
"pt": "Conectado(a)"
|
||||||
},
|
},
|
||||||
"button-leave-lobby": {
|
"status-connected-as": {
|
||||||
"en": "Leave Lobby",
|
"en": "Connected as",
|
||||||
"es": "Salir del Lobby",
|
"es": "Conectado/a como",
|
||||||
"pt": "Sair do Lobby"
|
"pt": "Conectado/a como"
|
||||||
},
|
},
|
||||||
|
"status-disconnected": {
|
||||||
|
"en": "Disconnected",
|
||||||
"error-bold": {
|
"es": "Desconectado/a",
|
||||||
"en": "ERROR",
|
"pt": "Desconectado/a"
|
||||||
"es": "ERRO",
|
|
||||||
"pt": "ERROR"
|
|
||||||
},
|
},
|
||||||
"error-no-username": {
|
"username": {
|
||||||
"en": "Username not present",
|
"en": "Username",
|
||||||
"es": "Nombre de usuario no esta presente",
|
"es": "Nombre de usuario",
|
||||||
"pt": "Nome de usuário não esta presente"
|
"pt": "Nome de usuàrio"
|
||||||
},
|
},
|
||||||
"error-invalid-username": {
|
"visibility": {
|
||||||
"en": "Invalid username",
|
"en": "Visibility",
|
||||||
"es": "Nombre de usuario no es válido",
|
"es": "Visibilidad",
|
||||||
"pt": "Nome de usuário Inválido"
|
"pt": "Visibilidade"
|
||||||
},
|
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,4 +56,4 @@ status-connected:Conectado(a)
|
|||||||
status-connected-as:Conectado/a como
|
status-connected-as:Conectado/a como
|
||||||
status-disconnected:Desconectado/a
|
status-disconnected:Desconectado/a
|
||||||
username:Nome de usuàrio
|
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