i18n
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
34 posts
• Page 1 of 3 • 1, 2, 3
i18n
by KrazyTheFox » 28 Jul 2014, 18:05
Since this discussion was taking place in the Android build thread, I've decided to create a topic instead of replying there as suggested.
Here's the start of the conversation if you'd like to follow along: http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=14534&start=420#p156709
--
I did some work not too long ago on the Starbound Mod Manager (see here and here) that involved making sure the entire program could be localized easily. All anyone has to do to add a new language is translate the strings file and put in a pull request to add it to the repo.
To achieve this, I used icu4j. This class I wrote should be able to be copied almost verbatim to Forge to add the functionality, then all we'd need to do is find every place in the program that uses a hard coded string that's visible to the user and replace them with getMessage(key) or formatMessage(key, replacement values).
getMessage(...) in the code linked above grabs a String from the localizer and presents it as is (plus behind-the-scenes localization, of course).
formatMessage(...) works in much the same way String.format(...) does. It takes a string from the localizer and replaces temporary values with the arguments provided.
A sample localization file looks like this:
To use the first line, just use:
To use the second line, you'll need to use:
Finally, the third line also uses formatMessage(...), but it instead applies pluralization rules to the text based on the number given.
That would look like:
I'm sure you're all very bored with the above, but based on simplicity, I'd propose that we use icu4j for localization and I could add in the code to handle that in no time at all. We'd just need someone to go change everything else; I don't have time at the moment.
I'll be happy to be in charge of maintaining this feature, but I would like some help replacing the current code. If no one wants to, I'll get to it in a couple weeks or so—it depends on when I can get my housing situation sorted out.
Here's the start of the conversation if you'd like to follow along: http://www.slightlymagic.net/forum/viewtopic.php?f=26&t=14534&start=420#p156709
--
I did some work not too long ago on the Starbound Mod Manager (see here and here) that involved making sure the entire program could be localized easily. All anyone has to do to add a new language is translate the strings file and put in a pull request to add it to the repo.
To achieve this, I used icu4j. This class I wrote should be able to be copied almost verbatim to Forge to add the functionality, then all we'd need to do is find every place in the program that uses a hard coded string that's visible to the user and replace them with getMessage(key) or formatMessage(key, replacement values).
getMessage(...) in the code linked above grabs a String from the localizer and presents it as is (plus behind-the-scenes localization, of course).
formatMessage(...) works in much the same way String.format(...) does. It takes a string from the localizer and replaces temporary values with the arguments provided.
A sample localization file looks like this:
- Code: Select all
inputdialogue.starboundpath = Please locate your Starbound directory:
mod.badarchive = The file "{0}" could not be read correctly. Please see the log for more information.
mainview.addmods = Add {0, plural, one{Mod}other{Mods}}:
To use the first line, just use:
- Code: Select all
getMessage("inputdialogue.starboundpath");
To use the second line, you'll need to use:
- Code: Select all
formatMessage("mod.badarchive", "Example Mod") //Returns "The file "Example Mod" could not be read correctly. Please see the log for more information."
Finally, the third line also uses formatMessage(...), but it instead applies pluralization rules to the text based on the number given.
That would look like:
- Code: Select all
formatMessage("mainview.addmods", 1) //Add Mod:
formatMessage("mainview.addmods", 3) //Add Mods:
I'm sure you're all very bored with the above, but based on simplicity, I'd propose that we use icu4j for localization and I could add in the code to handle that in no time at all. We'd just need someone to go change everything else; I don't have time at the moment.
I'll be happy to be in charge of maintaining this feature, but I would like some help replacing the current code. If no one wants to, I'll get to it in a couple weeks or so—it depends on when I can get my housing situation sorted out.
Last edited by KrazyTheFox on 28 Jul 2014, 18:16, edited 1 time in total.
-
KrazyTheFox - Programmer
- Posts: 725
- Joined: 18 Mar 2014, 23:51
- Has thanked: 66 times
- Been thanked: 226 times
Re: i18n
by krishkrush » 28 Jul 2014, 18:12
Could someone move the posts concerning this topic to this thread? So anyone new to this could follow the topic.
- krishkrush
- Posts: 89
- Joined: 13 Oct 2012, 14:18
- Has thanked: 30 times
- Been thanked: 2 times
Re: i18n
by krishkrush » 28 Jul 2014, 18:23
As far as I understand this (as you already may know, english is not my mother language so i'm having a hard time when it comes to special terms as for example programming language), you have already a program which searches the files which should be localized? I don't get what you wrote in code but would it be possible to view only the text parts which should be translated? Also do i get this right, the program isn't able to be used with forge yet?
Also: Starbound rocks!
Also: Starbound rocks!
- krishkrush
- Posts: 89
- Joined: 13 Oct 2012, 14:18
- Has thanked: 30 times
- Been thanked: 2 times
Re: i18n
by KrazyTheFox » 28 Jul 2014, 18:26
Basically, I'm saying that I already have the code that will allow Forge to be translated (with some small adjustments). I just need to add it to the program. The bigger part to all of this is to find all the English text in the program and replace it with code to get a localized version of the text instead.krishkrush wrote:As far as I understand this (as you already may know, english is not my mother language so i'm having a hard time when it comes to special terms as for example programming language), you have already a program which searches the files which should be localized? I don't get what you wrote in code but would it be possible to view only the text parts which should be translated? Also do i get this right, the program isn't able to be used with forge yet?
Also: Starbound rocks!
Here's what a full language file looks like (but again, we'd need to point to it in Forge): https://github.com/KrazyTheFox/Starbound-Mod-Manager/blob/master/src/main/resources/strings_en_US.properties
The same thing in German: https://github.com/KrazyTheFox/Starbound-Mod-Manager/blob/master/src/main/resources/strings_de_DE.properties
-
KrazyTheFox - Programmer
- Posts: 725
- Joined: 18 Mar 2014, 23:51
- Has thanked: 66 times
- Been thanked: 226 times
Re: i18n
by krishkrush » 28 Jul 2014, 18:30
So if you or someone else would adjust your program for forge, i would only have to translate the red parts of the code as in the example? Or is it more complicated than this?
- krishkrush
- Posts: 89
- Joined: 13 Oct 2012, 14:18
- Has thanked: 30 times
- Been thanked: 2 times
Re: i18n
by KrazyTheFox » 28 Jul 2014, 18:35
Once all the English in Forge is moved from Forge itself into a file, then that's all you'd have to do, yes.krishkrush wrote:So if you or someone else would adjust your program for forge, i would only have to translate the red parts of the code as in the example? Or is it more complicated than this?
-
KrazyTheFox - Programmer
- Posts: 725
- Joined: 18 Mar 2014, 23:51
- Has thanked: 66 times
- Been thanked: 226 times
Re: i18n
by friarsol » 28 Jul 2014, 18:41
Krazy, isn't there design concerns with just flipping words from English to whatever local language? I know German in particular has really long words and switching from English to German could cause overflow of text in many places. I'm not saying this couldn't be done, but I don't think it's as simple as flipping a translation bit. (My real time job ran into the same issue last year when the designed was looking into localization.) Of course this doesn't even count things like languages that read right to left or up-down. I know drdev has a font-reducer that he's been using in a few places to help on the mobile game, but we'd basically need that... everywhere.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: i18n
by krishkrush » 28 Jul 2014, 18:47
Alright. As I am quite sure i cannot help you with searching and changing the code, just tell me when i can start translating. I'm checking this forum almost every day. Thanks again for helping with this endeavor.
@ friarsol
Yes you're right. For example the Song of Ice and Fire books by G. R. R. Martin are each divided into two books in the german edition, hehe. But there are ways to shorten the texts. I would certainly try to avoid abbreviations (the german Elder Scrolls: Oblivion version is an infamous example of this). Maybe someone could find out how much maximum text space there is and i would try to take that into account.
@ friarsol
Yes you're right. For example the Song of Ice and Fire books by G. R. R. Martin are each divided into two books in the german edition, hehe. But there are ways to shorten the texts. I would certainly try to avoid abbreviations (the german Elder Scrolls: Oblivion version is an infamous example of this). Maybe someone could find out how much maximum text space there is and i would try to take that into account.
- krishkrush
- Posts: 89
- Joined: 13 Oct 2012, 14:18
- Has thanked: 30 times
- Been thanked: 2 times
Re: i18n
by KrazyTheFox » 28 Jul 2014, 18:49
There are concerns, absolutely, but the translations themselves can be worked on while I work on the design changes where needed. My plan would be to implement the feature to where it needs to be specifically activated in the launch args, then testing out the UI and stuff can go from there. That way it doesn't affect anything until it's ready to go (would default to English, which is the current behavior).friarsol wrote:Krazy, isn't there design concerns with just flipping words from English to whatever local language? I know German in particular has really long words and switching from English to German could cause overflow of text in many places. I'm not saying this couldn't be done, but I don't think it's as simple as flipping a translation bit. (My real time job ran into the same issue last year when the designed was looking into localization.) Of course this doesn't even count things like languages that read right to left or up-down. I know drdev has a font-reducer that he's been using in a few places to help on the mobile game, but we'd basically need that... everywhere.
Forge is an old program and there will certainly be some issues, but I think they'll be manageable. It pretty much just comes down to UI and I've been getting a lot better at manipulating it. I also built the Starbound Mod Manager to be very flexible in regards to language sizes and quirks, so I have experience there that'd apply here. RTL languages... well, I'll have to think about how to deal with that one.
I have also been considering a UI rewrite to use vector graphics among other things, but that's a huge undertaking that I don't know when I'll have time to do.
Last edited by KrazyTheFox on 28 Jul 2014, 18:55, edited 2 times in total.
-
KrazyTheFox - Programmer
- Posts: 725
- Joined: 18 Mar 2014, 23:51
- Has thanked: 66 times
- Been thanked: 226 times
Re: i18n
by krishkrush » 28 Jul 2014, 18:50
Maybe we could test this first with some examples which i translate (especially the long ones) and you put it into the code. Then we could see what is necessary to make this work.
- krishkrush
- Posts: 89
- Joined: 13 Oct 2012, 14:18
- Has thanked: 30 times
- Been thanked: 2 times
Re: i18n
by drdev » 29 Jul 2014, 03:05
The text being too big is not a concern at all for the mobile game, as I built the text rendering code to always support auto-shrinking to fit. The desktop game could be updated to work similarly with a little work. At any rate, I can handle updating the UI if others handle localizing the code and card files.
- drdev
- Programmer
- Posts: 1958
- Joined: 27 Jul 2013, 02:07
- Has thanked: 189 times
- Been thanked: 565 times
Re: i18n
by KrazyTheFox » 29 Jul 2014, 18:13
Sounds great! I'll see if I can't get that started after the next release.
-
KrazyTheFox - Programmer
- Posts: 725
- Joined: 18 Mar 2014, 23:51
- Has thanked: 66 times
- Been thanked: 226 times
Re: i18n
by friarsol » 29 Jul 2014, 18:21
The resource we use for updating Oracle text (mtg-data.txt) also comes in an xml variety that has a bunch more information (including individual files for a bunch of different languages). We would need to include this data in some fashion (Maybe migrating the XML files into a single language oracle file since XML gets bloated? Or I guess if we're only using one language at a time, separate should work out ok.) Right now the Oracle text is in the card texts as a convenience, but it doesn't necessarily have to be, if we're going to have a language file for Oracle anyway.
- friarsol
- Global Moderator
- Posts: 7593
- Joined: 15 May 2010, 04:20
- Has thanked: 243 times
- Been thanked: 965 times
Re: i18n
by drdev » 30 Jul 2014, 02:17
I think this topic is important enough to be stickied. Can somebody please sticky this thread and move over the relevant conversation from the Forge Android App thread?
Thanks.
-Dan
Thanks.
-Dan
- drdev
- Programmer
- Posts: 1958
- Joined: 27 Jul 2013, 02:07
- Has thanked: 189 times
- Been thanked: 565 times
34 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 35 guests