Skip to content

Commit

Permalink
encourage developers to move English to bundles #2073
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed May 6, 2019
1 parent 926e955 commit 4c76181
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions doc/sphinx-guides/source/developers/coding-style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,18 @@ Generally speaking you should use ``fine`` for everything that you don't want to

When adding logging, do not simply add ``System.out.println()`` lines because the logging level cannot be controlled.

Avoid Hard-Coding Strings
~~~~~~~~~~~~~~~~~~~~~~~~~
Avoid Hard-Coding Strings (Use Constants)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Special strings should be defined as public constants. For example, ``DatasetFieldConstant.java`` contains a field for "title" and it's used in many places in the code (try "Find Usages" in Netbeans). This is better than writing the string "title" in all those places.

Avoid Hard-Coding User-Facing Messaging in English
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There is an ongoing effort to translate Dataverse into various languages. Look for "lang" or "languages" in the :doc:`/installation/config` section of the Installation Guide for details if you'd like to help or play around with this feature.

The translation effort is hampered if you hard code user-facing messages in English in the Java code. Put English strings in ``Bundle.properties`` and use ``BundleUtil`` to pull them out. This is especially important for messages that appear in the UI. We are aware that the API has many, many hard coded English strings in it. If you touch a method in the API and notice English strings, you are strongly encouraged to used that opportunity to move the English to ``Bundle.properties``.

Type Safety
~~~~~~~~~~~

Expand Down

0 comments on commit 4c76181

Please sign in to comment.