473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Name of user's language, in English

Does C++ have a method of retrieving this?

When launching my app, I want to select the appropriate language
for ts GUI, based on the user's language setting.

The frameworks wxWidgets and OpenOffice UNO have this
functionality but the wxWidgets code is a mess of platform
specific #ifdef sections. I wonder i there is a standard compliant
way.

The locale functions help formatting numbers and currency but
they don't tell the language name AFAICanSee.

I looked in the Boost docs but didn't find it there.
Jul 1 '08 #1
6 2065
"Ole Nielsby" <ol*********@tekareyouspamminglogisk.dkwrote:
>
Does C++ have a method of retrieving this?

When launching my app, I want to select the appropriate language
for ts GUI, based on the user's language setting.
What is ts ?
The frameworks wxWidgets and OpenOffice UNO have this
functionality but the wxWidgets code is a mess of platform
specific #ifdef sections. I wonder i there is a standard compliant way.
What do you mean by such a statement?
What is wxWidgets?
Since when has it become part of the language in discussion here (C++) ?
The locale functions help formatting numbers and currency but
they don't tell the language name AFAICanSee.

I looked in the Boost docs but didn't find it there.
And you are really a programmer? What language?

Jul 1 '08 #2
"Ole Nielsby" <ol*********@tekareyouspamminglogisk.dkwrites:
Does C++ have a method of retrieving this?
No. This is not a programming language question.

It would depend on the Operating System, and/or on the user interface
toolkit.
When launching my app, I want to select the appropriate language
for ts GUI, based on the user's language setting.

The frameworks wxWidgets and OpenOffice UNO have this
functionality but the wxWidgets code is a mess of platform
specific #ifdef sections. I wonder i there is a standard compliant
way.

The locale functions help formatting numbers and currency but
they don't tell the language name AFAICanSee.

I looked in the Boost docs but didn't find it there.
On unix systems, man 7 locale should give you enough information.
Namely, the unix user sets its language by setting environment
variables such as LANG, LANGUAGE, LC_ALL, LC_CTYPE, LC_COLLATE, etc.

Of course, naive users cannot understand what an environment variable
is, so GUI environments have their own way to do it. Read the
documentation.

If wxWidgets is a mess, I could advise you to use a better
environment, such as GNUstep.

In anycase, these it's iso639 language codes that must be put in these
environment variables, so if you want the name in English, you will
have to map it yourself.

This can be done with a std::map<std::string,std::stringiso636ToEnglishNam es;
that you fill explicitely:

