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. How to use multiple locale at the same time?

How to use multiple locale at the same time?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • S Offline
    S Offline
    SaiyanRiku
    wrote on last edited by
    #1

    Hi,

    I'm developing an HTTP server with Qt! I have internationalized my application and i know how to switch the locale of the complete application.

    I would like each client of the web interface can select his desired language. So each client session can have a different locale.

    One ugly solution i found should be to use mutex around each string to translate:
    @
    lock()
    setLocale()
    tr("the string")
    restoreDefaultLocale()
    unlock()
    @

    But this will lack performance when multiple client are connected at the same time, because only one thread can get a string at the same time.

    I would like to know if there is not a better solution like a native tr() function with an additional parameters.

    For example, i would like to use:
    @
    tr("mystring", "fr");
    tr("mystring", "de");
    tr("mystring", "en");
    @

    Thank for your help

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rcari
      wrote on last edited by
      #2

      You shoud look at "QTranslator":http://qt-project.org/doc/qt-4.8/qtranslator.html
      You should instantiate one translator for each locale, and use the @QTranslator::translate(...)@ methods directly.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SaiyanRiku
        wrote on last edited by
        #3

        Thank you very much. I think i can deal with that.

        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