Skip to content

Commit 1712f58

Browse files
committed
docs(cli): the i18n guide keeps to what a caller can use
The shipped RTL and testing guide had gained the internal useComponentTranslator pattern with relative imports into core source and the contributor check command, none of which a caller of the package can reach. The page now says what holds for a caller: components carry their own strings, so an app bundles only the strings of the components it renders, and useTranslator() resolves every @AstryX.* key; the contributor pattern stays in CONTRIBUTING.md.
1 parent 575718a commit 1712f58

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

‎packages/cli/assets/docs/tree/i18n-rtl-and-testing.doc.mjs‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ export const docs = {
1111
type: 'generic',
1212
name: 'i18n-rtl-and-testing',
1313
title: 'RTL & Testing',
14-
placement: {
15-
parent: 'namespace:internationalization',
16-
slot: 'guides',
17-
order: 30,
18-
},
14+
placement: {parent: 'namespace:internationalization', slot: 'guides', order: 30},
1915
category: 'guide',
2016
description:
2117
'Text direction (RTL), pseudo-locale testing, and contributor guidance for developers and translators.',
@@ -126,23 +122,22 @@ import pseudo from '@astryxdesign/core/locales/pseudo.generated.js';
126122
},
127123
{
128124
type: 'prose',
129-
text: "Astryx component authors read strings with `useComponentTranslator(<slice>)` rather than hardcoding user-facing text. The slice is the component's own namespace of the English catalog, so an app bundles only the strings of the components it renders.",
125+
text: "Astryx components read their own strings from the English catalog rather than hardcoding them, so an app bundles only the strings of the components it renders. Your own code reads any `@astryx.*` key with `useTranslator()`:",
130126
},
131127
{
132128
type: 'code',
133129
lang: 'tsx',
134130
label: 'Read an astryx string',
135-
code: `import {useComponentTranslator} from '../i18n/useComponentTranslator';
136-
import saveButtonMessages from '../i18n/generated-locales/en/saveButton.generated';
131+
code: `import {useTranslator} from '@astryxdesign/core/i18n';
137132
138133
function SaveButton() {
139-
const t = useComponentTranslator(saveButtonMessages);
140-
return <button>{t('@astryx.saveButton.save')}</button>;
134+
const t = useTranslator();
135+
return <button>{t('@astryx.actions.save')}</button>;
141136
}`,
142137
},
143138
{
144139
type: 'prose',
145-
text: "Astryx's own strings live in `packages/core/locales/en.json`, keyed `@astryx.<namespace>.<name>`. New user-facing strings must go through the translator; the `@astryx/no-hardcoded-i18n-string` ESLint rule enforces that, and `pnpm check:i18n-catalog` fails a key read outside the file's slice. `useTranslator()` from `@astryxdesign/core/i18n` is the consumer-facing hook and carries the whole catalog. See the AI contribution guide for the alias-and-resolve pattern used when adding new keys.",
140+
text: "Astryx's own strings live in `packages/core/locales/en.json`, keyed `@astryx.<namespace>.<name>`. The contributing guide covers how a core component reads its strings, the `@astryx/no-hardcoded-i18n-string` ESLint rule and the alias-and-resolve pattern used when adding new keys.",
146141
},
147142
{
148143
type: 'prose',

0 commit comments

Comments
 (0)