ReturnVoid
ReturnVoid

Reputation: 1126

Standardised Language conversion?

Is there a standards for language conversion in programming? If this is to broad a question, then specifically for my example:

I've designed a program in c++ & hardcoded English words but I wish to adapt this to accommodate for the display of equivalent words in Italian. I am thinking of using a simple Lang.ini file like so;

English=Language
Do=Fare
Column=Colonna
etc

Load this & and swap out words at run-time. There is nothing web related.

Would there be a better way to do this & any issues I should be mindful of?

Thanks.

EDIT: To clarify: I wish to have the English words that I've used hardcoded in my program automatically converted to whatever language is being used on the users PC.

Upvotes: 0

Views: 147

Answers (2)

fl-web
fl-web

Reputation: 460

It is possible to load resources for language, and save strings in resources. https://msdn.microsoft.com/en-us/library/cc194810.aspx

Usable standart lnaguage macroses:

WORD lang_id = MAKELANGID( primary, sublang )
BYTE primary = PRIMARYLANGID( lang_id )
BYTE sublang = SUBLANGID( lang_id )

Loading resources:

HRSRC hrsrc = FindResourceEx(hMod, RT_ICON, id, langID );
HGLOBAL hglb = LoadResource(hMod, hrsrc);
LPVOID lpsz = LockResource(hglb);

Language initialization code:

static DWORD dwJapanese =
MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT));
// load Japanese resource
SetThreadLocale(dwJapanese, SORT_DEFAULT)

Use LoadString function, possible write wrapper function for convenient using like tihs: http://www.codeproject.com/Tips/86496/Load-a-Windows-string-resource-into-a-std-string-o

Upvotes: 1

Peter
Peter

Reputation: 36597

What you're looking for is described as "internationalization" (or, for those who appreciate a little irony, as "internationalisation"). There is a fair amount of introductory material that may be found using google.

The topic involves more than just translating words. There are also considerations about how numeric values are output, currency is represented, etc etc.

Standard C and C++ support such features. An article (from C/C++ Users Journal) on the topic is http://www.angelikalanger.com/Articles/Cuj/Internationalization/I18N.html

Separately from C++, windows also has its own features that may be used for internationalization of applications. One starting point is https://msdn.microsoft.com/en-au/library/windows/desktop/dd318661%28v=vs.85%29.aspx

Upvotes: 1

Related Questions