Auto-translate trappings

This commit is contained in:
LeRatierBretonnien 2020-03-31 12:25:27 +02:00
parent 37b88c1507
commit 9688136a7c
2 changed files with 34 additions and 1 deletions

View File

@ -69,6 +69,35 @@ Hooks.once('init', () => {
}
return talents_list;
},
"career_trappings": (trappings_list) => {
var compendium = game.packs.find(p => p.collection === 'wfrp4e.trappings');
var i;
var len = trappings_list.length;
var re = /(.*)\((.*)\)/i;
for (i = 0; i < len; i++) {
var transl = compendium.i18nName( trappings_list[i] );
if ( transl == trappings_list[i] ) {
var res = re.exec( trappings_list[i]);
if (res) {
//console.log("Matched/split:", res[1], res[2]);
var subword = game.i18n.localize(res[2].trim() );
var s1 = res[1].trim() + " ()";
var translw = compendium.i18nName( s1 );
if (translw != transl) {
var res2 = re.exec(translw);
transl = res2[1] + "(" + subword + ")";
} else {
s1 = res[1].trim() + " ( )";
translw = compendium.i18nName( s1 );
var res2 = re.exec(translw);
transl = res2[1] + "(" + subword + ")";
}
}
}
trappings_list[i] = transl;
}
return trappings_list;
},
// To avoid duplicateing class for all careers
"career_class": (value) => {
return game.i18n.localize( value.trim() );

View File

@ -16,6 +16,10 @@
"careergroup": {
"path": "data.careergroup.value",
"converter": "career_careergroup"
},
"trappings": {
"path": "data.trappings",
"converter": "career_trappings"
}
},
"entries": [