Internationalization and localization tools


Locale-Sensitive Java Method

java.lang.StringBuilder, java.lang.StringBuffer

public StringBuilder insert(int index, char[] str, int offset, int len)

public StringBuilder insert(int offset, Object obj)

public StringBuilder insert(int offset, String str)

public StringBuilder insert(int offset, char[] str)

public StringBuilder insert(int offset, boolean b)

public StringBuilder insert(int offset, char c)

public StringBuilder insert(int offset, int i)

public StringBuilder insert(int offset, long l)

public StringBuilder insert(int offset, float f)

public StringBuilder insert(int offset, double d)


public StringBuffer insert(int index, char[] str, int offset, int len)

public StringBuffer insert(int dstOffset, CharSequence s)

public StringBuffer insert(int dstOffset, CharSequence s, int start, int end)

public StringBuffer insert(int offset, Object obj)

public StringBuffer insert(int offset, String str)

public StringBuffer insert(int offset, char[] str)

public StringBuffer insert(int offset, boolean b)

public StringBuffer insert(int offset, char c)

public StringBuffer insert(int offset, int i)

public StringBuffer insert(int offset, long l)

public StringBuffer insert(int offset, float f)

public StringBuffer insert(int offset, double d)

Internationalization (I18n) Function Overview

The insert method inserts the string representation of the specified parameter into the StringBuilder or StringBuffer instance. Instances of StringBuilder are not safe for use by multiple threads, unlike StringBuffer.

For more information click here.

I18n Issues

In an internationalized application, insert 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 insert 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, insertion of a single character is just as suspicious as insertion 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 insert 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

    Insertion of 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 insert 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