Internationalization and localization tools


Locale-Sensitive Java Method

java.lang.StringBuilder, java.lang.StringBuffer

public StringBuilder append(boolean value);
public StringBuilder append(char value);
public StringBuilder append(char[] value);
public StringBuilder append(char[] value, int offset, int len);
public StringBuilder append(CharSequence value);
public StringBuilder append(CharSequence value, int start, int end);
public StringBuilder append(double value);
public StringBuilder append(int value);
public StringBuilder append(long value);
public StringBuilder append(Object value);
public StringBuilder append(float value);
public StringBuilder append(string value);
public StringBuilder append(StringBuilder value);

public StringBuffer append(boolean value);
public StringBuffer append(char value);
public StringBuffer append(char[] value);
public StringBuffer append(char[] value, int offset, int len);
public StringBuffer append(CharSequence value);
public StringBuffer append(CharSequence value, int start, int end);
public StringBuffer append(double value);
public StringBuffer append(int value);
public StringBuffer append(long value);
public StringBuffer append(Object value);
public StringBuffer append(float value);
public StringBuffer append(string value);
public StringBuffer append(StringBuffer value);

Internationalization (I18n) Function Overview

The append method appends the string representation of the specified parameter to the end of a StringBuilder or StringBuffer instance. Instances of StringBuilder are not safe for use by multiple threads, unlike StringBuffer.

I18n Issues

In an internationalized application, append should not be used if the resulting string is to be displayed to the user. This is because the order of the translated pieces of the string can be different for each locale. In addition, there are other i18n issues concerning these specific append parameter data types:

  • boolean - this will be converted to the string "True" or "False", which, in a non-English application, will need to be translated.
  • char - although this data type can hold a Unicode character, concatenation of a single character is just as suspicious as concatenation of a word from a linguistic point of view. Punctuation marks such as list separators are locale sensitive. It is preferable to externalize strings to encompass complete sentential forms (including punctuation), rather than append individual characters.
  • double, float - the floating point number will be converted to a string based on the current locale. As this may result in a different decimal point separator, ensure that the locale is properly set.
  • long, int - the number will be converted to a string based on the current locale. As this may result in a different grouping separator, ensure that the locale is properly set.
  • Recommended Replacements

    Appending words is particularly questionable from a linguistic point of view. It is preferable to externalize strings to encompass complete sentential forms (including punctuation), rather than append individual fragment strings. Use MessageFormat or String.format to manage dynamic string creation, assuming locale has properly been set using setlocale.

    Locale-Sensitive Java Methods

     

    Lingoport internationalization and localization services and software