struct{ const char* englishName,
const char* code,
const char* family } iso636ToEnglishNamesData[]={
{"AYMARA","AY","AMERINDIAN"},
{"GUARANI","GN","AMERINDIAN"},
{"QUECHUA","QU","AMERINDIAN"},
{"BHUTANI","DZ","ASIAN"},
{"BURMESE","MY","ASIAN"},
{"CAMBODIAN","KM","ASIAN"},
{"CHINESE","ZH","ASIAN"},
{"JAPANESE","JA","ASIAN"},
{"KOREAN","KO","ASIAN"},
{"LAOTHIAN","LO","ASIAN"},
{"THAI","TH","ASIAN"},
{"TIBETAN","BO","ASIAN"},
{"VIETNAMESE","VI","ASIAN"},
{"LATVIAN","LV","BALTIC"},
{"LITHUANIAN","LT","BALTIC"},
{"BASQUE","EU","BASQUE"},
{"BRETON","BR","CELTIC"},
{"IRISH","GA","CELTIC"},
{"SCOTS-GAELIC","GD","CELTIC"},
{"WELSH","CY","CELTIC"},
{"KANNADA","KN","DRAVIDIAN"},
{"MALAYALAM","ML","DRAVIDIAN"},
{"TAMIL","TA","DRAVIDIAN"},
{"TELUGU","TE","DRAVIDIAN"},
{"GREENLANDIC","KL","ESKIMO"},
{"INUPIAK","IK","ESKIMO"},
{"ESTONIAN","ET","FINNO-UGRIC"},
{"FINNISH","FI","FINNO-UGRIC"},
{"HUNGARIAN","HU","FINNO-UGRIC"},
{"AFRIKAANS","AF","GERMANIC"},
{"DANISH","DA","GERMANIC"},
{"DUTCH","NL","GERMANIC"},
{"ENGLISH","EN","GERMANIC"},
{"FAROESE","FO","GERMANIC"},
{"FRISIAN","FY","GERMANIC"},
{"GERMAN","DE","GERMANIC"},
{"ICELANDIC","IS","GERMANIC"},
{"NORWEGIAN","NO","GERMANIC"},
{"SWEDISH","SV","GERMANIC"},
{"YIDDISH","YI","GERMANIC"},
{"AFAN","OM","HAMITIC"},
{"AFAR","AA","HAMITIC"},
{"SOMALI","SO","HAMITIC"},
{"ABKHAZIAN","AB","IBERO-CAUCASIAN"},
{"GEORGIAN","KA","IBERO-CAUCASIAN"},
{"ASSAMESE","AS","INDIAN"},
{"BENGALI","BN","INDIAN"},
{"BIHARI","BH","INDIAN"},
{"GUJARATI","GU","INDIAN"},
{"HINDI","HI","INDIAN"},
{"KASHMIRI","KS","INDIAN"},
{"MARATHI","MR","INDIAN"},
{"NEPALI","NE","INDIAN"},
{"ORIYA","OR","INDIAN"},
{"PUNJABI","PA","INDIAN"},
{"SANSKRIT","SA","INDIAN"},
{"SINDHI","SD","INDIAN"},
{"SINGHALESE","SI","INDIAN"},
{"URDU","UR","INDIAN"},
{"ALBANIAN","SQ","INDO-EUROPEAN/OTHER"},
{"ARMENIAN","HY","INDO-EUROPEAN/OTHER"},
{"ESPERANTO","EO","INTERNATIONAL"},
{"INTERLINGUA","IA","INTERNATIONAL"},
{"INTERLINGUE","IE","INTERNATIONAL"},
{"VOLAPUK","VO","INTERNATIONAL"},
{"KURDISH","KU","IRANIAN"},
{"PASHTO","PS","IRANIAN"},
{"PERSIAN","FA","IRANIAN"},
{"TAJIK","TG","IRANIAN"},
{"GREEK","EL","LATIN/GREEK"},
{"LATIN","LA","LATIN/GREEK"},
{"HAUSA","HA","NEGRO-AFRICAN"},
{"KINYARWANDA","RW","NEGRO-AFRICAN"},
{"KURUNDI","RN","NEGRO-AFRICAN"},
{"LINGALA","LN","NEGRO-AFRICAN"},
{"SANGHO","SG","NEGRO-AFRICAN"},
{"SESOTHO","ST","NEGRO-AFRICAN"},
{"SETSWANA","TN","NEGRO-AFRICAN"},
{"SHONA","SN","NEGRO-AFRICAN"},
{"SISWATI","SS","NEGRO-AFRICAN"},
{"SWAHILI","SW","NEGRO-AFRICAN"},
{"TSONGA","TS","NEGRO-AFRICAN"},
{"TWI","TW","NEGRO-AFRICAN"},
{"WOLOF","WO","NEGRO-AFRICAN"},
{"XHOSA","XH","NEGRO-AFRICAN"},
{"YORUBA","YO","NEGRO-AFRICAN"},
{"ZULU","ZU","NEGRO-AFRICAN"},
{"FIJI","FJ","OCEANIC/INDONESIAN"},
{"INDONESIAN","ID","OCEANIC/INDONESIAN"},
{"JAVANESE","JV","OCEANIC/INDONESIAN"},
{"MALAGASY","MG","OCEANIC/INDONESIAN"},
{"MALAY","MS","OCEANIC/INDONESIAN"},
{"MAORI","MI","OCEANIC/INDONESIAN"},
{"SAMOAN","SM","OCEANIC/INDONESIAN"},
{"SUNDANESE","SU","OCEANIC/INDONESIAN"},
{"TAGALOG","TL","OCEANIC/INDONESIAN"},
{"TONGA","TO","OCEANIC/INDONESIAN"},
{"CATALAN","CA","ROMANCE"},
{"CORSICAN","CO","ROMANCE"},
{"FRENCH","FR","ROMANCE"},
{"GALICIAN","GL","ROMANCE"},
{"ITALIAN","IT","ROMANCE"},
{"MOLDAVIAN","MO","ROMANCE"},
{"OCCITAN","OC","ROMANCE"},
{"PORTUGUESE","PT","ROMANCE"},
{"RHAETO-ROMANCE","RM","ROMANCE"},
{"ROMANIAN","RO","ROMANCE"},
{"SPANISH","ES","ROMANCE"},
{"AMHARIC","AM","SEMITIC"},
{"ARABIC","AR","SEMITIC"},
{"HEBREW","HE","SEMITIC"},
{"MALTESE","MT","SEMITIC"},
{"TIGRINYA","TI","SEMITIC"},
{"BULGARIAN","BG","SLAVIC"},
{"BYELORUSSIAN","BE","SLAVIC"},
{"CROATIAN","HR","SLAVIC"},
{"CZECH","CS","SLAVIC"},
{"MACEDONIAN","MK","SLAVIC"},
{"POLISH","PL","SLAVIC"},
{"RUSSIAN","RU","SLAVIC"},
{"SERBIAN","SR","SLAVIC"},
{"SERBO-CROATIAN","SH","SLAVIC"},
{"SLOVAK","SK","SLAVIC"},
{"SLOVENIAN","SL","SLAVIC"},
{"UKRAINIAN","UK","SLAVIC"},
{"AZERBAIJANI","AZ","TURKIC/ALTAIC"},
{"BASHKIR","BA","TURKIC/ALTAIC"},
{"KAZAKH","KK","TURKIC/ALTAIC"},
{"KIRGHIZ","KY","TURKIC/ALTAIC"},
{"TATAR","TT","TURKIC/ALTAIC"},
{"TURKISH","TR","TURKIC/ALTAIC"},
{"TURKMEN","TK","TURKIC/ALTAIC"},
{"UZBEK","UZ","TURKIC/ALTAIC"},
{"BISLAMA","BI","MISCELLANEOUS"},
{"MONGOLIAN","MN","MISCELLANEOUS"},
{"NAURU","NA","MISCELLANEOUS"},
};

