Add language option to menu


#1

Could we have an option in the game menu to switch languages?

I dont even remember how I managed to get Frogatto 1.3 to switch to Scottish Gaelic, since the .bat file I used for 1.1 didn’t work. I guess it is working now because I managed to set my system locale to [tt]gd[/tt]. This is too complicated for the average user though. Moreover, many families will have shared computers where not everybody speaks Gaelic, so depending on the locale isn’t really a good choice for them.


#2

We really need to get around to doing this :-
I’m actually messing around with it myself right now, but I don’t really know my C++ stuff; I’ll probably at least be bugging someone about any issues I encounter, unless someone else takes on the job.


#3

Thanks for taking this on :slight_smile:


#4

Well…
More so than I had feared, this is just way beyond my current ability. :expressionless:
So… can someone else work on this?


#5

If we’re low on manpower to do this, I believe that making a build with the “gd” locale hardcoded in src/i18n.cpp:77 wouldn’t be too unreasonable.


#6

This would work nicely as an interim solution so I can get the game out there :slight_smile:


#7

I spent some hours fiddling with it and what I have so far is:

  • a new config file [tt]data/languages.cfg[/tt] that maps ISO codes to native language names
  • a new function in[tt] i18n[/tt] that will get the language name for the current locale
  • a mockup button in the pause game dialog that displays the current language name

Todo:

  • layout improvement

  • get the button to go through the languages when clicking on it

  • fetching the button font for non-latin languages when displaying language names

  • writing the selected locale to [tt]preferences.cfg[/tt]

  • getting the selected locale from [tt]preferences.cfg[/tt]. If empty, write the locale that’s gotten by the currently implemented system

Compiled and tested on Ubuntu virtual machine.


frogatto - changed files.zip (5.7 KB)


#8

