Is there any library or way to get system's current language code?
For example, if system uses some English variant, it would return "en" or "uk" if system in Ukrainian.
I know that there several codes standards and almost all OSs uses different one, but something unified and cross-platform would be fine by me.
Get system language locale?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Get system language locale?
This might help viewtopic.php?p=212987#p212987
Re: Get system language locale?
Well, it kinda helps and not. Flatpak love it returns just "C" which is not really helpful information, and, apparently, on different OSs it will return different locale standards (which is not good) and also I somehow need to parse everything that this function might return.
Re: Get system language locale?
Ah yeah I hadn't run it until just now as I was on my phone. It returns "C" on my machine as well, that's a bit naff. You could always go with the other suggestion in that post and just allow the user to select their language manually, which is also a slightly mucky compromise. :\
- BrotSagtMist
- Party member
- Posts: 665
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Get system language locale?
You can use getenv instead
But honestly this makes no sense, what information do you even want to obtain?
Cause there is no such thing as a set language.
We have timezone, time format, keyboard, spell check and so on, and noone of them have to even match.
I mean my timezone is german, my language is english and my keyboard is of the charts.
But honestly this makes no sense, what information do you even want to obtain?
Cause there is no such thing as a set language.
We have timezone, time format, keyboard, spell check and so on, and noone of them have to even match.
I mean my timezone is german, my language is english and my keyboard is of the charts.
obey
Re: Get system language locale?
Yes, I can and would, probably, do that in futuremarclurr wrote: ↑Sat Aug 19, 2023 7:48 pm Ah yeah I hadn't run it until just now as I was on my phone. It returns "C" on my machine as well, that's a bit naff. You could always go with the other suggestion in that post and just allow the user to select their language manually, which is also a slightly mucky compromise. :\
Well, I would pick language in-game (if game supports one) based on that information. (Even if I would use suggestion from link about "choose your language on 1st run", I still want to highlight language option that match system language.) While some people definitely doesn't want to use/pick language in-game that based on system language, majority will, so this small feature is definitely handy.BrotSagtMist wrote: ↑Sat Aug 19, 2023 8:12 pm You can use getenv instead
But honestly this makes no sense, what information do you even want to obtain?
Cause there is no such thing as a set language.
We have timezone, time format, keyboard, spell check and so on, and noone of them have to even match.
I mean my timezone is german, my language is english and my keyboard is of the charts.
For example, in Godot, there exists and fully works such system. No matter on which system you run game, Godot will convert that information to same standard (like en_US or uk_UA), which is definitely handy to have.
Considering that engines such as Unity or Godot can provide such information, or even some software frameworks/tools such as GTK or Qt and do that in cross-platform manner, I think this is definitely possible.Cause there is no such thing as a set language.
Yes, but this would require me to parse and process this information on different OSs that do that in different manner (for example, linux returns data in "uk_UA" manner, while windows use different ISO, macOS probably too, and maybe even android) and then convert all of this to 1 standard which I would later use in-game (because if in-game I would identify "en_US" and windows would return something in windows specific format "KZ-1048", then it's not going to work). I don't think I have required knowledge to do so, nor do power to maintain this thing. Because such feature should be done in scope of some library rather then game code hack.You can use getenv instead
- BrotSagtMist
- Party member
- Posts: 665
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Get system language locale?
But again, Language of what?
What actually is the output of unity and godot based on?
If i print my system environment i get a whooping 11 results, i can only identify 3 as useful.
The system language, the spellcheck, the date.
My system is en_US, my spellcheck is en_GB and my date is de_DE.
So which language you want to give me?
What actually is the output of unity and godot based on?
If i print my system environment i get a whooping 11 results, i can only identify 3 as useful.
The system language, the spellcheck, the date.
My system is en_US, my spellcheck is en_GB and my date is de_DE.
So which language you want to give me?
obey
Re: Get system language locale?
Your system language? Why should it something else?BrotSagtMist wrote: ↑Sun Aug 20, 2023 11:29 am But again, Language of what?
What actually is the output of unity and godot based on?
If i print my system environment i get a whooping 11 results, i can only identify 3 as useful.
The system language, the spellcheck, the date.
My system is en_US, my spellcheck is en_GB and my date is de_DE.
So which language you want to give me?
- slime
- Solid Snayke
- Posts: 3172
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Get system language locale?
love 12 has a love.system.getPreferredLocales function.
However, if your game is on Steam you should use Steam's APIs instead. They let users choose a per-game preferred locale inside Steam that's separate from OS settings.
However, if your game is on Steam you should use Steam's APIs instead. They let users choose a per-game preferred locale inside Steam that's separate from OS settings.
- BrotSagtMist
- Party member
- Posts: 665
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Get system language locale?
Yee i forgot what my chain of thought was leading to.
There was something, but i havent slept in like 30 hours and it takes its toll.
There was something, but i havent slept in like 30 hours and it takes its toll.
obey
Who is online
Users browsing this forum: Bing [Bot] and 5 guests