Skip to content

Commit 6ce2570

Browse files
committed
Add shared catalog for shared-webapp/ui translations and merge at runtime
1 parent badb492 commit 6ce2570

14 files changed

Lines changed: 303 additions & 625 deletions

File tree

.claude/rules/frontend/translations.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ Guidelines for implementing translations and internationalization in the fronten
1414
3. Always use plain English text in translation markers
1515
4. Don't hardcode text without proper translation wrappers
1616
5. Use "Sentence case" for everything (buttons, menus, headings, etc.)
17-
6. **Lingui macros work in `shared-webapp/ui` components**. The SWC plugin runs in source-build mode across all workspace packages, and each self-contained system's `createLinguiConfig()` includes `shared-webapp/ui/**/*.{ts,tsx}` in its extraction scope. This means every shared UI component auto-generates catalog entries in every self-contained system (main, account, back-office) independently. Prefer macros over threading translatable text through props -- only accept a text prop when a consumer genuinely needs to override the default (e.g., context-specific wording). Note: shared strings must be translated in every self-contained system's `*.po` files -- translation workflow must keep all three self-contained systems in sync
17+
6. **Catalogs are split between the shared component library and each self-contained system**:
18+
- Markers in `application/shared-webapp/ui/**` extract to `application/shared-webapp/ui/translations/locale/{locale}.po` — one shared catalog used by every app
19+
- Markers in `application/<system>/WebApp/**` extract to that system's `shared/translations/locale/{locale}.po`
20+
- At runtime, `createFederatedTranslation` merges them: shared underneath, system on top, federated remote (e.g. account loaded into main) on top of that
21+
- Translate each shared string **once** in the shared catalog, not in every system's catalog
22+
- Prefer Lingui macros inside `shared-webapp/ui` components over threading translatable text through props -- only accept a text prop when a consumer genuinely needs to override the default (e.g., context-specific wording)
1823
7. Translation workflow:
19-
- Translation files are in `shared/translations/locale/` (e.g., `da-DK.po`, `en-US.po`)
20-
- After adding/changing `<Trans>` or t\`\` markers, the `*.po` files are auto-generated/updated by the build system
21-
- Don't manually add or remove entries to `*.po` files
22-
- After auto-generation, translate all new/updated entries in `*.po` files for all supported languages
23-
- Only translate `msgstr` values—never change `msgid` values
24+
- After adding/changing `<Trans>` or t\`\` markers, the `*.po` files are auto-regenerated on build
25+
- Don't manually add or remove `msgid` entries -- only translate `msgstr` values
26+
- After auto-generation, translate all new/updated entries for all supported languages
2427
8. **Use correct language-specific characters** in translations -- e.g., Danish requires æøå/ÆØÅ, not ae/oe/aa substitutes. Never approximate with ASCII equivalents
2528
9. Don't translate fully dynamic content such as variable values or dynamic text
2629
9. **Domain terminology consistency**:

application/account/WebApp/routes/components/-components/PreviewAvatarMenu.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { t } from "@lingui/core/macro";
22
import { useLingui } from "@lingui/react";
33
import { Trans } from "@lingui/react/macro";
44
import { preferredLocaleKey } from "@repo/infrastructure/translations/constants";
5+
import localeMap from "@repo/infrastructure/translations/i18n.config.json";
56
import { type Locale, translationContext } from "@repo/infrastructure/translations/TranslationContext";
67
import { Avatar, AvatarFallback } from "@repo/ui/components/Avatar";
78
import {
@@ -81,7 +82,9 @@ function FakeProfileCard() {
8182
export function PreviewAvatarMenu() {
8283
const isCollapsed = useContext(collapsedContext);
8384
const { theme, setTheme, resolvedTheme } = useTheme();
84-
const { setLocale, getLocaleInfo, locales } = use(translationContext);
85+
const { setLocale } = use(translationContext);
86+
const locales = Object.keys(localeMap) as Locale[];
87+
const getLocaleInfo = (locale: Locale) => localeMap[locale];
8588
const { i18n } = useLingui();
8689
const currentLocale = i18n.locale as Locale;
8790
const [currentZoomLevel, setCurrentZoomLevel] = useState("1");

application/account/WebApp/shared/translations/locale/da-DK.po

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ msgstr ""
1313
"Plural-Forms: \n"
1414
"X-Generator: @lingui/cli\n"
1515

16-
#. placeholder {0}: -diffDays
17-
msgid "{0, plural, one {# day ago} other {# days ago}}"
18-
msgstr "{0, plural, one {for # dag siden} other {for # dage siden}}"
19-
2016
#. placeholder {0}: result.value
2117
msgid "{0, plural, one {# hour ago} other {# hours ago}}"
2218
msgstr "{0, plural, one {# time siden} other {# timer siden}}"
@@ -64,9 +60,6 @@ msgstr "{0}/måned"
6460
msgid "{deletedCount} users permanently deleted"
6561
msgstr "{deletedCount} brugere slettet permanent"
6662

67-
msgid "{diffDays, plural, one {In # day} other {In # days}}"
68-
msgstr "{diffDays, plural, one {Om # dag} other {Om # dage}}"
69-
7063
msgid "{price}/month"
7164
msgstr "{price}/måned"
7265

@@ -479,9 +472,6 @@ msgstr "Bunddrawer"
479472
msgid "Bottom sheet"
480473
msgstr "Bundsheet"
481474

482-
msgid "Breadcrumb"
483-
msgstr "Brødkrumme"
484-
485475
msgid "Breadcrumb — custom separator"
486476
msgstr "Brødkrumme — brugerdefineret skilletegn"
487477

@@ -665,12 +655,6 @@ msgstr "By"
665655
msgid "Clear"
666656
msgstr "Ryd"
667657

668-
msgid "Clear date"
669-
msgstr "Ryd dato"
670-
671-
msgid "Clear dates"
672-
msgstr "Ryd datoer"
673-
674658
msgid "Clear filters"
675659
msgstr "Ryd filtre"
676660

@@ -683,15 +667,9 @@ msgstr "Klik på en række for at åbne sidepanelet. Brug Shift eller Cmd/Ctrl s
683667
msgid "Close"
684668
msgstr "Luk"
685669

686-
msgid "Close menu"
687-
msgstr "Luk menu"
688-
689670
msgid "Close recipe details"
690671
msgstr "Luk opskriftsdetaljer"
691672

692-
msgid "Close sidebar"
693-
msgstr "Luk sidemenu"
694-
695673
msgid "Close user profile"
696674
msgstr "Luk brugerprofil"
697675

@@ -794,9 +772,6 @@ msgstr "Land"
794772
msgid "Create"
795773
msgstr "Opret"
796774

797-
msgid "Create <0>{search}</0>"
798-
msgstr "Opret <0>{search}</0>"
799-
800775
msgid "Create new account"
801776
msgstr "Opret ny konto"
802777

@@ -893,9 +868,6 @@ msgstr "Afslå"
893868
msgid "Declining..."
894869
msgstr "Afslår..."
895870

896-
msgid "Decrease"
897-
msgstr "Formindsk"
898-
899871
msgid "Default"
900872
msgstr "Standard"
901873

@@ -1023,9 +995,6 @@ msgstr "Slip et billede i et vilkårligt kort — AspectRatio holder feltet fast
1023995
msgid "Drop anywhere to add to the gallery"
1024996
msgstr "Slip et vilkårligt sted for at tilføje til galleriet"
1025997

1026-
msgid "Drop files here, or click to browse"
1027-
msgstr "Slip filer her, eller klik for at vælge"
1028-
1029998
msgid "Drop your filter controls here. The sheet handles scrolling and dismissal."
1030999
msgstr "Placér dine filterkontroller her. Sheet håndterer scrolling og lukning."
10311000

@@ -1266,12 +1235,6 @@ msgstr "Gå til kontoindstillinger"
12661235
msgid "Go to home"
12671236
msgstr "Gå til forsiden"
12681237

1269-
msgid "Go to next page"
1270-
msgstr "Gå til næste side"
1271-
1272-
msgid "Go to previous page"
1273-
msgstr "Gå til forrige side"
1274-
12751238
msgid "Google"
12761239
msgstr "Google"
12771240

@@ -1323,9 +1286,6 @@ msgstr "I selve appen er sidemenuen fixed-positioneret, gemmer sin tilstand og b
13231286
msgid "Include cooking notes"
13241287
msgstr "Inkluder tilberedningsnoter"
13251288

1326-
msgid "Increase"
1327-
msgstr "Forøg"
1328-
13291289
msgid "Indeterminate"
13301290
msgstr "Ubestemt"
13311291

@@ -1524,9 +1484,6 @@ msgstr "Linkvarianter"
15241484
msgid "LinkedIn"
15251485
msgstr "LinkedIn"
15261486

1527-
msgid "Loading"
1528-
msgstr ""
1529-
15301487
msgid "Loading..."
15311488
msgstr "Indlæser..."
15321489

@@ -1647,9 +1604,6 @@ msgstr "Midte"
16471604
msgid "Mobile"
16481605
msgstr "Mobil"
16491606

1650-
msgid "Mobile navigation menu"
1651-
msgstr "Mobilnavigationsmenu"
1652-
16531607
msgid "Mobile-first sheet with a drag handle and swipe-to-dismiss. Reach for it when content is short and the user should be able to flick it away. Left and right drawers are narrow by default; top and bottom span the full width unless you constrain DrawerContent with mx-auto and max-w-*."
16541608
msgstr "Mobile-first panel med trækhåndtag og swipe-to-dismiss. Brug det når indholdet er kort og brugeren skal kunne flicke det væk. Venstre- og højre-drawers er smalle som standard; top og bund spænder fuld bredde med mindre du begrænser DrawerContent med mx-auto og max-w-*."
16551609

@@ -1668,9 +1622,6 @@ msgstr "Flere eksportmuligheder"
16681622
msgid "More merge options"
16691623
msgstr "Flere fletmuligheder"
16701624

1671-
msgid "More pages"
1672-
msgstr "Flere sider"
1673-
16741625
msgid "More save options"
16751626
msgstr "Flere gemgemuligheder"
16761627

@@ -1812,15 +1763,9 @@ msgstr "Kun ejere kan ændre brugerroller"
18121763
msgid "Only trusted personnel access data through Azure AD authentication"
18131764
msgstr "Kun betroet personale får adgang til data gennem Azure AD autentificering"
18141765

1815-
msgid "Open calendar"
1816-
msgstr ""
1817-
18181766
msgid "Open command palette"
18191767
msgstr "Åbn kommandopalette"
18201768

1821-
msgid "Open navigation menu"
1822-
msgstr "Åbn navigationsmenu"
1823-
18241769
msgid "Open side pane"
18251770
msgstr "Åbn sidepanel"
18261771

@@ -1872,9 +1817,6 @@ msgstr "Siden blev ikke fundet"
18721817
msgid "Page Views"
18731818
msgstr "Sidevisninger"
18741819

1875-
msgid "Pagination"
1876-
msgstr "Paginering"
1877-
18781820
msgid "Palak paneer"
18791821
msgstr "Palak paneer"
18801822

@@ -2192,9 +2134,6 @@ msgstr "Justerbar app-skal"
21922134
msgid "Resizable panels"
21932135
msgstr "Justerbare paneler"
21942136

2195-
msgid "Resize sidebar"
2196-
msgstr "Ændr bredde på sidepanel"
2197-
21982137
msgid "Responsive layout"
21992138
msgstr "Responsivt layout"
22002139

@@ -2343,9 +2282,6 @@ msgstr "Vælg land"
23432282
msgid "Select dates"
23442283
msgstr "Vælg datoer"
23452284

2346-
msgid "Select time zone"
2347-
msgstr "Vælg tidszone"
2348-
23492285
msgid "Select with groups"
23502286
msgstr "Vælg med grupper"
23512287

@@ -2424,9 +2360,6 @@ msgstr "Vis detaljer"
24242360
msgid "Show dismissable banner"
24252361
msgstr "Vis afliveligt banner"
24262362

2427-
msgid "Show more"
2428-
msgstr "Vis flere"
2429-
24302363
msgid "Show search filters"
24312364
msgstr "Vis søgefiltre"
24322365

@@ -2484,9 +2417,6 @@ msgstr "Enkelt-udfoldning vs multi-udfoldning"
24842417
msgid "Skeleton"
24852418
msgstr "Skelet"
24862419

2487-
msgid "Skip to main content"
2488-
msgstr "Spring til hovedindhold"
2489-
24902420
msgid "SLA"
24912421
msgstr "SLA"
24922422

@@ -2722,9 +2652,6 @@ msgstr "Titel"
27222652
msgid "To delete your account, please contact our support team."
27232653
msgstr "For at slette din konto bedes du kontakte vores supportteam."
27242654

2725-
msgid "Today"
2726-
msgstr "I dag"
2727-
27282655
msgid "Toggle bold"
27292656
msgstr "Skift fed"
27302657

@@ -2737,18 +2664,12 @@ msgstr "Skiftegruppe"
27372664
msgid "Toggle italic"
27382665
msgstr "Skift kursiv"
27392666

2740-
msgid "Toggle sidebar"
2741-
msgstr "Skift sidepanel"
2742-
27432667
msgid "Toggle underline"
27442668
msgstr "Skift understregning"
27452669

27462670
msgid "Tom yum soup"
27472671
msgstr "Tom yum-suppe"
27482672

2749-
msgid "Tomorrow"
2750-
msgstr "I morgen"
2751-
27522673
msgid "Tonkotsu ramen"
27532674
msgstr "Tonkotsu ramen"
27542675

0 commit comments

Comments
 (0)