ICU (International Components for Unicode) syntax is a reliable system designed to support internationalization (i18n) and localization (l10n) by enabling dynamic text formatting in software. It provides essential features like pluralization, gender-specific text variations, and context-sensitive messaging, helping developers handle the challenges of different languages and cultures. ICU syntax also ensures consistent formatting of numbers, dates, and currencies across various locales. By embedding rules directly in text templates, it simplifies the creation of multilingual applications and ensures clear and accurate communication. This makes ICU syntax a key tool for delivering tailored and precise content in globally used software.
The purpose of this feature is to assist linguists in adapting and completing ICU syntax to align with the target language in the Lingotek workbench. When a source segment includes valid ICU syntax elements, these are converted into the corresponding target-language syntax, enabling linguists to translate effectively. To make the process easier, a preview feature is included to show how the source and target ICU syntaxes work after conversion.
This feature supports various types of ICU syntax, including plural, select, selectordinal, function-based syntax (for dates, times, and numbers), and argument-based syntax. It also works with nested and linear ICU syntaxes, provided they follow a valid ICU format. This ensures flexibility and precision, making it easier to manage complex linguistic and formatting tasks.
ICU Syntax Types
Plural
Used to handle pluralization rules based on a numeric value. It ensures text adjusts to singular or plural forms depending on the count.
{count, plural, one {1 item} other {# items}}
Select
Used to choose text based on specific values, such as gender or other categorical variables.
{gender, select, male {He liked your post} female {She liked your post} other {They liked your post}}
SelectOrdinal
Handles ordinal numbers like 1st, 2nd, or 3rd.
{position, selectordinal, one {#st place} two {#nd place} few {#rd place} other {#th place}}
Date
Formats date values according to the locale.
{eventDate, date, long}
Time
Formats time values with locale-specific styles like 12-hour or 24-hour clocks.
{eventTime, time, short}
Argument
Refers to placeholders dynamically replaced with variables such as names.
Example:
{userName} logged in successfully.
Number
Formats numeric values with locale-aware rules, supporting various representations such as currency, percentage, and custom patterns.
Number Type:
Decimal Formatting: Displays numbers in standard decimal format.
{price, number}
Currency: Formats numbers as currency with locale-specific symbols.
{price, number, ::currency/USD}
Percentage: Displays numbers as percentages.
{progress, number, percent}
Scientific Notation: Represents numbers in scientific notation when required.
{value, number, scientific}
Custom Patterns: Allows defining specific number patterns, like fixed decimal places.
{score, number, ::.00}
Steps to Use the ICU Pluralization Feature
Enable or Disable Pluralization for the Community
1.Navigate to System > Communities.
2. Select the desired community and enable or disable the Pluralization option under Additional Features.
Upload the Document
1.Go to the project and upload an XLF2 document along with the corresponding .srx file.
2.Open the document in the Workbench.
3.If Pluralization is enabled, the ICU Pluralization tab will be visible in the Workbench sidebar.
Check the Source Segment for ICU Syntax
1.Select a source segment from the Workbench's segment table.
2.If the segment does not contain ICU syntax, a message will display: "No ICU syntax detected." and ICU Pluralization tab icon displays the count as 0.
3.If the segment contains invalid ICU syntax, an error message will display: "Invalid ICU syntax in the provided source segment." and ICU Pluralization tab icon displays the count as 0.
View and Translate the Target String
1.If the source segment contains valid ICU syntax, ICU Pluralization tab icon displays the number of linear ICU syntax count and the converted ICU syntax for the target language will appear in the Target String panel.
2.Editable placeholders (highlighted in grey) allow the user to add translated text. Users are not required to fill all placeholders.
3.When the ICU container tab is loaded, the ICU Message Helper section displays input elements based on the target type and argument names.
Preview the Translation
1.When the user updates the target string, the application previews the output based on default input values in both the Source Preview and Target Preview panels.
2.After completing the target string, users can modify the input values to see how the ICU syntax behaves with different values.
Handle Errors in ICU Syntax
1.Any issues with the ICU syntax will be displayed in the Preview section, allowing users to identify and resolve errors.
Copy the Completed Target String
1.Once satisfied with the results, click Copy to Target Text to paste the completed target string into the target column of the segment table.
2.Users can also copy the segment at any time, regardless of whether it is fully completed.
Note:
To simplify the application, the octothorpe syntax (#) is not supported. If a segment includes the # character in SelectOrdinal or any other ICU syntax, users must manually type it. During rendering, the # will be replaced with the corresponding number automatically.