Internationalization and localization tools


Externalize Concatenated Strings

Globalyzer now detects when strings are part of a string concatenation. Concatenated strings need to be refactored before being externalized.

As Globalyzer scans your source code, it sets a detected string's Scan Results priority to the new string concatenation priority 'C' when at least one of the following conditions are true:

  • string literal starts or ends with white space
  • string literal is preceded or followed by (language specific) concatenation characters
  • string literal is a parameter to a Locale-Sensitive Method configured to have priority 0 (the string concatenation priority)

For example, given the following code:

String ua = user + " is " + age + " years old.";

Globalyzer will find two strings: " is " and " years old." and assign them both priority 'C'.

You cannot simply externalize the two strings independently to a resource file and have the file sent out for translation. The translator will end up translating the two strings out of context. The word order may be different by language and the grammar may be different, too. For instance, in French, a person has four years. Without the context or the full sentence, a translator could not guess how "is" will be used.

Most programming languages support some kind of parameter substitution. For example, in Java the above code could be refactored using MessageFormat.format:

String ua = MessageFormat.format("{0} is {1} years old.", user, age);

After refactoring, rescan the file. The new string, "{0} is {1} years old." is detected and can now be externalized. The translator will know the proper translation given the full context of the string.

Note: Once externalized, the entry will be removed from the Active Scan Results table.

 

Lingoport internationalization and localization services and software