Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Inverted translation to get sourceText from translated string
Forum Updated to NodeBB v4.3 + New Features

Inverted translation to get sourceText from translated string

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    j.kreuzberger
    wrote on last edited by
    #1

    Hi!

    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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      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. ;)

      1 Reply Last reply
      0
      • J Offline
        J Offline
        j.kreuzberger
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved