Class AppLanguages

  • All Implemented Interfaces:
    EventListener, IGProp<GProp<?>[]>, IPropCnr, java.lang.Cloneable

    public class AppLanguages
    extends PropCnr
    The configured languages for the application.
    Author:
    Christopher Mindus
    • Constructor Detail

      • AppLanguages

        protected AppLanguages()
        Constructor without name.
    • Method Detail

      • addPredefinedProps

        protected void addPredefinedProps()
                                   throws PropException
        Adds the predefined properties for this container. This method is called once just after construction of the property container.
        Overrides:
        addPredefinedProps in class PropCnr
        Throws:
        PropException - for property exceptions.
      • getPredefinedProps

        protected void getPredefinedProps()
        Gets potential references to predefined properties for this container. This method is called once just after cloning of the property container.

        The method should get reference to using the getProp(...) methods. This allows the subclass to be able to retrieve the new instances to the properties created during addPredefinedProps() if stored in instance variables.

        Overrides:
        getPredefinedProps in class PropCnr
      • getModuleApp

        public ModuleApp getModuleApp()
        Gets the module app that contains these language information.
        Returns:
        The ModuleApp instance.
        Throws:
        java.lang.InternalError - If the ModuleApp is null, something that should never happen.
      • getTextTable

        public TextTable getTextTable()
        Gets the text table that is assigned to the app. In case the application is localized, then you can get text tables for a particular language code, or all.

        This is a helper function that does the same as calling getModuleApp().getTextTable().

        Returns:
        The text table for the application, or null if none is set.
      • isAppLocalized

        public boolean isAppLocalized()
        Gets the setting if this is a localized application, i.e. has support to be displayed in different languages, thus has support uses multiple text tables. This is known by checking the text tables derived text tables and their language codes, and so on. But this is not an optimal solution because it requires computation.
        Returns:
        The configured setting by the app developer if this app supports localization. If so, the text table should have derived text tables for all defined language codes. Errors and warnings will be displayed to the app developer if there is a mismatch of the localization settings and defined language codes.
      • getDefaultLanguageCode

        public java.lang.String getDefaultLanguageCode()
        Gets the default language code defined when none is matching.
        Returns:
        The default language code to use (e.g. "en-US"), or null if none is defined.
      • setDefaultLanguageCode

        public boolean setDefaultLanguageCode​(java.lang.String lang)
        Sets the default language code.
        Parameters:
        lang - The language code, or null or empty String to remove default.
        Returns:
        true for changed, false for no change.
      • mapLanguage

        public AppLanguages.Result mapLanguage​(java.lang.String languageCode)
        Maps a user language code to a Result.
        Parameters:
        languageCode - The language code.
        Returns:
        The Result, never null.
      • getLanguageDefinitions

        public StringArrayProp getLanguageDefinitions()
        Gets the language map StringArrayProp that stores the language mappings as strings formatted as "lang{\t}useFor" where "lang" is the application-defined language, {\t} is the tab character and "useFor" is empty indicates the original language code being matched for, or a comma separated string of language codes with optional wildcards (* ?) that matches a particular language code to the application-defined language code.
      • getData

        public AppLanguages.Data getData()
        Gets a cached copy of (or builds) the language information from the language definitions.
        Returns:
        The AppLanguages data.