Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Translating text in Java is accomplished by using the org.ofbiz.base.util.UtilProperties class. Here is an example:

Code Block
java
java
public static Map<String, Object> myJavaService(DispatchContext ctx, Map<String, ?> context) {
    Locale locale = (Locale) context.get("locale");
    try {
        // Do something risky
        ...
    } catch (Exception e) {
        return ServiceUtil.returnError(String myLabel = UtilProperties.getMessage(MyUiLabelsCommonUiLabels, "RiskyErrorMessageCommonAddNew", locale));
    }
    ...
}