Indeed !
Card art is so good in Res Arcana, there was no way we could have generated it without a significant loss to quality.
We settled on en/fr/jp cards.
The method is simple :
- Detect locale on setup
- Prevent preload of card images not needed
- Apply a css class on body depending on the locale
a few notes :
- locale is detected on browser and may be inacurate, work with exact matches and a default
- having the url of the different locales art files in the css can still lead to the browser loading them
- you can probably write this way better than I did at the time but you'll get the idea
main js :
css :
Card art is so good in Res Arcana, there was no way we could have generated it without a significant loss to quality.
We settled on en/fr/jp cards.
The method is simple :
- Detect locale on setup
- Prevent preload of card images not needed
- Apply a css class on body depending on the locale
a few notes :
- locale is detected on browser and may be inacurate, work with exact matches and a default
- having the url of the different locales art files in the css can still lead to the browser loading them
- you can probably write this way better than I did at the time but you'll get the idea
main js :
Code: Select all
setuplang:function() {
let lang = dojo.config.locale.substr(0, 2);
// console.log("detected lang ", lang);
// if (window.location.href.includes("studio.boardgamearena.com")) {
// lang="fr";
// console.log("on studio, lang forced to fr");
// }
if (lang=="fr") {
this.preventpreload("en");
this.preventpreload("jp");
dojo.addClass('ebd-body', 'localefr');
}
else if (lang=="ja"){
this.preventpreload("en");
this.preventpreload("fr");
dojo.addClass('ebd-body', 'localejp');
} else {
this.preventpreload("fr");
this.preventpreload("jp");
dojo.addClass('ebd-body', 'localeen');
}
},
preventpreload:function(lang) {
const prefix = lang+".";
if (lang=="en") prefix="";
let dontpreload=[];
(...)
dontpreload.push(prefix+'magicitems.jpg');
for (let idx in dontpreload) {
this.dontPreloadImage(dontpreload[idx]);
}
},
Code: Select all
.localeen .res_magicitem
{
background-image: url('img/magicitems.jpg');
}
.localefr .res_magicitem
{
background-image: url('img/fr.magicitems.jpg');
}