OpenWebBeans
  1. OpenWebBeans
  2. OWB-191

Convert logging to use keyed, formatted strings from a ResourceBundle to allow for translation.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: M4
    • Component/s: Core
    • Labels:
      None
    • Environment:
      All.

      Description

      Currently all logs and exceptions use hard coded strings that are embedded throughout the source. The attached patch converts the code to use key-based strings from a ResourceBundle so that all strings are collected in one place to enable translation.

        Activity

        Hide
        Paul J. Reder added a comment -

        This patch adds two new files:
        webbeans-impl/src/main/resources/javax/openwebbeans/Messages_en.properties
        and
        webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java

        adds ResourceBundle support to:
        webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java

        and updates most of the OWB code to use const-based keys to reference the bundle instead of using hard-coded strings. The bundled strings now support formatting substitutions using Object[] args in the log calls.

        This patch will still allow non-keyed values to be logged as they were before, but supports keyed references to bundled strings with formatting.

        This patch contains a first pass at constant and key values. Those values can easily be changed to suit any standardized const/key format.

        The properties and constants files have been located in what I think is the right place, but can certainly be moved elsewhere.

        Please let me know if there is anything else I can do to make it easier to commit this.

        Show
        Paul J. Reder added a comment - This patch adds two new files: webbeans-impl/src/main/resources/javax/openwebbeans/Messages_en.properties and webbeans-impl/src/main/java/org/apache/webbeans/config/OWBLogConst.java adds ResourceBundle support to: webbeans-impl/src/main/java/org/apache/webbeans/logger/WebBeansLogger.java and updates most of the OWB code to use const-based keys to reference the bundle instead of using hard-coded strings. The bundled strings now support formatting substitutions using Object[] args in the log calls. This patch will still allow non-keyed values to be logged as they were before, but supports keyed references to bundled strings with formatting. This patch contains a first pass at constant and key values. Those values can easily be changed to suit any standardized const/key format. The properties and constants files have been located in what I think is the right place, but can certainly be moved elsewhere. Please let me know if there is anything else I can do to make it easier to commit this.
        Hide
        Gurkan Erdogdu added a comment -

        Committed, thanks Paul J. Reder

        Show
        Gurkan Erdogdu added a comment - Committed, thanks Paul J. Reder
        Hide
        Mark Struberg added a comment -

        WebBeansLogger crashes for Locale=de_AT because Resource.getBundle doesn't find anything.

        The Messages_en.properties file must be renamed to Messages.properties to become a fallback for all languages.
        I will also move the properties file to an openwebbeans sub folder.

        Show
        Mark Struberg added a comment - WebBeansLogger crashes for Locale=de_AT because Resource.getBundle doesn't find anything. The Messages_en.properties file must be renamed to Messages.properties to become a fallback for all languages. I will also move the properties file to an openwebbeans sub folder.
        Hide
        Mark Struberg added a comment -

        i18n bundle moved from

        • META-INF/Messages_en.properties
          to
        • openwebbeans/Messages.properties

        to ensure 2 things
        1.) the Messages also get picked up if the langage is not 'en' e.g for a Locale='de_AT'
        2.) the resource doesn't interfere with other Messages.properties files this way

        Show
        Mark Struberg added a comment - i18n bundle moved from META-INF/Messages_en.properties to openwebbeans/Messages.properties to ensure 2 things 1.) the Messages also get picked up if the langage is not 'en' e.g for a Locale='de_AT' 2.) the resource doesn't interfere with other Messages.properties files this way
        Hide
        Mark Struberg added a comment -

        closed all issues which got resolved in M4

        Show
        Mark Struberg added a comment - closed all issues which got resolved in M4

          People

          • Assignee:
            Gurkan Erdogdu
            Reporter:
            Paul J. Reder
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development