Class LocaleSelector


  • public class LocaleSelector
    extends java.lang.Object
    Select XML content based on current Locale. Tries locale and country separated by an underscore, language, and then uses the default Locale. _tlh is treated as a special case, for the ant locale target
    Since:
    2.9.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String[] suffixes  
      (package private) static boolean testLocale  
    • Constructor Summary

      Constructors 
      Constructor Description
      LocaleSelector()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.String checkElement​(Element el, java.lang.String name, java.lang.String suffix)
      Checks one element to see if it's the one for the current language else returns null.
      static java.lang.String getAttribute​(Element el, java.lang.String name)
      Return the value of an attribute for the current locale.
      protected static void setSuffixes​(java.lang.String[] newSuffixes)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getAttribute

        public static java.lang.String getAttribute​(Element el,
                                                    java.lang.String name)
        Return the value of an attribute for the current locale.

        <foo temp="a"> <temp xml:lang="hh">b</temp> </foo>

        Say it's looking for the attribute ATT. For each possible suffix, it first looks for a contained element named ATT with an XML 'lang' attribute for the suffix. If so, it takes that value. If none are found, the attribute value is taken from the original element.

        Parameters:
        el - the element with the attribute or child element
        name - the name of the attribute or child element
        Returns:
        the value of the attribute or null
      • checkElement

        static java.lang.String checkElement​(Element el,
                                             java.lang.String name,
                                             java.lang.String suffix)
        Checks one element to see if it's the one for the current language else returns null.
        Parameters:
        el - the element
        name - the attribute
        suffix - the locale
        Returns:
        the value of the attribute or null
      • setSuffixes

        protected static void setSuffixes​(java.lang.String[] newSuffixes)