Embedded String

The challenges of embedded strings to effective internationalization (i18n)

An embedded string, also known as an interpolated string or template string, is a feature in programming languages that embeds expressions or variables within a string literal.
Embedded strings can offer a convenient and concise way to include dynamic or computed values in a software UI without the need to join characters end-to-end in complex strings, known as concatenation.
The process of software internationalization (i18n) includes translating embedded strings into different languages.

Why strings are used in software programming?

In computer programming, a string is a data type that represents a sequence of characters such as words, sentences, or even symbols.
In most programming languages, strings typically appear enclosed in quotation marks (single or double) to distinguish them from other data types, for instance.
Strings can contain letters, numbers, symbols, and whitespace characters. They serve widely to store and manipulate textual data, display messages and prompts to users, read and write text files, and represent user input.

Here are a few examples of strings:

“Hello, World!”: A simple string that represents a greeting.
“Lingoport”: A string that represents the name of a company.
“12345”: A string that represents a numeric value but is treated as text 
instead of a mathematical entity.
“Programming is fun!”: A string that represents a statement or message.

In our free ebook, you can learn more about the challenges of embedded strings and other common i18n bugs.

The localization process and strings 

Strings are often manipulated using various string operations, such as concatenation (combining two strings), substring extraction (extracting a portion of a string), searching for specific patterns, replacing and modifying parts of a string, or embedding variables within a string.

Best practice for i18n handling of embedded strings

The string handling is a crucial aspect of the software internationalization (i18n) process for different languages and regions, as depending on the approach taken, the extraction and translation can produce sub-optimal results in the UI.

Don’t Embed: Externalise & Identify

To simplify managing and translating text strings and enable localization, export them as discrete strings with key-value pairs within a resource file.

The resource file is where the software application looks to load UI elements when running, specific to the language selection. 

Example

Here are two simple example text strings and the recommended key/value pair where the value is the string itself. 

String d =”All the young ones”;
String d =getString(“JAVA_TESTSTR_105”);
String e =”Having a good time”;
String e =getString(“JAVA_TESTSTR_106”);

The key/value pair in the resource file would look like this:

JAVA_TESTSTR_105=All the young ones
JAVA_TESTSTR_106=Having a good time

Lingoport offers products like Globalyzer and Localyzer specifically designed for software localization.
➡️Book a call with Lingoport i18n experts today.

Related Posts