Agent Wranglers

LOC-30Recommended

Let every layout grow with the longest translation

Give text room to grow. No text container has a fixed width or height, and every screen is tested with the longest translation of each message.

How to do it

The W3C quotes average growth from English of 200 to 300% for texts up to 10 characters, and about 130% for texts over 70. Short labels such as buttons and tabs grow the most. Let containers wrap and grow, with min-width instead of width and no fixed heights on text. On mobile, use wrap-content sizes and Auto Layout instead of fixed frames. Where space is fixed, such as a tab bar, give translators the limit as Give translators context and a review step says. Find the longest translation per key with a script, and test with it as Test with a pseudo-locale says.

Examples

JavaScript example

export function longestLocale(catalogs) {
  const longest = {};
  for (const messages of Object.values(catalogs))
    for (const [key, text] of Object.entries(messages))
      if (!longest[key] || text.length > longest[key].length) longest[key] = text;
  return longest;
}

Python example

def longest_locale(catalogs: dict[str, dict[str, str]]) -> dict[str, str]:
    longest: dict[str, str] = {}
    for messages in catalogs.values():
        for key, text in messages.items():
            if len(text) > len(longest.get(key, "")):
                longest[key] = text
    return longest

CSS example

.tab-label { min-inline-size: 6rem; overflow-wrap: anywhere; }

How to check

The browser or UI tests run once in a locale built from the longest translation of every key, at phone width. No text is cut off, overlaps or scrolls sideways.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/localization/layout-and-scripts/text-expansion">Agent Wranglers localization playbook</a>. In code you write, add a comment next to it with the same link.