134 lines
5.6 KiB
JavaScript
134 lines
5.6 KiB
JavaScript
const app_translations = {
|
|
fr: {
|
|
"menu.languageLabel": "Langue",
|
|
"menu.title": "Configurez votre partie",
|
|
"menu.subtitle": "Reglez l'horloge, choisissez le mode de block, puis lancez la partie depuis le meme systeme de scenes.",
|
|
"menu.startGame": "Lancer la partie",
|
|
"menu.settingsTitle": "Parametres",
|
|
"menu.startTimeLabel": "Temps initial",
|
|
"menu.startTimeHelp": "Minutes pour les blancs et les noirs",
|
|
"menu.startMoveLabel": "Coups avant cube",
|
|
"menu.startMoveHelp": "Nombre de coups avant la phase cube",
|
|
"menu.blockTimeLabel": "Temps du block",
|
|
"menu.blockTimeHelp": "Minutes",
|
|
"menu.maxIncrementLabel": "Increment maximal",
|
|
"menu.maxIncrementHelp": "Secondes",
|
|
"menu.blockModeLabel": "La partie commence avec",
|
|
"menu.blockModeHelp": "Choisissez le mode de block utilise au debut de la partie",
|
|
"menu.blockPlus": "Block +",
|
|
"menu.blockMinus": "Block -",
|
|
"clock.start": "Start",
|
|
"clock.whiteWins": "Blanc gagne",
|
|
"clock.blackWins": "Noir gagne",
|
|
"clock.draw": "Nulle",
|
|
"clock.blockTime": "Temps restant Block : {time}",
|
|
"clock.movesWhite": "Coup restant Blanc : {number}",
|
|
"clock.movesBlack": "Coup restant Noir : {number}",
|
|
"cube.title": "Phase Cube",
|
|
"cube.subtitle": "Maintiens 2 secondes pour lancer le timer, puis touche de nouveau quand le cube est termine.",
|
|
"cube.hintStart": "Appui long pour demarrer",
|
|
"cube.hintFinish": "Touchez quand le cube est fini",
|
|
"cube.timeWhite": "Temps au cube Blanc : {time}",
|
|
"cube.timeBlack": "Temps au cube Noir : {time}",
|
|
"endgame.kicker": "Partie terminee",
|
|
"endgame.subtitle": "Le resultat final est valide. Vous pouvez revenir au menu pour preparer une nouvelle partie.",
|
|
"endgame.backToMenu": "Retour au menu",
|
|
"endgame.whiteWon": "Les Blancs ont gagne",
|
|
"endgame.blackWon": "Les Noirs ont gagne",
|
|
"endgame.draw": "Match nul",
|
|
"common.whiteUpper": "BLANC",
|
|
"common.blackUpper": "NOIR"
|
|
},
|
|
en: {
|
|
"menu.languageLabel": "Language",
|
|
"menu.title": "Configure your match",
|
|
"menu.subtitle": "Set the clock, choose the block mode, then launch the game from the same scene system.",
|
|
"menu.startGame": "Start Game",
|
|
"menu.settingsTitle": "Settings",
|
|
"menu.startTimeLabel": "Start Time",
|
|
"menu.startTimeHelp": "Minutes for both white and black",
|
|
"menu.startMoveLabel": "Moves Before Cube",
|
|
"menu.startMoveHelp": "Number of moves before the cube phase",
|
|
"menu.blockTimeLabel": "Block Time",
|
|
"menu.blockTimeHelp": "Minutes",
|
|
"menu.maxIncrementLabel": "Max Increment",
|
|
"menu.maxIncrementHelp": "Seconds",
|
|
"menu.blockModeLabel": "Game Starts With",
|
|
"menu.blockModeHelp": "Choose the block mode used when the game begins",
|
|
"menu.blockPlus": "Block +",
|
|
"menu.blockMinus": "Block -",
|
|
"clock.start": "Start",
|
|
"clock.whiteWins": "White wins",
|
|
"clock.blackWins": "Black wins",
|
|
"clock.draw": "Draw",
|
|
"clock.blockTime": "Block time left: {time}",
|
|
"clock.movesWhite": "White moves left: {number}",
|
|
"clock.movesBlack": "Black moves left: {number}",
|
|
"cube.title": "Cube Phase",
|
|
"cube.subtitle": "Hold for 2 seconds to start the timer, then tap again when the cube is finished.",
|
|
"cube.hintStart": "Long press to start",
|
|
"cube.hintFinish": "Tap when the cube is finished",
|
|
"cube.timeWhite": "White cube time: {time}",
|
|
"cube.timeBlack": "Black cube time: {time}",
|
|
"endgame.kicker": "Game Over",
|
|
"endgame.subtitle": "The final result is confirmed. You can return to the menu to set up a new game.",
|
|
"endgame.backToMenu": "Back to menu",
|
|
"endgame.whiteWon": "White wins",
|
|
"endgame.blackWon": "Black wins",
|
|
"endgame.draw": "Draw",
|
|
"common.whiteUpper": "WHITE",
|
|
"common.blackUpper": "BLACK"
|
|
}
|
|
}
|
|
|
|
let app_language = localStorage.getItem("menu_language") || "fr"
|
|
|
|
function get_app_translation(key, params = {}) {
|
|
const dictionary = app_translations[app_language] || app_translations.fr
|
|
const fallback_dictionary = app_translations.fr
|
|
let text = dictionary[key] || fallback_dictionary[key] || key
|
|
|
|
Object.keys(params).forEach((param_key) => {
|
|
text = text.replaceAll(`{${param_key}}`, params[param_key])
|
|
})
|
|
|
|
return text
|
|
}
|
|
|
|
function apply_static_translations() {
|
|
document.querySelectorAll("[data-i18n]").forEach((element) => {
|
|
const translated_text = get_app_translation(element.dataset.i18n)
|
|
|
|
if (element.tagName === "INPUT") {
|
|
element.value = translated_text
|
|
} else {
|
|
element.textContent = translated_text
|
|
}
|
|
})
|
|
}
|
|
|
|
function apply_app_language(language) {
|
|
app_language = app_translations[language] ? language : "fr"
|
|
localStorage.setItem("menu_language", app_language)
|
|
document.documentElement.lang = app_language
|
|
|
|
const language_select = document.getElementById("MenuLanguage")
|
|
if (language_select) {
|
|
language_select.value = app_language
|
|
}
|
|
|
|
apply_static_translations()
|
|
|
|
if (typeof refresh_clock_scene_translations === "function") {
|
|
refresh_clock_scene_translations()
|
|
}
|
|
|
|
if (typeof refresh_cube_scene_translations === "function") {
|
|
refresh_cube_scene_translations()
|
|
}
|
|
|
|
if (typeof refresh_endgame_scene_translations === "function") {
|
|
refresh_endgame_scene_translations()
|
|
}
|
|
}
|