Minesweeper-2.0-test/scripts/game/language.js

82 lines
2.6 KiB
JavaScript
Raw Normal View History

2023-01-27 11:45:10 +00:00
/**************************************
文件名language.js
功能该模块用于处理主菜单语言相关内容
版本2.0(23.01.08)
**************************************/
/**************************************
对象名Language
参数lang: 传入语言(zh_cn为中文en为英文jp为日文)
**************************************/
function Language(lang){
this.lang = lang;
}
/**************************************
方式名langRender()
功能根据语种渲染对应的语言
**************************************/
Language.prototype.langRender = function(){
switch (this.lang){
case "zh_cn":
this.chineseRender();
break;
case "en":
this.englishRender();
break;
case "jp":
this.japaneseRender();
break;
}
}
/**************************************
方式名chineseRender()
功能渲染中文
**************************************/
Language.prototype.chineseRender = function(){
document.querySelector(".timeTitle").innerHTML = "游戏时长";
document.querySelector(".confirm").innerHTML = "确认";
let newBtn = document.querySelectorAll(".new");
for (let i = 0; i < newBtn.length; i++){
newBtn[i].innerHTML = "重开一局";
}
let back = document.querySelectorAll(".back");
for (let i = 0; i < back.length; i++){
back[i].innerHTML = "返回";
}
}
/**************************************
方式名englishRender()
功能渲染英文
**************************************/
Language.prototype.englishRender = function(){
document.querySelector(".timeTitle").innerHTML = "Time";
document.querySelector(".confirm").innerHTML = "Confirm";
let newBtn = document.querySelectorAll(".new");
for (let i = 0; i < newBtn.length; i++){
newBtn[i].innerHTML = "New Game";
}
let back = document.querySelectorAll(".back");
for (let i = 0; i < back.length; i++){
back[i].innerHTML = "Back";
}
}
/**************************************
方式名japaneseRender()
功能渲染日语
**************************************/
Language.prototype.japaneseRender = function(){
document.querySelector(".timeTitle").innerHTML = "プレイ時間";
document.querySelector(".confirm").innerHTML = "確認する";
let newBtn = document.querySelectorAll(".new");
for (let i = 0; i < newBtn.length; i++){
newBtn[i].innerHTML = "ニューゲーム";
}
let back = document.querySelectorAll(".back");
for (let i = 0; i < back.length; i++){
back[i].innerHTML = "戻る";
}
}