Hmm, I think krista had started to work on this; you’ll want to wait for her input.
Having a languages.cfg file holding the translations you can currently select is a good idea; much better than trying to get smart and read the available translation folders, as that’d put very incomplete translations in the list as well.
Here’s the relevant discussion on IRC (#frogatto at irc.freenode.net if you want to join in; if you don’t have an IRC client, use webchat.freenode.net)

[code]<Krista^> [03:44:56] marcavis: can you make me a list of languages we want in the dialog, please.
[03:45:13] Awesome! uh…
<Krista^> [03:46:17] And ideally what code they use.
[03:47:23] Krista^, Fran?ais fr, G?idhlig gd, Deutsch de, Italiano it, Espa?ol es, Portugu?s Brasileiro pt_BR
<Krista^> [03:47:53] Hmmm.
<Krista^> [03:48:32] Ideally we want those all to be translatable strings
<Krista^> [03:48:52] I.think
[03:49:25] Actually we don’t - they’re for the benefit of the foreign players, so they want to be able to recognize their language name at all times;
<Krista^> [03:49:51] Anyway I’m going to stick them all in a .cfg file we load in.
[03:50:12] say, I shouldn’t get into a state where I’ve clicked Russian (not yet 100%, so don’t add it yet) and we can’t find our language anymore at a glance
<Krista^> [03:50:45] Okay. Point taken.
<Krista^> [03:51:27] Anyway it’ll be easier to manage in a .cfg file we load.
[03:51:44] Oh yeah, that sounds good
<Krista^> [03:54:22] We could just enumerate directories, but we may want to be more selective for incomplete translations
[03:56:41] Oh yes, we really will be. I had seen a german let’s play once… It was version 1.1.1 I think. The text was like half-german, that was pretty disheartening.
<Krista^> [03:59:34] The most technical challenge is working out how to render multiple graphical fonts.
[04:01:08] Hmm, that does sound tricky… None of these languages happen to use a different font, but yeah, soon that issue will pop up
[04:02:17] Jetrel: Cute grumpy mushroom.
[04:02:49] DDR: gotta make his cap-throw animation and projectile later, and he’s ready to go.
[04:03:05] … a fungal Oddjob.
[04:03:44] Jetrel, bonus points if it has a head with balding spots under the cap…? xD Hmm, dunno.
[04:04:28] Probably weird and uncanny.
[04:04:40] hehehe
[04:18:48] Chinese and Japanese are the only languages that use different graphical fonts right?
[04:19:22] hm, there’s cyrillic
[04:19:36] it’s in the same font, though.

  • Sirp_ [04:19:50] personally thinks it’d be okay to name all languages in English and trust that people know enough English to select their language
    [04:19:51] but I’ll be making greek in a new font
    [04:19:54] hmm
    <Sirp_> [04:19:56] I mean it’s not an ideal solution but I think good enough
    [04:20:43] Well, I suppose we could use that, with some flag icons for good measure
    [04:21:20] That ideal solution in using every language’s name in that language I stole from Allacrost, which uses TTF fonts
    [04:21:37] you could use names in their own languages except for Chinese/Japanese; you could also include just the glyphs for words “Chinese” and “Japanese” in their own languages into the default font
    <Sirp_> [04:21:56] flag icons would be even better
    [04:22:39] hagabaka, Yeah, that too. Even with several languages, it wouldn’t be too bad. Just copying over some characters among several fontsheets, easy enough.
    [04:22:52] using language names in their own languages seems pretty standard on the web, although if someone doesn’t understand English, they wouldn’t know to click on the “language” menu either
    [04:24:13] Heh. Touch?. To protect against that, the language selection would have to be the first screen the player sees
    [04:24:35] Which does tend to be the case for some european releases of console games, etc.
    [04:24:38] Which it actually is on e.g. OS X.
    [04:25:14] Here, though - we’re protected by the “default to the OS language” intelligence.
    [04:25:22] Ohh yes
    [04:25:54] is there a good flag for every language included? for example Scottish Gaelic?
    [04:26:12] There is for that
    [04:26:31] The scottish flag is one of the components of the “UK” flag, albeit color changed.
    [04:27:03] IIRC… The scottish flag is a white flag with a blue X. The english flag is a white flag with a red cross.
    [04:27:37] yeah… even if only a minority in scotland speaks gaelic, its flag would work for that
    [04:27:38] WITH THEIR POWERS COMBINED, I AM CA… etc…
    [04:28:05] QUEEN VICTORIA!!
    [04:28:06] waitwhat
    [04:29:35] It’s not really a problem, either way; every speaker of gaelic is also an english speaker.
    [04:29:50] Jetrel: blue flag
    [04:29:51] white x
    [04:30:02] prophile: ahha
    [04:30:27] maybe you can just add buttons with only flag icons to the pause dialog then?
    [04:30:46] hagabaka, that works too
    [04:31:23] A common iconization for “pick language” is the UN flag.
    [04:31:58] Which mind offend the few space rangers who hate the UN, but …
    [04:32:38] (which include my grandfather who things the UN is a vast conspiracy to install a one-world government)
    [04:33:36] delicious NWO
    [04:36:47] IKR?
    [04:38:07] my brain is broken
    [04:38:14] i feel a need for breakfast
    [04:38:27] despite having approached it from the wrong direction
    <Sirp_> [04:44:03] marcavis: so I think the best thing is to just do something real KISS
    <Sirp_> [04:44:05] we can improve it later
    <Sirp_> [04:44:10] just straight text languages
    <Sirp_> [04:44:17] then later we can do flags, perhaps internationalize each line etc
    [04:46:28] Sirp, Yeah… given that Jetrel pointed out that we should still default to the user’s OS locale, anything we do will be at least decent enough[/code]

#9

Thanks!

I’ll stop fiddling until I hear back. I don’t have a lot of time, so if somebody else is taking this on, brilliant! In any case, I have learned a bit of C++ :stuck_out_tongue:

If you wish to use part of my code, I have commented all the lines I have touched with “language selection.”

My take on the flag idea:

Yes, the Scottish Flag is blue with a white St. Andrew’s cross. There is one problem with the flag idea though: Most countries are multilingual! E.g. How would you separate Canadian French from Canadian English or Scottish Gaelic from Scots? Also, do all First Nations have their own flag? I think this would be really messy in African countries as well, should we one day attract African localizers.

So, I think using the operating system’s locale until a language is manually selected should do the trick :slight_smile:


#10

Recently hagabaka has added a Language… dialog, we should be good to go in time for 1.3.


#11

Great news, thanks!


#12

Thank you for the code you posted GunChleoc. It gave me an idea of where to start, and I used your languages.cfg file.


#13

Glad I could help, expecially being C++ illiterate :smiley:


#14

I’ve seen from the new strings in Transifex that you’re working on this, thank you! :smiley:

Do you plan to have this available for 1.3 when it’s done? This would relly make my day :wink:


#15

Ahh, yes! This was also committed to the 1.3 branch.


#16

does a happy dance


#17

Did you also implement a language menu for the mobile versions, e.g. for iPhone? I can’t test this myself, because my phone doesn’t have enough memory. I’m asking because we might have a locale problem again. On the iPhone they probably don’t even allow people to set their locale to a minority language.