[SOLVED]Localizing resources
-
Hello guys
First of all, sorry for this stupid question :)
I'm storing some text files in embedded resource file which I want to localize. Is there any way to load the text file which targets currently selected language in the application? What's the best practice for localizing resources. I'm aware of the tr() function, but I want to avoid hardcoding those texts in the application.
I tried searching the net but couldn't find anything helpful :(
Thanks
-
You can get locale by invoking:
@QLocale::system().name(); // Returns QString with locale name@Then just use it to load particular file from QRC.
-
Is this the best approach? I mean, in .NET, you could just append locale name to the resource (e.g. MyResource.resx, MyResource.ru-RU.resx etc) and the framework automatically recognizes which resource to load by current locale. I thought maybe there is such way in Qt too?
-
have a look at the "arrow pads example":http://doc.qt.nokia.com/4.7/linguist-arrowpad.html.
-
There is one, yes, but when you use tr() macro (it's fun, by the way, try it! And locales are stored as separate files). I am not sure it can be used for QRC (which can hold any files, including pictures). I don't know whether it's the best way, just first one that popped into my mind.