Details

    • Type: Feature Request
    • Status: CLOSED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.x
    • Fix Version/s: 2.7.x, 2.8.x
    • Component/s: Kernel
    • Labels:
    • CLE Team Issue:
      Yes
    • Previous Issue Keys:
      KNL-671

      Description

      There is no obvious method in the preferences service to get a users locale. On would expect a method like:

      PreferencesService.getUserLocale(String userId). As it is one has to do something like:

      protected Locale getUserLocale(String userId) {
      Locale loc = null;
      Preferences prefs = preferencesService.getPreferences(userId);
      ResourceProperties locProps = prefs.getProperties(InternationalizedMessages.APPLICATION_ID);
      String localeString = locProps.getProperty(InternationalizedMessages.LOCALE_KEY);

      if (localeString != null) {
      String[] locValues = localeString.split("_");
      if (locValues.length > 2)

      { loc = new Locale(locValues[0], locValues[1], locValues[2]); // language, country, variant }

      else if (locValues.length > 1)

      { loc = new Locale(locValues[0], locValues[1]); // language, country }

      else if (locValues.length == 1)

      { loc = new Locale(locValues[0]); // just language }

      }
      //the user has no preference set - get the system default
      if (loc == null ) {
      String lang = System.getProperty("user.language");
      String region = System.getProperty("user.region");

      if (region != null)

      { log.debug("getting system locale for: " + lang + "_" + region); loc = new Locale(lang,region); }

      else

      { log.debug("getting system locale for: " + lang ); loc = new Locale(lang); }

      }

      return loc;
      }

      Solution - add a new method to preferences service to make this easier and avoid dubplicate code

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                dhorwitz David Horwitz
                Reporter:
                dhorwitz David Horwitz
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code