Inverted translation to get sourceText from translated string
I have a String based paramer handling class that associates strings with values. The parameters are stored in a plain text file and read by the program at startup.
Strings are in English, this was quite good. Now i have a customer who wants to store the parameters in his own language.
I would like to do this with the normal tr(..) approach, so its no problem to store the english parameters in customers language.
But how to get back?
How can i invert the translation to get back to my original source text?
Can i overload QTranslator and do a inverse match?
Or am i forced to write my own Translator which stores translations e.g. as SQLITE and search the database on "inverted" translation.
Any help appreciated. Thanks
Seems like tr() is more of a one way due to hashing (ELF). That makes lookups very fast, but basically not invertable.
However I don't quite see your problem. When you want to access the foreign language keys, why not use the tr there, too, e.g.:
int value = parameterParser.getValueOfKey(tr("My Key"));
If nothing helps: Tell your customer to learn english ffs, it's the world language. ;)
I thank for your hint, you are right the the tr mechanism should work this way. I didn't see this in my yesterdays brainstorming :-). This should also help me when i get the foreign files and have to read into my english version. In this case i just must use the right translator for the parameter files.