Getting the current ISO-639 and ISO-3166 locales
Cameron Cawley (3514) 158 posts |
I’d like to be able to add an implementation of SDL_GetPreferredLocales on RISC OS. Is there an easy way to look up the ISO-639 and ISO-3166 language and country codes for the active territory? |
Chris Mahoney (1684) 2165 posts |
Is there even a way to set your country under the current Territory system? Note that the *Country command actually sets the keyboard layout, so mine’s set to USA despite being in New Zealand. |
Sprow (202) 1158 posts |
The country code can be mapped via service International 9 (RISC OS 5, circa 2012 onwards). I think to make a language code you’ll have to write something yourself or have a big internal lookup table.
Compare and contrast
|
Steffen Huber (91) 1953 posts |
I hate to say it, but until we have a meaningful i18n/l10n system for RISC OS beyond the braindead Territory system, I would recommend just returning a hardcoded enGB, which will be right in around 99.73% of cases anyway. |
Cameron Cawley (3514) 158 posts |
Coming back to this, I’ve put together some proof of concept code to get the current locale info in a format that SDL expects: https://gist.github.com/ccawley2011/f63e882aa1cac6e799e3f886236b9140 The code is able to compile independently of SDL, and has been tested on RISC OS 3.7 and RISC OS 5 with the UK territory. I haven’t fleshed out the language mapping table properly though, since it’s not clear what language is represented by a given territory number, so it may not return sensible language values for other territories. If anyone using RISC OS with a territory other than UK, I’d appreciate it if you could try building and running the test program and reporting what it returns, in addition to what it should be returning. |