The basics

Best Practices

  1. Follow the standards described in this guide
  2. Always use properties files for user interface text; never include displayable text in java, jsp, or templates (see Localizing Tools below)
  3. Use properties files only for user interface text and config files for configuration settings (see Config Properties below).
  4. Use a proper naming schema for keys in your resource bundles. The name of the keys should provide some information about the context of the displayed text. This helps the translators during the translation process. A naming schema could be <view>.<type>.<name>. Examples: edit.button.save, edit.label.title or list.action.addnew
  5. Group keys by view, ie. edit.title, edit.instructions, list.title, list.instructions, create.title, etc
  6. Never use displayable text when executing comparisons within the logic of the tool (separate codified values from displayable text)
  7. Always use the ResourceLoader (not ResourceBundle) class for retrieving properties values, and invoke ResourceLoader methods dynamically, to accommodate dynamic user preferences (see Resource Loader below).
  8. All dynamically constructed phrases must be sensitive to locale specific subject/verb/object ordering by using the Sakai ResourceLoader class: org.sakaiproject.util.ResourceLoader.getFormattedMessage() (see Structure messages appropriately below)
  9. All numbers and dates should be formatted specific to the user's locale (e.g. java.text.NumberFormat and java.text.DateFormat)
  10. Test tools in more than one language

Config Properties


Properties files (<filename>.properties) should only be used for user interface text that should be translated. All other configuration information (e.g. configuration constants, class names, filenames, etc.) should be in a separate directory tree. Alternately, config files can use the <filename>.config extension and be referenced as follows:

import java.util.Properties;
...
Properties p = new Properties();
p.load(this.getClass().getResourceAsStream("filename.config"));