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

82 lines
2.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**************************************
文件名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 = "戻る";
}
}