Any advances in the SDL locale API? |
Any advances in the SDL locale API? |
Sam Lantinga
|
As far as I know this hasn't been implemented.
On Thu, Jul 10, 2014 at 5:02 AM, Ardillas del Monte wrote:
|
|||||||||||||
|
Any advances in the SDL locale API? |
Ryan C. Gordon
Guest
|
On 7/10/14, 8:02 AM, Ardillas del Monte wrote:
This stalled out, but it's still something I'd like to get into SDL. I actually needed this API for two separate games recently, so I'll probably revisit this soon. --ryan. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Any advances in the SDL locale API? |
slvn
|
Hi,
I have some code to obtain the current language for a few architectures (IOS, Win8, Android). And it seems to me it works correctly, so I will share it. This ticket already exist. https://bugzilla.libsdl.org/show_bug.cgi?id=2131 And I attached my code there ... Cheers, Sylvain On Mon, Jul 14, 2014 at 3:57 AM, Ryan C. Gordon wrote:
-- Sylvain Becker _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
Any advances in the SDL locale API? |
Ardillas del Monte
Guest
|
Thanks a lot, Sylvain.
Btw, regarding Android, I don't fully understand your code. I suppose you propose two options, but, are they better than the original code submitted by Julien? ardi On Tue, Jul 15, 2014 at 9:10 PM, Sylvain Becker wrote:
|
|||||||||||||||||
|
Any advances in the SDL locale API? |
slvn
|
This is not a patch, only part of code to retrieve to locale on Android/Ios/Win
Don't put to much attention to the jni part as there are a few macros not defined, and this is different than what should be done for sdl code (this should be understandable anyway). I think this is equivalent to what Julien propose. Maybe, the Java part is slighly different : getContext().getResources().getConfiguration().locale.toString(); and String lang = new String(Locale.getDefault().getLanguage()); if (Locale.getDefault().getCountry().length() > 0) { lang = lang + "_" + Locale.getDefault().getCountry(); } ( The autor of this code is probably Pelya (https://github.com/pelya/commandergenius/blob/sdl_android/project/java/Settings.java#L604) ) On Wed, Jul 16, 2014 at 2:31 PM, Ardillas del Monte wrote:
-- Sylvain Becker _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||||
|
Any advances in the SDL locale API? |
Gabriele Greco
Guest
|
In my game I did it without having a java bridge in full native code: const char *get_lang_id() { Â Â AConfiguration *cfg = AConfiguration_new(); Â Â AConfiguration_fromAssetManager(cfg, asset_mgr); Â Â static char language[4]; Â Â memset(language, 0, sizeof(language)); Â Â AConfiguration_getLanguage(cfg, language); Â Â AConfiguration_delete(cfg); Â Â if (*language) return language; Â Â return NULL; } The only thing you need to do this is a pointer to the asset manager. The values returned in "language" are strings like "it", "de", "fr".... You can get the exact same result on iOS with this: const char *get_lang_id() { Â Â NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; Â Â return [language UTF8String]; } -- Bye, Â Gabry |
|||||||||||||
|
Any advances in the SDL locale API? |
slvn
|
I have updated the Ryan's patch SDL_PreferredLocales to fit the trunk,
and I also added the parts : - Android : with the "AConfiguration" choice, but that may be an error because it also requires a JNI to get the assetMgr. so it's increasing the scope of dependencies. - WinRT/WindowPhones : code working, but not tested in SDL. - some code I was using : to convert a locale to an enum/language. I believe this is more convenient to handle translations, but feel free to modify it ! https://bugzilla.libsdl.org/show_bug.cgi?id=2131 Cheers, Sylvain On Thu, Jul 17, 2014 at 4:05 PM, Gabriele Greco wrote:
-- Sylvain Becker _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
Any advances in the SDL locale API? |
Sik
|
2014-07-25 13:00 GMT-03:00, Sylvain Becker:
I believe we have agreed long ago that returning a language string was better than a language number (especially since it's likely you'll end up using a string anyway). Any comments on this? _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Any advances in the SDL locale API? |
Daniel Bünzli
Guest
|
Le vendredi, 25 juillet 2014 à 21:12, Sik the hedgehog a écrit :
I agree an enum is useless here, best would be to return BCP 47 language identifiers [1,2], nowadays it is the standard (and precise) way for specifying languages. Best, Daniel [1] http://en.wikipedia.org/wiki/IETF_language_tag [2] http://www.rfc-editor.org/rfc/bcp/bcp47.txt _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Any advances in the SDL locale API? |
slvn
|
Sorry for the confusion, SDL_GetPreferedLocales() is still using
string like the initial code. I refreshed the patch, and added android / winrt. This is an attempt not to see this patch lost for the next 6 months. In addition, I put some code to convert a locale to an enum. I believe that essentially the only use-able thing. but feel free to discard / adapt it. (as you can guess, I don't even need this patch myself). On Fri, Jul 25, 2014 at 10:12 PM, Sik the hedgehog wrote:
-- Sylvain Becker _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
Any advances in the SDL locale API? |
Robotic-Brain
Guest
|
Am 25.07.2014 22:12, schrieb Sik the hedgehog:
Enums are completely useless for languages, since there are just so many of them. In your code you don't care what the actual language is anyways and just load the appropriate lang-file. Plus you would need a recompiled version of SDL every time the set of "supported" languages changes. This is just ridiculous for a middle-ware library, that doesn't even display/handle text. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Any advances in the SDL locale API? |
Ryan C. Gordon
Guest
|
We'll likely apply some version of this right after 2.0.4 ships (unless Sam says he wants it for 2.0.4). --ryan. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: Any advances in the SDL locale API? |
ollika
|
What is the status on this? Thanks. |
|||||||||||||
|