@astryxdesign/cli 0.1.6-canary.ba37404 → 0.1.6-canary.d63070f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.6-canary.ba37404",
3
+ "version": "0.1.6-canary.d63070f",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -75,10 +75,10 @@
75
75
  "zod": "^4.4.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@astryxdesign/charts": "0.1.6-canary.ba37404",
79
- "@astryxdesign/core": "0.1.6-canary.ba37404",
80
- "@astryxdesign/lab": "0.1.6-canary.ba37404",
81
- "@astryxdesign/theme-neutral": "0.1.6-canary.ba37404",
78
+ "@astryxdesign/charts": "0.1.6-canary.d63070f",
79
+ "@astryxdesign/core": "0.1.6-canary.d63070f",
80
+ "@astryxdesign/lab": "0.1.6-canary.d63070f",
81
+ "@astryxdesign/theme-neutral": "0.1.6-canary.d63070f",
82
82
  "gpt-tokenizer": "^3.4.0"
83
83
  },
84
84
  "peerDependenciesMeta": {
@@ -96,10 +96,10 @@
96
96
  }
97
97
  },
98
98
  "devDependencies": {
99
- "@astryxdesign/charts": "0.1.6-canary.ba37404",
100
- "@astryxdesign/core": "0.1.6-canary.ba37404",
101
- "@astryxdesign/lab": "0.1.6-canary.ba37404",
102
- "@astryxdesign/theme-neutral": "0.1.6-canary.ba37404",
99
+ "@astryxdesign/charts": "0.1.6-canary.d63070f",
100
+ "@astryxdesign/core": "0.1.6-canary.d63070f",
101
+ "@astryxdesign/lab": "0.1.6-canary.d63070f",
102
+ "@astryxdesign/theme-neutral": "0.1.6-canary.d63070f",
103
103
  "gpt-tokenizer": "^3.4.0"
104
104
  },
