Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-8258

iOS getPreferredLanguage should be from the list of available localizations for the app

    XMLWordPrintableJSON

Details

    Description

      In CDVGlobalization.m, the following line is used to get the preferredLanguage from getPreferredLanguage

      NSString* language = [[NSLocale preferredLanguages] objectAtIndex:0];

      The issue with this is, for an application, if the system preferred language is not available in Application Resource bundle,all framework messages will appear in the system preferred language and all app specific strings will appear in a fallback language like en_US.

      A second scenario is, like for a language like Portuguese, if only viewControllerBundle_pt.xlf is existing as application resource but the system language selected is pt_BR, with the current code, the fallback resource bundle viewControllerBundle_pt.xlf won't be activated and application will appear in en_US

      Using the following, instead we can get a preferred language from the list of available localizations for the an application, which is independent of the preferredLanguage for the system.

      NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];

      Attachments

        Activity

          People

            Unassigned Unassigned
            surebee Suresh Chandrasekharan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: