2020-03-25 20:37:09 +01:00
|
|
|
|
|
|
|
Hooks.once('init', () => {
|
|
|
|
|
|
|
|
if(typeof Babele !== 'undefined') {
|
|
|
|
|
|
|
|
Babele.get().register({
|
|
|
|
module: 'WH4-fr-translation',
|
|
|
|
lang: 'fr',
|
|
|
|
dir: 'compendium'
|
|
|
|
});
|
2020-03-30 23:23:21 +02:00
|
|
|
|
|
|
|
Babele.get().registerConverters({
|
|
|
|
"career_skills": (skills_list) => {
|
|
|
|
var compendium = game.packs.find(p => p.collection === 'wfrp4e.skills');
|
|
|
|
var i;
|
|
|
|
var len = skills_list.length;
|
|
|
|
var re = /(.*)\((.*)\)/i;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
var transl = compendium.i18nName( skills_list[i] );
|
|
|
|
if ( transl == skills_list[i] ) {
|
|
|
|
var res = re.exec( skills_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 + ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
skills_list[i] = transl;
|
|
|
|
}
|
|
|
|
return skills_list;
|
|
|
|
},
|
|
|
|
"career_talents": (talents_list) => {
|
|
|
|
var compendium = game.packs.find(p => p.collection === 'wfrp4e.talents');
|
|
|
|
var i;
|
|
|
|
var len = talents_list.length;
|
|
|
|
var re = /(.*)\((.*)\)/i;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
var transl = compendium.i18nName( talents_list[i] );
|
|
|
|
if ( transl == talents_list[i] ) {
|
|
|
|
var res = re.exec( talents_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 + ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
talents_list[i] = transl;
|
|
|
|
}
|
|
|
|
return talents_list;
|
|
|
|
}
|
|
|
|
});
|
2020-03-27 23:12:43 +01:00
|
|
|
}
|
|
|
|
|
2020-03-25 21:03:36 +01:00
|
|
|
} );
|