published
11 January 2025
by
Ray Morgan
updated
6 February 2025

Grammatical Features in UI Localization

Many UI elements contain dynamic, user-generated, or system-generated text that must follow the grammatical rules of the target language. A direct translation often fails because:

  • The user's gender, case, politeness level, or plurality affects the wording.
  • Certain languages don't allow concatenation, making text assembly problematic.
  • UI elements like notifications, tooltips, buttons, and status messages require grammatically correct variations.

Examples of UI Elements Affected by Grammar

UI Element Grammatical Issue Example
Welcome Messages Gendered terms "Welcome, cher utilisateur!" (male) vs. "Welcome, chère utilisatrice!" (female) in French
Notifications Verb conjugation "Maria liked your post" must match subject and tense correctly in different languages.
Success Messages Politeness level A Japanese UI may use honorifics: "ファイルがアップロードされました" (neutral) vs. "ファイルをアップロードなさいました" (polite).
Button Labels Verb form English "Edit Profile" → Russian: "Редактировать профиль" (infinitive) vs. "Отредактируйте профиль" (imperative).
Dropdowns & Forms Case inflection A form field for selecting "Your Country" may require different cases: "Deutschland" (nom.) vs. "aus Deutschland" (dat.) in German.

Common Pitfalls in UI Localization

String Concatenation Fails:

  • A UI notification like "User " + name + " sent you a message" may break in languages that require case changes.
    • Wrong in Russian: "Пользователь Анна отправил вам сообщение." (should be Анна → Анна отправила).
    • Fix: Use a localization framework that dynamically adjusts word forms.

Assuming Gender-Neutrality:

  • English does not require gendered adjectives, but languages like French, Spanish, and Italian do.
    • Example: "You are a registered user"
      • ✅ French (male): "Vous êtes un utilisateur enregistré."
      • ✅ French (female): "Vous êtes une utilisatrice enregistrée."
    • Fix: Use gender-neutral phrasing where possible or allow dynamic gender handling.

Direct Translations Ignore Verb Forms:

  • A button label saying "Post" may require different forms in different languages:
    • English: "Post" (imperative verb)
    • French: "Publier" (infinitive) or "Publiez" (imperative, formal)
    • German: "Beitrag veröffentlichen" (noun + verb phrase)
    • Fix: Use localized verb handling instead of assuming one form fits all.

2. Solution Requirements

For internationalized UI elements, the system must:

  1. Support Dynamic Gender & Case Handling:
    • Avoid assuming gender-neutrality unless it works in all target languages.
  2. Format Text Without String Concatenation:
    • Use localization frameworks that allow variable substitution and case/gender adjustments.
  3. Enable UI Text Variations for Politeness Levels:
    • Some languages (Japanese, Korean) require honorific versions.
  4. Use ICU MessageFormat or i18n Libraries:
    • Solutions like ICU, gettext, i18next, or Symfony Translation handle these issues natively.

3. Demos: Implementing UI Localization with Grammatical Adjustments

Minimal Implementation: Gender Handling in UI

A welcome message should change based on user gender.

Using ICU MessageFormat (Best Practice)

{
  "welcome": "{GENDER, select, male {Bienvenue, cher utilisateur!} female {Bienvenue, chère utilisatrice!} other {Bienvenue!}}"
}

💡 Why? This avoids hardcoded conditions and works with i18n tools like i18next, Symfony, and gettext.

JavaScript with i18next

import i18next from 'i18next';

i18next.init({
  lng: 'fr',
  resources: {
    fr: {
      translation: {
        welcome: {
          male: "Bienvenue, cher utilisateur!",
          female: "Bienvenue, chère utilisatrice!",
          other: "Bienvenue!",
        },
      },
    },
  },
});

const gender = "female"; 
console.log(i18next.t(`welcome.${gender}`)); // Outputs: "Bienvenue, chère utilisatrice!"

Robust Implementation: Case Handling in UI

For a form dropdown, a country name may require a case change.

Example: German Case Inflection for "Your Country"

{
  "your_country": "{CASE, select, nominative {Deutschland} dative {aus Deutschland} other {Deutschland}}"
}

💡 Why? This ensures a correct case ending based on sentence structure.

PHP with Symfony Translation

use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\ArrayLoader;

$translator = new Translator('de');
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', [
    'your_country' => '{CASE, select, nominative {Deutschland} dative {aus Deutschland} other {Deutschland}}'
], 'de');

$case = 'dative';
echo $translator->trans("your_country", ['CASE' => $case]); // Outputs: aus Deutschland

Dynamic Verb Forms in UI Buttons

Problem: A "Delete File" button needs the correct verb form:

  • English: "Delete File"
  • Spanish: "Eliminar archivo" (infinitive)
  • German: "Datei löschen" (infinitive)
  • Japanese: "ファイルを削除" (noun + verb)

Solution: Use Context-Based Translations

{
  "delete_button": {
    "en": "Delete File",
    "es": "Eliminar archivo",
    "de": "Datei löschen",
    "ja": "ファイルを削除"
  }
}

💡 Why? Instead of dynamically inserting verbs, pre-translate entire button labels.


4. Implementation Guide

Completion Criteria

✅ UI elements correctly adapt based on gender, case, politeness, or conjugation.
Concatenation is avoided in favor of templating/localization frameworks.
Gender-neutral phrasing is used where possible.
Fallbacks exist for cases where grammar-based UI changes aren’t available.

Testing Considerations

🔹 Check UI Consistency: Ensure buttons, dropdowns, and notifications match grammatical expectations.
🔹 Test with Native Speakers: Automated translation tools may not detect case/gender errors.
🔹 Verify Fallbacks: If a UI lacks gender data, ensure a neutral message appears instead of broken text.


Final Takeaways

  • Gender, case, and verb forms affect UI localization more than expected.
  • Concatenation should be avoided in favor of structured templates.
  • Localization frameworks (ICU, i18next, Symfony, gettext) simplify handling grammatical features.
  • Testing with real-world UI scenarios is essential to catch errors not obvious in English-based development.