Skip to content

Commit

Permalink
i18n WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
fourinone41 committed Jul 1, 2024
1 parent cc2d779 commit 2cd361e
Show file tree
Hide file tree
Showing 8 changed files with 1,593 additions and 585 deletions.
537 changes: 537 additions & 0 deletions js/data/strings_en.json

Large diffs are not rendered by default.

537 changes: 537 additions & 0 deletions js/data/strings_ja.json

Large diffs are not rendered by default.

154 changes: 24 additions & 130 deletions js/simulator-ui/cmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,132 +69,10 @@ COMMON.CMP_LOADING = {

let messages = {
en: {
'ui_search': 'Search',
'ui_back': 'Back',
'ship_name_0': '',
'equip_name_0': '',
'selector': {
'ship_section_Shipgirls': 'Shipgirls',
'ship_section_Abyssals': 'Abyssals',
'ship_section_Extra': 'Extra',
'ship_cat_DD': 'DD',
'ship_cat_CL(T)': 'CL(T)',
'ship_cat_CA(V)': 'CA(V)',
'ship_cat_BB(V)': 'BB(V)',
'ship_cat_CVL': 'CVL',
'ship_cat_CV': 'CV',
'ship_cat_CV(L)': 'CV(L)',
'ship_cat_SS(V)': 'SS(V)',
'ship_cat_Other': 'Other',
'ship_cat_Installation': 'Installation',
'ship_cat_Arpeggio': 'Arpeggio',
'ship_cat_Vita': 'Vita',
'ship_cat_???': '???',
'ship_title_Base': 'Base',
'equip_section_Player': 'Player',
'equip_section_Abyssal': 'Abyssal',
'equip_cat_Main Gun (S)': 'Main Gun (S)',
'equip_cat_Main Gun (M)': 'Main Gun (M)',
'equip_cat_Main Gun (L)': 'Main Gun (L)',
'equip_cat_Secondary Gun': 'Secondary Gun',
'equip_cat_Torpedo': 'Torpedo',
'equip_cat_Midget Sub': 'Midget Sub',
'equip_cat_Fighter': 'Fighter',
'equip_cat_Dive Bomber': 'Dive Bomber',
'equip_cat_Torpedo Bomber': 'Torpedo Bomber',
'equip_cat_Other Aircraft': 'Other Aircraft',
'equip_cat_Seaplane': 'Seaplane',
'equip_cat_Seaplane Bomber': 'Seaplane Bomber',
'equip_cat_Seaplane Fighter': 'Seaplane Fighter',
'equip_cat_Radar': 'Radar',
'equip_cat_Sonar': 'Sonar',
'equip_cat_Depth Charge': 'Depth Charge',
'equip_cat_Engine': 'Engine',
'equip_cat_Shell': 'Shell',
'equip_cat_Anti-Air Gun': 'Anti-Air Gun',
'equip_cat_Bulge': 'Bulge',
'equip_cat_Night Gear': 'Night Gear',
'equip_cat_Landing Craft': 'Landing Craft',
'equip_cat_Land-based Bomber': 'Land-based Bomber',
'equip_cat_Interceptor': 'Interceptor',
'equip_cat_Other': 'Other',
},
'results': {
'retreat_rate': 'Retreat',
'S_rate': 'S Rate',
'flagsunk_rate': 'Flagship Sunk Rate',
'avg_per_S': 'Avg Resource Per S',
'avg_per_flagsunk': 'Avg Resource Per Flagship Sunk',
'fuel': 'Fuel',
'ammo': 'Ammo',
'steel': 'Steel',
'baux': 'Bauxite',
'buckets': 'Buckets',
},

},
ja: {
'ui_search': '検索',
'ui_back': '戻る',
'ship_name_0': '',
'equip_name_0': '',
'selector': {
'ship_section_Shipgirls': '艦娘',
'ship_section_Abyssals': '深海棲艦',
'ship_section_Extra': 'EXTRA',
'ship_cat_DD': '駆逐艦',
'ship_cat_CL(T)': '軽巡級',
'ship_cat_CA(V)': '重巡級',
'ship_cat_BB(V)': '戦艦級',
'ship_cat_CVL': '軽空母',
'ship_cat_CV': '正規空母',
'ship_cat_CV(L)': '航空母艦',
'ship_cat_SS(V)': '潜水艦',
'ship_cat_Other': 'その他',
'ship_cat_Installation': '陸上施設',
'ship_cat_Arpeggio': 'アルペジオ',
'ship_cat_Vita': '艦これ改',
'ship_cat_???': '???',
'ship_title_Base': '未改',
'equip_section_Player': '艦娘',
'equip_section_Abyssal': '深海棲艦',
'equip_cat_Main Gun (S)': '小口径主砲',
'equip_cat_Main Gun (M)': '中口径主砲',
'equip_cat_Main Gun (L)': '大口径主砲',
'equip_cat_Secondary Gun': '副砲',
'equip_cat_Torpedo': '魚雷',
'equip_cat_Midget Sub': '特殊潜航艇',
'equip_cat_Fighter': '艦上戦闘機',
'equip_cat_Dive Bomber': '艦上爆撃機',
'equip_cat_Torpedo Bomber': '艦上攻撃機',
'equip_cat_Other Aircraft': '他の艦載機',
'equip_cat_Seaplane': '水上偵察機',
'equip_cat_Seaplane Bomber': '水上爆撃機',
'equip_cat_Seaplane Fighter': '水上戦闘機',
'equip_cat_Radar': '電探',
'equip_cat_Sonar': 'ソナー',
'equip_cat_Depth Charge': '爆雷',
'equip_cat_Engine': '機関部強化',
'equip_cat_Shell': '強化弾',
'equip_cat_Anti-Air Gun': '対空機銃',
'equip_cat_Bulge': '追加装甲',
'equip_cat_Night Gear': '夜戦',
'equip_cat_Landing Craft': '上陸用舟艇',
'equip_cat_Land-based Bomber': '陸上攻撃機',
'equip_cat_Interceptor': '局地戦闘機',
'equip_cat_Other': 'その他',
},
'results': {
'retreat_rate': '撤退率',
'S_rate': 'S率',
'flagsunk_rate': '旗艦撃沈率',
'avg_per_S': 'S勝利あたり',
'avg_per_flagsunk': '旗艦撃沈あたり',
'fuel': '燃料',
'ammo': '弾薬',
'steel': '鋼材',
'baux': 'ボーキ',
'buckets': 'バケツ',
},

},
}
for (let id in SHIPDATA) {
Expand All @@ -207,11 +85,27 @@ for (let id in EQDATA) {
messages.en[key] = EQDATA[id].name;
messages.ja[key] = EQDATA[id].nameJP;
}
//note: using dev because prod behaves different? (component locale not reactive on $t)
COMMON.i18n = VueI18n.createI18n({
locale: 'en',
fallbackLocale: 'en',
messages,
});
async function init() {
let datas = await Promise.all([
fetch('js/data/strings_en.json').then(resp => resp.json()),
fetch('js/data/strings_ja.json').then(resp => resp.json())
]);
let stringsEN = datas[0];
let stringsJA = datas[1];
for (let key in stringsEN) {
messages.en[key] = stringsEN[key];
}
for (let key in stringsJA) {
messages.ja[key] = stringsJA[key];
}

//note: using dev because prod behaves different? (component locale not reactive on $t)
COMMON.i18n = VueI18n.createI18n({
locale: 'en',
fallbackLocale: 'en',
messages,
});
}
COMMON.promiseI18n = init();

})();
17 changes: 9 additions & 8 deletions js/simulator-ui/fleet-editor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(() => {
COMMON.promiseI18n.then(() => {

var CONST = window.COMMON.getConst({
numShipMax: 7,
Expand All @@ -13,9 +13,9 @@ var CONST = window.COMMON.getConst({
shipImgNameDefault: 'Kblank.png',
equipImgNameDefault: 'empty',

tooltipUnknownStat: 'This stat\'s true value is currently unknown.',
tooltipUnknownStatPlaceholder: 'This stat\'s true value is unknown, it is a placeholder not backed by data. Recommended to try setting your own value.',
tooltipUnknownStatDBEstimate: 'This stat\'s true value is unknown, it is an estimate based on data from DB submissions.',
tooltipUnknownStat: 'stat_true_value_unknown',
tooltipUnknownStatPlaceholder: 'stat_true_value_placeholder',
tooltipUnknownStatDBEstimate: 'stat_true_value_db_estimate',

rankExceptTypes: [],
rankDefaultSpecial: {},
Expand Down Expand Up @@ -523,10 +523,11 @@ var UI_FLEETEDITOR = Vue.createApp({
if (ship.statsUnknown[stat] == CONST.STAT_UNKNOWN.DB_ESTIMATE) return {unknownMed:true};
},
getTitleStat: function(ship,stat) {
if (ship.statsBase[stat] != ship.statsDefault[stat]) return null;
if (ship.statsBase[stat] != ship.statsDefault[stat]) return '';
if (ship.statsUnknown[stat] == CONST.STAT_UNKNOWN.NONE) return CONST.tooltipUnknownStat;
if (ship.statsUnknown[stat] == CONST.STAT_UNKNOWN.PLACEHOLDER) return CONST.tooltipUnknownStatPlaceholder;
if (ship.statsUnknown[stat] == CONST.STAT_UNKNOWN.DB_ESTIMATE) return CONST.tooltipUnknownStatDBEstimate;
return '';
},
getClassHP: function(ship) {
if (ship.hpInit/ship.hp <= .25) return 'damage heavy';
Expand Down Expand Up @@ -1066,7 +1067,7 @@ var UI_ADDITIONALSTATS = Vue.createApp({
this.active = false;
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divAdditionalStats');
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divAdditionalStats');


var UI_ADDITIONALSTATSLBAS = Vue.createApp({
Expand Down Expand Up @@ -1118,7 +1119,7 @@ var UI_ADDITIONALSTATSLBAS = Vue.createApp({
this.active = false;
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divAdditionalStatsLBAS');
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divAdditionalStatsLBAS');



Expand All @@ -1144,4 +1145,4 @@ COMMON.global.fleetEditorMoveTemp = function(elFrom) {
}
}

})();
})
5 changes: 3 additions & 2 deletions js/simulator-ui/selector.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(() => {
COMMON.promiseI18n.then(() => {

var CONST = window.COMMON.getConst({
MAX_RESULTS: 9999,
Expand Down Expand Up @@ -471,6 +471,7 @@ COMMON.global.equipSelectorOpen = function(callbackSubmit,callbackClose,keyInit)
COMMON.global.equipSelectorClose = function() {
UI_EQUIPSELECTOR.doClose();
}
COMMON.global.selectorInit = init;


})();
})
23 changes: 10 additions & 13 deletions js/simulator-ui/ui-main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(() => {
COMMON.promiseI18n.then(() => {

var CONST = window.COMMON.getConst({
numBattlesMax: 9,
Expand Down Expand Up @@ -549,7 +549,7 @@ ${t('results.baux')}: ${this.results.bauxSunk}
${t('results.buckets')}: ${this.results.bucketSunk}`;
}
navigator.clipboard.writeText(txt);
this.noticeTxt = 'Copied to Clipboard';
this.noticeTxt = t('copied_to_clipboard');
let n = ++this.showNoticeCount;
setTimeout(() => n == this.showNoticeCount && (this.showNoticeCount = 0), 1000);
},
Expand Down Expand Up @@ -658,9 +658,6 @@ ${t('results.buckets')}: ${this.results.bucketSunk}`;
},
},
methods: {
getCompName: function(comp) {
return this.fleetname + ' - Comp ' + comp.num;
},
getCompPercent: function(comp) {
let total = this.comps.reduce((a,b) => a + Math.max(0,b.rate),0);
if (total <= 0) return Math.round(100/this.comps.length);
Expand Down Expand Up @@ -709,7 +706,7 @@ var UI_BONUSEDITOR = Vue.createApp({
this.active = false;
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divBonusEditor');
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divBonusEditor');


var UI_DECKBUILDERIMPORTER = Vue.createApp({
Expand Down Expand Up @@ -798,7 +795,7 @@ var UI_DECKBUILDERIMPORTER = Vue.createApp({
event.target.select();
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divDeckbuilderImporter');
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divDeckbuilderImporter');


var UI_KCNAVCOMPIMPORTER = Vue.createApp({
Expand Down Expand Up @@ -986,7 +983,7 @@ var UI_KCNAVCOMPIMPORTER = Vue.createApp({
}.bind(this),500);
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divKCNavCompImporter');
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divKCNavCompImporter');


var UI_BONUSIMPORTER = Vue.createApp({
Expand Down Expand Up @@ -1211,7 +1208,7 @@ var UI_BONUSIMPORTER = Vue.createApp({
}.bind(this),500);
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divBonusImporter');
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divBonusImporter');


var UI_BACKUP = Vue.createApp({
Expand Down Expand Up @@ -1302,7 +1299,7 @@ var UI_BACKUP = Vue.createApp({
window.location.reload();
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divSimBackup');;
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divSimBackup');;


var UI_FCFSETTINGS = Vue.createApp({
Expand Down Expand Up @@ -1365,7 +1362,7 @@ var UI_FCFSETTINGS = Vue.createApp({
ship.neverFCF = !ship.neverFCF;
},
},
}).component('vmodal',COMMON.CMP_MODAL).mount('#divFCFSettings');;
}).component('vmodal',COMMON.CMP_MODAL).use(COMMON.i18n).mount('#divFCFSettings');;



Expand Down Expand Up @@ -1709,7 +1706,7 @@ var UI_AUTOBONUS = Vue.createApp({
this.canStart ? this.$refs.txtLoading.stop() : this.$refs.txtLoading.start();
},
},
}).component('vmodal',COMMON.CMP_MODAL).component('vloading',COMMON.CMP_LOADING).mount('#divAutoBonus');
}).component('vmodal',COMMON.CMP_MODAL).component('vloading',COMMON.CMP_LOADING).use(COMMON.i18n).mount('#divAutoBonus');



Expand All @@ -1721,4 +1718,4 @@ document.body.onunload = function() {

COMMON.UI_MAIN = UI_MAIN; //debug

})();
})
6 changes: 6 additions & 0 deletions js/vue-i18n.global.prod.js

Large diffs are not rendered by default.

Loading

0 comments on commit 2cd361e

Please sign in to comment.