std::map<std::string,std::stringiso636ToEnglishNam es;
for(i=0;i<sizeof(iso636ToEnglishNamesData)/sizeof(iso636ToEnglishNamesData[0]);i++){
iso636ToEnglishNames[iso636ToEnglishNamesData[i].code]=iso636ToEnglishNamesData[i].name;
}

So you can get the English name of the user selected language with something like:

iso636ToEnglishNames[toUpperCase(extractLanguage(getenv("LANG")))];

Note, you can get an uptodate list from
http://www.loc.gov/standards/iso639-2/langhome.html

--
__Pascal Bourguignon__
Jul 1 '08 #3
On Jul 1, 11:09 am, "Ole Nielsby"
<ole.niel...@tekareyouspamminglogisk.dkwrote:
Does C++ have a method of retrieving this?
Retrieving what? What does the name of user's language mean?
What if there are a lot of users, with different languages?
(That's the case for most of my programs.)
When launching my app, I want to select the appropriate
language for ts GUI, based on the user's language setting.
Like most things which concern the GUI, it's implementation
dependent. Most likely, the GUI framework itself has something.
The frameworks wxWidgets and OpenOffice UNO have this
functionality but the wxWidgets code is a mess of platform
specific #ifdef sections. I wonder i there is a standard
compliant way.
Not really. You can do something like:
std::locale( "" ).name()
which should give you the name of the locale specific native
environment, whatever that means. (I'm pretty sure that the
intent is to give the login user's locale.) But I'm not sure
that's not necessarily much help, when it works, and with g++,
all it does is core dump anyway, at least under Solaris.
(Locale names aren't standardized.)
The locale functions help formatting numbers and currency but
they don't tell the language name AFAICanSee.
They're supposed to allow you to get locale dependent messages,
so if you use them to get the text you want to display, they
should work. In theory. You still have to figure out how to
install your messages (and their translations) as part of the
corresponding locales for each system. And from experience, I
wouldn't count on it working anyway.
I looked in the Boost docs but didn't find it there.
I don't think that Boost has much which concerns locales.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jul 1 '08 #4
On Jul 1, 2:21 am, "Adem24" <ade...@adem24adem24.org.invalidwrote:
"Ole Nielsby" <ole.niel...@tekareyouspamminglogisk.dkwrote:
Does C++ have a method of retrieving this?
When launching my app, I want to select the appropriate language
for ts GUI, based on the user's language setting.

What is ts ?
Irrelevant.
The frameworks wxWidgets and OpenOffice UNO have this
functionality but the wxWidgets code is a mess of platform
specific #ifdef sections. I wonder i there is a standard compliant way.

What do you mean by such a statement?
The OP is giving examples of some functionality and seeking it's
equivalent in standard C++.
What is wxWidgets?
A framework used as an example.
Since when has it become part of the language in discussion here (C++) ?
It is not a part of C++. It may have something to do with the part of
"such a statement" above that you admit did not understand.
The locale functions help formatting numbers and currency but
they don't tell the language name AFAICanSee.
I looked in the Boost docs but didn't find it there.

And you are really a programmer? What language?
Boost is a collection of C++ libraries:

boost.org

By the way, I have a feeling that missed the point of your post; if
there was one that is...

Ali
Jul 1 '08 #5
Pascal J. Bourguignon <pj*@informatimago.comwrote:
>
In anycase, these it's iso639 language codes
James Kanze <ja*********@gmail.comwrote:
You can do something like:
std::locale( "" ).name()
But [...] with g++, all it does is core dump anyway, at
least under Solaris.
Thanks for these hints. It seems I'll have to do without it.

(But I really think it belongs in a standard - perhaps in the
Boost locale library. It may be technically ill-defined by the
present state of things, but to the user, it's very well-defined.)
Jul 3 '08 #6
On Jul 3, 1:14 pm, "Ole Nielsby"
<ole.niel...@tekareyouspamminglogisk.dkwrote:
Pascal J. Bourguignon <p...@informatimago.comwrote:
In anycase, these it's iso639 language codes
James Kanze <james.ka...@gmail.comwrote:
You can do something like:
std::locale( "" ).name()
But [...] with g++, all it does is core dump anyway, at
least under Solaris.
Thanks for these hints. It seems I'll have to do without it.
(But I really think it belongs in a standard - perhaps in the
Boost locale library. It may be technically ill-defined by the
present state of things, but to the user, it's very
well-defined.)
Is it? What's my "language", when I'm a user? On my Windows
machine at home, Windows itself displays the messages in French,
but the US keyboard driver is usually active, and different
programs display in different languages, depending on what I'm
doing at the moment. On the Unix machines, my LC_ variables are
mixed, and also depend on the system (since different systems
have different installed locales). What's my son's language,
when he's playing an online game with some of the participants
in Paris, and others in Frankfurt?

And of course, that C++ doesn't control everything; typically,
the information simply isn't available for the C++ library to
provide.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jul 4 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jc | last post by:
Hi, I want to build a xml translation map as the following <A english sentence, with punctuations such as "?">translation of this sentence in some language in utf8 </A english sentence, with...
18
by: OrenFlekser | last post by:
Hi I've posted this message couple of days ago, but I can't find it now, so sorry if you see it twice... Anyways - I have a text box, and I want my users to be able to write only in english...
2
by: Giovane Calabrese | last post by:
( aspx + vb ) hi everyone ! I really need make that function work ! im brazilian , and i want to make a multilanguage system , that function above must look at all ASPX take the labels ID and...
0
by: Giovane Calabrese | last post by:
ok. im try to make a multilanguage system based on that tutorial : http://www.123aspx.com/redir.aspx?res=29112 in my aspx pages all text are in labels , and i want to take the name labels...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
12
by: lucky | last post by:
hi guys, right now i'm going through System.Globalization Namespace. and i found very intersting class there called CultureInfo. i was trying to get cultureInfo on the basis of name but i didnt...
1
by: mouton | last post by:
Hello, I am a beginner. My website has 2 pages: one in English and one in French. I would like non English people to be directed to the English page. There I would like to display a...
6
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I would like to ask how can I with C# find out the service name on non-English Windows OS. Thanks, Lubomir
3
by: Greg | last post by:
Lately I have been Customizing C commands into another language (Shona) to facilitate easier learning of C by Shona speaking people using pre-processor directives i.e. (#include define) is there...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.