105
105
  "scripts": {
@@ -1,243 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /** @type {import('../../core/src/docs-types').ReferenceDoc} */
4
-
5
- export const docs = {
6
- name: 'internationalization',
7
- title: 'Internationalization',
8
- category: 'guide',
9
- description:
10
- 'Localize astryx component strings, provide translation catalogs, override default text, coexist with your own i18n library, swap languages at runtime, and test translations with the pseudo locale.',
11
-
12
- sections: [
13
- {
14
- title: 'Quick Start',
15
- category: 'guide',
16
- content: [
17
- {
18
- type: 'prose',
19
- text: 'Internationalization ships with `@astryxdesign/core`. There is nothing to install. Wrap your app in `<InternationalizationProvider>` and set a `locale` — astryx components pick up localized strings automatically.',
20
- },
21
- {
22
- type: 'code',
23
- lang: 'tsx',
24
- label: 'Wrap your app',
25
- code: `import {InternationalizationProvider} from '@astryxdesign/core';
26
-
27
- function App() {
28
- return (
29
- <InternationalizationProvider locale="en">
30
- <YourApp />
31
- </InternationalizationProvider>
32
- );
33
- }`,
34
- },
35
- {
36
- type: 'code',
37
- lang: 'tsx',
38
- label: 'Read strings inside a component',
39
- code: `import {useTranslator} from '@astryxdesign/core';
40
-
41
- function SaveButton() {
42
- const t = useTranslator();
43
- return <button>{t('@myapp.actions.save')}</button>;
44
- }`,
45
- },
46
- {
47
- type: 'prose',
48
- text: 'The hook is available to consumer components too, but using it is entirely optional — many teams keep their app strings on their existing i18n library (react-intl, i18next, next-intl, LinguiJS) and only use `useTranslator` when reading astryx keys. If you do route your own strings through it, we recommend namespacing them (`@myapp.*` or your npm scope) to keep them separated from `@astryx.*`, but this is a convention, not a requirement — the resolver treats every key as an opaque string.',
49
- },
50
- {
51
- type: 'prose',
52
- text: "Astryx ships translations only for English today. First-party translations for other locales are on the roadmap and coming soon — track https://github.com/facebook/astryx/issues/3641. In the meantime, if you want astryx UI translated into another locale, you can ship your own catalog through the `messages` prop (covered in the next section). If you're using `useTranslator` for your own strings, you'll want to ship your own catalog either way — astryx only carries the fallback for `@astryx.*` keys, not the ones you author.",
53
- },
54
- ],
55
- },
56
- {
57
- title: 'Providing locale catalogs',
58
- category: 'guide',
59
- content: [
60
- {
61
- type: 'prose',
62
- text: 'Astryx bundles only the English catalog today. To render in any other locale, provide a translation catalog through the `messages` prop and set `locale` accordingly. This matches how MUI, Ant Design, and AG Grid work — the consumer app supplies the catalogs it actually needs so unused translations stay out of the bundle.',
63
- },
64
- {
65
- type: 'code',
66
- lang: 'tsx',
67
- label: 'Add French',
68
- code: `import {InternationalizationProvider} from '@astryxdesign/core';
69
- import fr from './locales/astryx/fr.json';
70
-
71
- <InternationalizationProvider locale="fr" messages={{fr}}>
72
- <App />
73
- </InternationalizationProvider>;`,
74
- },
75
- {
76
- type: 'prose',
77
- text: "See `@astryxdesign/core/locales/en.json` for the full inventory of keys to translate. Copy it as the starting point — every key you translate replaces the English default; anything you omit falls back through the locale chain to English (e.g. `pt-BR` walks to `pt` then to shipped `en`), so a partial translation renders as a mix rather than empty text or raw key names.",
78
- },
79
- {
80
- type: 'prose',
81
- text: 'A community-maintained set of astryx translations is on the roadmap but not shipped yet. For now, consumer apps that ship in multiple languages own their astryx catalogs alongside their app catalogs. Contributions to a first-party set are welcome — track discussion at https://github.com/facebook/astryx/issues/3641.',
82
- },
83
- ],
84
- },
85
- {
86
- title: "Overriding astryx's default text",
87
- category: 'guide',
88
- content: [
89
- {
90
- type: 'prose',
91
- text: 'Use `overrides` to change individual strings without shipping a full catalog. Overrides are keyed by locale and merged on top of the built-in and user-supplied catalogs.',
92
- },
93
- {
94
- type: 'code',
95
- lang: 'tsx',
96
- label: 'Change one string in English',
97
- code: `<InternationalizationProvider
98
- locale="en"
99
- overrides={{en: {'@astryx.pagination.next': 'Next →'}}}
100
- >
101
- <App />
102
- </InternationalizationProvider>`,
103
- },
104
- {
105
- type: 'prose',
106
- text: 'Overrides win over both bundled English and any `messages` catalog for the same key. Use them for brand voice tweaks or one-off wording changes.',
107
- },
108
- ],
109
- },
110
- {
111
- title: 'Using astryx with your own i18n library',
112
- category: 'guide',
113
- content: [
114
- {
115
- type: 'prose',
116
- text: "Astryx components render astryx strings through astryx's provider. Consumer components render consumer strings through whatever i18n library you already use — react-intl, i18next, next-intl, LinguiJS, and so on. The two systems coexist and read from the same source of truth for the active locale.",
117
- },
118
- {
119
- type: 'code',
120
- lang: 'tsx',
121
- label: 'Astryx + react-intl side by side',
122
- code: `import {InternationalizationProvider} from '@astryxdesign/core';
123
- import {Selector} from '@astryxdesign/core/Selector';
124
- import {Button} from '@astryxdesign/core/Button';
125
- import {FormattedMessage, IntlProvider, useIntl} from 'react-intl';
126
- import astryxFr from './locales/astryx/fr.json'; // astryx's UI, in French
127
- import appFr from './locales/app/fr.json'; // your app strings, in French
128
-
129
- function Pricing() {
130
- // Consumer strings — resolved by react-intl.
131
- const intl = useIntl();
132
-
133
- return (
134
- <section>
135
- <h1><FormattedMessage id="pricing.heading" /></h1>
136
-
137
- {/* Astryx Selector — trigger placeholder, search-box placeholder,
138
- clear-button aria-label all resolved by
139
- <InternationalizationProvider>. Options come from react-intl. */}
140
- <Selector
141
- label={intl.formatMessage({id: 'pricing.region.label'})}
142
- options={[
143
- {value: 'na', label: intl.formatMessage({id: 'pricing.region.na'})},
144
- {value: 'eu', label: intl.formatMessage({id: 'pricing.region.eu'})},
145
- ]}
146
- hasSearch
147
- hasClear
148
- />
149
-
150
- <Button label={intl.formatMessage({id: 'pricing.cta.subscribe'})} />
151
- </section>
152
- );
153
- }
154
-
155
- export default function App() {
156
- return (
157
- // Same locale, two providers reading their own catalogs.
158
- <IntlProvider locale="fr" messages={appFr}>
159
- <InternationalizationProvider locale="fr" messages={{fr: astryxFr}}>
160
- <Pricing />
161
- </InternationalizationProvider>
162
- </IntlProvider>
163
- );
164
- }`,
165
- },
166
- {
167
- type: 'prose',
168
- text: 'Keep the two providers in sync on locale, and each library owns its own catalog. Astryx never sees your app strings, and your i18n library never sees astryx internals. Runtime locale swap works the same way — re-render both providers with a new `locale` prop and the whole tree updates live.',
169
- },
170
- {
171
- type: 'prose',
172
- text: "Single-catalog usage — where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider — is on the roadmap via a `Translator` adapter. Track https://github.com/facebook/astryx/issues/4029. For now, run the two providers side by side as shown above.",
173
- },
174
- ],
175
- },
176
- {
177
- title: 'Runtime language swap',
178
- category: 'guide',
179
- content: [
180
- {
181
- type: 'prose',
182
- text: 'Re-render `<InternationalizationProvider>` with a new `locale` prop and every astryx string updates live. No reload, no separate API call.',
183
- },
184
- {
185
- type: 'code',
186
- lang: 'tsx',
187
- label: 'Toggle between locales',
188
- code: `const [locale, setLocale] = useState<'en' | 'fr'>('en');
189
-
190
- <InternationalizationProvider locale={locale} messages={{fr}}>
191
- <Button
192
- label={locale === 'en' ? 'Français' : 'English'}
193
- onClick={() => setLocale(l => (l === 'en' ? 'fr' : 'en'))}
194
- />
195
- <App />
196
- </InternationalizationProvider>;`,
197
- },
198
- {
199
- type: 'prose',
200
- text: "Persisting the user's choice (localStorage, cookie, URL segment, account setting) is up to the consumer. Astryx reads whatever `locale` you pass in.",
201
- },
202
- ],
203
- },
204
- {
205
- title: 'Testing your translations',
206
- category: 'guide',
207
- content: [
208
- {
209
- type: 'prose',
210
- text: 'Astryx generates a `pseudo` locale that wraps every string in `⟦…⟧` and replaces letters with accented look-alikes. Switching to it in development instantly reveals any astryx string that isn\'t going through the translator, plus any layout that breaks under longer text.',
211
- },
212
- {
213
- type: 'code',
214
- lang: 'tsx',
215
- label: 'Turn on pseudo-localization',
216
- code: `import pseudo from '@astryxdesign/core/locales/pseudo.json';
217
-
218
- <InternationalizationProvider locale="pseudo" messages={{pseudo}}>
219
- <App />
220
- </InternationalizationProvider>;`,
221
- },
222
- {
223
- type: 'prose',
224
- text: 'Any bare English text you still see on screen is a hardcoded string that needs to be routed through `useTranslator`.',
225
- },
226
- {
227
- type: 'prose',
228
- text: "Pseudoloc also has a subtle caveat worth knowing: the pseudo catalog is complete (astryx generates it from every shipped key), so a component using an astryx-shipped key will always render its pseudo version. Your handwritten translation catalogs, on the other hand, only cover the keys you translated — anything missing falls back to English. That means \"looks perfect in pseudo\" is not the same guarantee as \"looks perfect in French.\" Check each real locale by hand for coverage gaps.",
229
- },
230
- ],
231
- },
232
- {
233
- title: 'For contributors',
234
- category: 'guide',
235
- content: [
236
- {
237
- type: 'prose',
238
- text: "Astryx's own strings live in `packages/core/locales/en.json`. New user-facing strings must go through `useTranslator` — this is enforced by the `@astryx/no-hardcoded-i18n-string` ESLint rule. See the AI contribution guide for the alias-and-resolve pattern used when adding new keys.",
239
- },
240
- ],
241
- },
242
- ],
243
- };