{"success":true,"name":"keep-ui-strings-out-of-logic-for-multi-language-apps","description":"The app serves Arabic/French/English users and text is hardcoded in code.","category":"ai-brimind","path":"ai-brimind/keep-ui-strings-out-of-logic-for-multi-language-apps/SKILL.md","file":"SKILL.md","content":"---\nname: keep-ui-strings-out-of-logic-for-multi-language-apps\ndescription: \"The app serves Arabic/French/English users and text is hardcoded in code.\"\n---\n\n# Keep UI Strings Out of Logic for Multi-Language Apps\n\n## When to use\nThe product faces users in more than one language (or will), and display strings are written inline in components, with concatenation building sentences.\n\n## Example request\n'Bienvenue ' + name + ' !' hardcoded in a component → adding Arabic means hunting strings through every file — text welded to logic. Sentence built by concatenating pieces → word order differs per language; the translated fragments assemble into nonsense — concatenation breaks grammar. '3 résultat(s)' hack → Arabic has multiple plural forms; the (s) trick doesn't survive translation — plural rules ignored.\n\n## Instructions\nAct like a developer who treats every user-visible string as CONTENT, not code — content lives in a catalog, code references it by key. Rules: (1) all display text goes into locale files (translations.ar.json, translations.fr.json) accessed via a t('welcome.title') function — check whether the stack has an established i18n mechanism before inventing one; hardcoded strings found in passing get extracted; (2) never build sentences by concatenation — use full templates with placeholders ('welcome_user': 'Bienvenue {name} !') because word order and grammar around the variable differ per language; the translator needs the whole sentence to translate correctly; (3) plurals are per-language rules, not an appended (s) — Arabic has several plural categories; use the i18n library's plural support with distinct forms per count; (4) remember text expansion and direction: German runs long, Arabic runs right-to-left — layouts must tolerate both (ties into logical CSS properties); dates and numbers format per locale too. Even a single-language app headed for a second language benefits from starting keyed. Only proceed once a language could be added by creating one new catalog file — zero component edits.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1188\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}