Page 1 of 2
Getting language from JS?
Posted: 05 June 2021, 11:46
by __wiz__
Hi!
Is there a variable I can check on the client side to find out the user's requested language?
Thanks,
Thomas
Re: Getting language from JS?
Posted: 05 June 2021, 11:53
by Tisaac
__wiz__ wrote: ↑05 June 2021, 11:46
Hi!
Is there a variable I can check on the client side to find out the user's requested language?
Thanks,
Thomas
Why would you want to do that ?
Re: Getting language from JS?
Posted: 06 June 2021, 11:31
by __wiz__
It seems I'll be getting images for different language versions of a game (the graphics differ, so it's not just text replacement), so I want to display the correct images for the language.
Not sure how else to do that than to turn preloading off and then load the proper images for the language based on the client's language. But if you have better ideas?
Re: Getting language from JS?
Posted: 06 June 2021, 13:09
by robinzig
__wiz__ wrote: ↑06 June 2021, 11:31
It seems I'll be getting images for different language versions of a game (the graphics differ, so it's not just text replacement), so I want to display the correct images for the language.
Not sure how else to do that than to turn preloading off and then load the proper images for the language based on the client's language. But if you have better ideas?
Thanks for asking - if I'm allowed to "hijack", I've got an identical question about the game I'm developing (Deus). The image files I was given included two versions of the cards - one with names/text in English and the other in French. So far I'm only using the English ones but since the publisher included the French ones, and I believe they're a French-speaking publisher, it would be good to be able to use the French ones instead where appropriate. I'm not even going to think about implementing anything until the game logic is complete, but this was definitely on my mind to ask as part of the review process so I'm glad someone else has asked the question in advance
[One thought that crossed my mind was to use the game options and allow users to manually select English or French cards - but it would be good to be able to have it chosen automatically instead.]
Re: Getting language from JS?
Posted: 06 June 2021, 14:12
by thoun
For another game, editor sent cards with English text. We asked him for files without text and they send us layered files, so I could remove text and rebuild text with translated words. It's easier like this, having image file for each language will be hell to handle.
For original question, you say that it's not only the text that are different, can you put an example of 2 cards in different languages so we can see the difference and make the best suggestion?
Re: Getting language from JS?
Posted: 06 June 2021, 14:14
by Tisaac
The "cleanest" way to handle that is to recreate the cards yourself with the content as a real, translatable, text. This ensure that everyone can have it displayed in its own langage. That's a bit more work though.
An intermediate solution is to always display cards in english and have the card text/explanation in a translatable tooltip.
For your problem, I am not sure to understand what could be the advantages to have different assets for different languages
Re: Getting language from JS?
Posted: 06 June 2021, 16:39
by XCID
Regarding translatable card texts, does anyone have a good solution for dynamic text size to fit in the availabe space on the card?
What I do is setting a default fontsize, get the height of the div and keep reduceing the font size 1 by 1 until the div height is smaller than the maximum height. Bit I wonder if there is a more elegant and performant solution.
Re: Getting language from JS?
Posted: 07 June 2021, 01:36
by User Already Exists
It was my understanding that the original poster had different images for different languages (maybe different editions of the game), rather than just different text in the images.
Perhaps one method to get the language would be something like the following, which is clunky but might work:
Code: Select all
switch (_("en")) {
case "en":
default:
// use English cards
break;
case "fr":
// use French cards
break;
}
One would then have to ask the translators to translate the string "en" into the ISO 639-1 code of their respective languages. Of course, this is a bit indirect and error prone, since it requires cooperation from translators. If the language information is already available in the framework somehow, that would be more reliable.
Re: Getting language from JS?
Posted: 09 June 2021, 09:39
by apollo1001
If it is only 2 languages, then rather than trying to do things automatically, you could potentially use english as your default and add a gamepreference where the user can change it to the french cards if they wish to. I wouldn't recommend this if you're going to have more than 2 languages though...
Re: Getting language from JS?
Posted: 10 June 2021, 10:27
by Quinarbre
Res Arcana does precisely that (default is english, but french cards are displayed for French players).
Take a look at how they did, or ask the devs directly.