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. nativeLanguageName is too verbose

nativeLanguageName is too verbose

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 504 Views
  • 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.
  • MegamouseM Offline
    MegamouseM Offline
    Megamouse
    wrote on last edited by
    #1

    Hi,
    I am currently trying to implement a list of languages that the user can choose when they want to change the localization of our program.

    The QLocales are created using the available .qm filenames, which works perfectly fine.

    The problem I'm having is that the nativeLanguageString of some QLocales can end up really ugly, when used in combination with the native country name.

    QLocale locale = QLocale("en");
    myString = locale.nativeLanguageName() + " (" + locale.nativeCountryName() + ")";
    

    I would expect to see something like "English (United States)"
    But instead the result is "American English (United States)"

    I already found out that QLocale::languageToString(locale)will return "English", which apparently is hardcoded as english string in the Qt souce code.

    So my main question is:
    Is there a way to make this look better in its native language?
    Or what is the commonly recommended way to show language selections to the user?

    Best regards,
    Megamouse

    Pablo J. RoginaP 2 Replies Last reply
    1
    • MegamouseM Megamouse

      Hi,
      I am currently trying to implement a list of languages that the user can choose when they want to change the localization of our program.

      The QLocales are created using the available .qm filenames, which works perfectly fine.

      The problem I'm having is that the nativeLanguageString of some QLocales can end up really ugly, when used in combination with the native country name.

      QLocale locale = QLocale("en");
      myString = locale.nativeLanguageName() + " (" + locale.nativeCountryName() + ")";
      

      I would expect to see something like "English (United States)"
      But instead the result is "American English (United States)"

      I already found out that QLocale::languageToString(locale)will return "English", which apparently is hardcoded as english string in the Qt souce code.

      So my main question is:
      Is there a way to make this look better in its native language?
      Or what is the commonly recommended way to show language selections to the user?

      Best regards,
      Megamouse

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @Megamouse said in nativeLanguageName is too verbose:

      nativeLanguageName()

      From the method source code, it looks the "ugly" name comes from the system locale (based on underlying OS) if Qt was configured to use system locale, or from a built-in table if not.

      See that the method comment already make you aware of the possible return values:

      Returns a native name of the language for the locale. For example

      "Schwiizertüütsch" for Swiss-German locale.
      

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • MegamouseM Megamouse

        Hi,
        I am currently trying to implement a list of languages that the user can choose when they want to change the localization of our program.

        The QLocales are created using the available .qm filenames, which works perfectly fine.

        The problem I'm having is that the nativeLanguageString of some QLocales can end up really ugly, when used in combination with the native country name.

        QLocale locale = QLocale("en");
        myString = locale.nativeLanguageName() + " (" + locale.nativeCountryName() + ")";
        

        I would expect to see something like "English (United States)"
        But instead the result is "American English (United States)"

        I already found out that QLocale::languageToString(locale)will return "English", which apparently is hardcoded as english string in the Qt souce code.

        So my main question is:
        Is there a way to make this look better in its native language?
        Or what is the commonly recommended way to show language selections to the user?

        Best regards,
        Megamouse

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @Megamouse said in nativeLanguageName is too verbose:

        Or what is the commonly recommended way to show language selections to the user?

        If the list of possible languages to select from is "short", which should be the case since you're are already creating locales using the available .qm filenames you could use a QMap<QLocale, QString> structure for instance and provide the whatever fancy name you want for a particular locale.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1
        • MegamouseM Offline
          MegamouseM Offline
          Megamouse
          wrote on last edited by
          #4

          @Pablo-J-Rogina I'm not adding the files.
          It's an open source software, so anyone can add their own language to their local build. But we don't ship translations ourselves.

          That's why a map is not feasible, unless someone has a map of language code to all the language names in their native tongue (ideally plus optional country).

          I'm tempted to simply go with the "ugly" verbose solution and hope that someone who gets triggered enough fixes it elegantly in the future.

          Pablo J. RoginaP 1 Reply Last reply
          0
          • MegamouseM Megamouse

            @Pablo-J-Rogina I'm not adding the files.
            It's an open source software, so anyone can add their own language to their local build. But we don't ship translations ourselves.

            That's why a map is not feasible, unless someone has a map of language code to all the language names in their native tongue (ideally plus optional country).

            I'm tempted to simply go with the "ugly" verbose solution and hope that someone who gets triggered enough fixes it elegantly in the future.

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @Megamouse said in nativeLanguageName is too verbose:

            That's why a map is not feasible, unless someone has a map of language code to all the language names

            Taking a second look at the "requirements", you could add one string in your open source code that's the "nativeLanguageName" and so, everyone adding a new language will have that string to translate in the set of strings to translate. So whenever a language file is loaded, the "nice" native language name is already there...

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            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