@primereact/mcp 11.0.0 → 11.1.0

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.
Files changed (32) hide show
  1. package/data/llms/headless/components/sidebar/api.json +1029 -54
  2. package/data/llms/headless/guides/misc/internationalization.md +282 -0
  3. package/data/llms/headless/guides/misc/locale.md +280 -0
  4. package/data/llms/llms-full.txt +9822 -1377
  5. package/data/llms/llms.txt +15 -0
  6. package/data/llms/primitive/components/sidebar/api.json +127 -33
  7. package/data/llms/primitive/guides/migration/updating-to-v11.md +2219 -0
  8. package/data/llms/primitive/guides/misc/internationalization.md +287 -0
  9. package/data/llms/primitive/guides/misc/locale.md +280 -0
  10. package/data/llms/styled/add-ons/designer/ci.md +273 -0
  11. package/data/llms/styled/add-ons/designer/guide.md +99 -0
  12. package/data/llms/styled/add-ons/designer/overview.md +194 -0
  13. package/data/llms/styled/add-ons/uikit/guide/v3.md +181 -0
  14. package/data/llms/styled/add-ons/uikit/guide/v4.md +163 -0
  15. package/data/llms/styled/add-ons/uikit/overview.md +204 -0
  16. package/data/llms/styled/components/datatable.md +8 -5
  17. package/data/llms/styled/components/menu.md +39 -41
  18. package/data/llms/styled/guides/configuration.md +198 -0
  19. package/data/llms/styled/guides/form/formik.md +448 -0
  20. package/data/llms/styled/guides/form/react-hook-form.md +503 -0
  21. package/data/llms/styled/guides/form/tanstack.md +502 -0
  22. package/data/llms/styled/guides/migration/updating-to-v11.md +2219 -0
  23. package/data/llms/styled/guides/misc/internationalization.md +379 -0
  24. package/data/llms/styled/guides/misc/locale.md +280 -0
  25. package/data/llms/tailwind/components/menu.md +5 -5
  26. package/data/llms/tailwind/components/tooltip.md +4 -13
  27. package/data/llms/tailwind/guides/misc/internationalization.md +287 -0
  28. package/data/llms/tailwind/guides/misc/locale.md +280 -0
  29. package/data/manifest.json +339 -24
  30. package/data/mcp-data.json +263 -8
  31. package/dist/index.js +1 -1
  32. package/package.json +1 -1
@@ -0,0 +1,282 @@
1
+ # Internationalization and Localization
2
+
3
+ Translating component messages and configuring regional settings such as date formats and the first day of the week.
4
+
5
+ ## Overview
6
+
7
+ Components ship with a set of built-in messages such as filter operator labels, month names and ARIA descriptions. These messages live in a locale registry that is shared across PrimeReact, PrimeVue and PrimeNG through the `@primeuix/locale` package, and are re-exported from `@primereact/core/locale`.
8
+
9
+ English is registered by default, so no configuration is required until another language is needed.
10
+
11
+ Setting a language is enough for components to pick it up. No per-component prop is involved. A DatePicker then renders its month and day names in that language, with the first day of the week adjusted to match.
12
+
13
+ ```jsx
14
+ import { PrimeReactProvider } from '@primereact/core';
15
+ import { de } from 'primelocale/js/de.js';
16
+
17
+ <PrimeReactProvider locale="de" locales={{ de }}>
18
+ <App />
19
+ </PrimeReactProvider>;
20
+ ```
21
+
22
+ ## Import
23
+
24
+ ```js
25
+ import { $t, $l, defineLocale, updateLocale, useLocale, Locale, LocaleService, en } from '@primereact/core/locale';
26
+ ```
27
+
28
+ ## Setting the Language
29
+
30
+ `Locale.use` selects the active language. Every component reading a message re-renders when it changes, so this works both at startup and later in response to a language switcher.
31
+
32
+ ```js
33
+ import { Locale } from '@primereact/core/locale';
34
+
35
+ Locale.use('de');
36
+ ```
37
+
38
+ Only `en` is built in, so any other language has to be registered first. See [Adding a Language](#adding-a-language) below.
39
+
40
+ `PrimeReactProvider` also accepts a `locale` prop, which sets the initial language for the components beneath it.
41
+
42
+ ```jsx
43
+ import { PrimeReactProvider } from '@primereact/core';
44
+
45
+ <PrimeReactProvider locale="de">
46
+ <App />
47
+ </PrimeReactProvider>;
48
+ ```
49
+
50
+ ## Adding a Language
51
+
52
+ `defineLocale` registers a new language.
53
+
54
+ ```js
55
+ import { defineLocale, Locale } from '@primereact/core/locale';
56
+
57
+ defineLocale('es', {
58
+ clear: 'Limpiar',
59
+ apply: 'Aplicar',
60
+ accept: 'Sí',
61
+ reject: 'No',
62
+ dayNames: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
63
+ dayNamesShort: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb'],
64
+ dayNamesMin: ['D', 'L', 'M', 'X', 'J', 'V', 'S'],
65
+ monthNames: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],
66
+ monthNamesShort: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic']
67
+ });
68
+
69
+ Locale.use('es');
70
+ ```
71
+
72
+ A registered language must be complete. Keys that are left out resolve to `undefined` rather than falling back to English, which renders as an empty label. The practical approach is to spread the built-in English messages and override from there:
73
+
74
+ ```js
75
+ import { defineLocale, en } from '@primereact/core/locale';
76
+
77
+ defineLocale('es', {
78
+ ...en,
79
+ clear: 'Limpiar',
80
+ apply: 'Aplicar'
81
+ });
82
+ ```
83
+
84
+ The `en` object holds the built-in English messages and is exported for exactly this purpose. Ready-made translations from [PrimeLocale](#ready-made-translations) already cover every key, so spreading is only needed for hand-written translations.
85
+
86
+ The provider accepts a `locales` map, which registers languages and selects one in a single step. Anything listed here is registered before `locale` is applied.
87
+
88
+ ```jsx
89
+ import { PrimeReactProvider } from '@primereact/core';
90
+
91
+ <PrimeReactProvider locale="es" locales={{ es: spanishMessages }}>
92
+ <App />
93
+ </PrimeReactProvider>;
94
+ ```
95
+
96
+ ## Updating an Existing Language
97
+
98
+ `updateLocale` merges new values into a language that is already registered, leaving the remaining keys untouched. It is useful for overriding a handful of labels without redefining a full translation.
99
+
100
+ ```js
101
+ import { updateLocale } from '@primereact/core/locale';
102
+
103
+ updateLocale('en', {
104
+ clear: 'Reset',
105
+ apply: 'Confirm'
106
+ });
107
+ ```
108
+
109
+ If the language does not exist yet, `updateLocale` registers it, behaving like `defineLocale`.
110
+
111
+ ## Reading Messages
112
+
113
+ ### In Components
114
+
115
+ `useLocale` is the React hook for reading the active locale. It re-renders the calling component when the language changes.
116
+
117
+ ```jsx
118
+ import { useLocale } from '@primereact/core/locale';
119
+
120
+ function ClearFilterButton({ onClear }) {
121
+ const { t } = useLocale();
122
+
123
+ return <button onClick={onClear}>{t('clear')}</button>;
124
+ }
125
+ ```
126
+
127
+ | Field | Description |
128
+ | ---------- | --------------------------------------------- |
129
+ | `lang` | Active language code, such as `en` or `de`. |
130
+ | `messages` | Full message object of the active language. |
131
+ | `t` | Translates a key against the active language. |
132
+
133
+ Re-rendering on a language change relies on the context published by `PrimeReactProvider`, which applications normally have at their root. A component rendered outside any provider still reads the correct messages on first render, but will not update when the language changes later.
134
+
135
+ ### Outside Components
136
+
137
+ `$t` performs the same lookup without a React context, which suits utilities, event handlers and module-level code.
138
+
139
+ ```js
140
+ import { $t } from '@primereact/core/locale';
141
+
142
+ $t('clear'); // 'Clear'
143
+ ```
144
+
145
+ Nested keys use dot notation.
146
+
147
+ ```js
148
+ $t('aria.selectRow'); // 'Row Selected'
149
+ ```
150
+
151
+ Messages containing placeholders accept replacement values. Positional placeholders such as `{0}` are filled from the argument order, while named ones are filled from an object.
152
+
153
+ ```js
154
+ $t('searchMessage', 5); // '5 results are available'
155
+ $t('selectionMessage', 3); // '3 items selected'
156
+ $t('aria.stars', { star: 4 }); // '4 stars'
157
+ ```
158
+
159
+ ## Reacting to Language Changes
160
+
161
+ Language changes emit a `locale:change` event. Components handle this automatically through `useLocale`; the event is only needed for code living outside React, such as syncing a third-party library.
162
+
163
+ ```js
164
+ import { LocaleService } from '@primereact/core/locale';
165
+
166
+ const onChange = ({ lang }) => console.log('Language is now', lang);
167
+
168
+ LocaleService.on('locale:change', onChange);
169
+
170
+ // remove the listener when it is no longer needed
171
+ LocaleService.off('locale:change', onChange);
172
+ ```
173
+
174
+ ## Inspecting the Registry
175
+
176
+ `$l` returns a facade over the registry, which helps when building a language switcher.
177
+
178
+ ```js
179
+ import { $l } from '@primereact/core/locale';
180
+
181
+ $l().langs; // ['en', 'es']
182
+ $l().get('es'); // message object of the Spanish locale
183
+ ```
184
+
185
+ ## Message Keys
186
+
187
+ These components read their labels from the active language:
188
+
189
+ | Component | Keys |
190
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
191
+ | DatePicker | `dayNames`, `dayNamesShort`, `dayNamesMin`, `monthNames`, `monthNamesShort`, `today`, `weekHeader`, `clear`, `am`, `pm`, `firstDayOfWeek`, `dateFormat` |
192
+ | FileUpload | `fileSizeTypes` |
193
+ | Paginator | `aria.firstPageLabel`, `aria.prevPageLabel`, `aria.nextPageLabel`, `aria.lastPageLabel`, `aria.pageLabel` |
194
+ | Sidebar | `aria.toggleSidebar` |
195
+
196
+ The registry holds a larger set covering filter operators, password strength labels, empty-state messages and the remaining `aria` labels. Those are reserved for components that do not consume them yet, so translating them has no visible effect today.
197
+
198
+ Not every entry is a string. `firstDayOfWeek` is a number, `showMonthAfterYear` is a boolean, and `dayNames`, `monthNames` and `fileSizeTypes` are arrays. `searchMessage` and similar entries carry a `{0}` placeholder.
199
+
200
+ The full set with default English values is exported as `en`, which can also be inspected at runtime:
201
+
202
+ ```js
203
+ import { en } from '@primereact/core/locale';
204
+
205
+ Object.keys(en); // every top-level key
206
+ ```
207
+
208
+ ## Ready-Made Translations
209
+
210
+ Writing a translation from scratch is rarely necessary. The community maintained [PrimeLocale](https://github.com/primefaces/primelocale) repository publishes complete translations for 70+ languages, shared across all Prime libraries. Each file covers every built-in message key, so nothing is left resolving to `undefined`.
211
+
212
+ ### Copying a File
213
+
214
+ Grab the JSON file for the desired language from the repository, for example `es.json`, and place it in the project.
215
+
216
+ Each file wraps its messages in a single key named after the language:
217
+
218
+ ```json
219
+ {
220
+ "es": {
221
+ "clear": "Limpiar",
222
+ "apply": "Aplicar",
223
+ "aria": { "selectRow": "Seleccionar fila" }
224
+ }
225
+ }
226
+ ```
227
+
228
+ That wrapper has to be unwrapped before registering, otherwise every lookup resolves to `undefined`:
229
+
230
+ ```js
231
+ import { defineLocale, Locale } from '@primereact/core/locale';
232
+ import es from './locales/es.json';
233
+
234
+ defineLocale('es', es.es);
235
+ Locale.use('es');
236
+ ```
237
+
238
+ The same unwrapping applies when the language is registered through the provider:
239
+
240
+ ```jsx
241
+ import { PrimeReactProvider } from '@primereact/core';
242
+ import es from './locales/es.json';
243
+
244
+ <PrimeReactProvider locale="es" locales={{ es: es.es }}>
245
+ <App />
246
+ </PrimeReactProvider>;
247
+ ```
248
+
249
+ ### Installing the Package
250
+
251
+ The translations are also published to npm, which avoids maintaining copies by hand.
252
+
253
+ ```bash
254
+ npm install primelocale
255
+ ```
256
+
257
+ ```js
258
+ import { defineLocale, Locale } from '@primereact/core/locale';
259
+ import { es } from 'primelocale/js/es.js';
260
+
261
+ defineLocale('es', es);
262
+ Locale.use('es');
263
+ ```
264
+
265
+ The package entry points export the messages directly, so no unwrapping is needed there.
266
+
267
+ Regional variants are named with an underscore in the package and a hyphen in the JSON files. Brazilian Portuguese is `primelocale/js/pt_BR.js` when imported and `pt-BR.json` when copied.
268
+
269
+ ### Adjusting a Translation
270
+
271
+ A ready-made translation can be tuned without editing the file, by layering overrides on top of it:
272
+
273
+ ```js
274
+ defineLocale('es', es.es);
275
+ updateLocale('es', { clear: 'Borrar' });
276
+ ```
277
+
278
+ Contributions of new languages and corrections are welcome in the PrimeLocale repository, and benefit every Prime library at once.
279
+
280
+ ## Coming from v10
281
+
282
+ The locale helpers from `primereact/api` were replaced. The [migration guide](/docs/primitive/guides/migration/updating-to-v11) maps each one to its replacement.
@@ -0,0 +1,280 @@
1
+ # Internationalization and Localization
2
+
3
+ Translating component messages and configuring regional settings such as date formats and the first day of the week.
4
+
5
+ ## Overview
6
+
7
+ Components ship with a set of built-in messages such as filter operator labels, month names and ARIA descriptions. These messages live in a locale registry that is shared across PrimeReact, PrimeVue and PrimeNG through the `@primeuix/locale` package, and are re-exported from `@primereact/core/locale`.
8
+
9
+ English is registered by default, so no configuration is required until another language is needed.
10
+
11
+ ## Import
12
+
13
+ ```js
14
+ import { $t, $l, defineLocale, updateLocale, useLocale, Locale, LocaleService, en } from '@primereact/core/locale';
15
+ ```
16
+
17
+ ## Setting the Language
18
+
19
+ `Locale.use` selects the active language. Every component reading a message re-renders when it changes, so this works both at startup and later in response to a language switcher.
20
+
21
+ ```js
22
+ import { Locale } from '@primereact/core/locale';
23
+
24
+ Locale.use('de');
25
+ ```
26
+
27
+ Only `en` is built in, so any other language has to be registered first — see [Adding a Language](#adding-a-language) below.
28
+
29
+ `PrimeReactProvider` also accepts a `locale` prop, which sets the initial language for the components beneath it.
30
+
31
+ ```jsx
32
+ import { PrimeReactProvider } from '@primereact/core';
33
+
34
+ <PrimeReactProvider locale="de">
35
+ <App />
36
+ </PrimeReactProvider>;
37
+ ```
38
+
39
+ ## Adding a Language
40
+
41
+ `defineLocale` registers a new language.
42
+
43
+ ```js
44
+ import { defineLocale, Locale } from '@primereact/core/locale';
45
+
46
+ defineLocale('es', {
47
+ clear: 'Limpiar',
48
+ apply: 'Aplicar',
49
+ accept: 'Sí',
50
+ reject: 'No',
51
+ dayNames: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
52
+ dayNamesShort: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb'],
53
+ dayNamesMin: ['D', 'L', 'M', 'X', 'J', 'V', 'S'],
54
+ monthNames: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],
55
+ monthNamesShort: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic']
56
+ });
57
+
58
+ Locale.use('es');
59
+ ```
60
+
61
+ A registered language must be complete. Keys that are left out resolve to `undefined` rather than falling back to English, which renders as an empty label. The practical approach is to spread the built-in English messages and override from there:
62
+
63
+ ```js
64
+ import { defineLocale, en } from '@primereact/core/locale';
65
+
66
+ defineLocale('es', {
67
+ ...en,
68
+ clear: 'Limpiar',
69
+ apply: 'Aplicar'
70
+ });
71
+ ```
72
+
73
+ The `en` object holds the built-in English messages and is exported for exactly this purpose. Ready-made translations from [PrimeLocale](#ready-made-translations) already cover every key, so spreading is only needed for hand-written translations.
74
+
75
+ The provider accepts a `locales` map, which registers languages and selects one in a single step. Anything listed here is registered before `locale` is applied.
76
+
77
+ ```jsx
78
+ import { PrimeReactProvider } from '@primereact/core';
79
+
80
+ <PrimeReactProvider locale="es" locales={{ es: spanishMessages }}>
81
+ <App />
82
+ </PrimeReactProvider>;
83
+ ```
84
+
85
+ ## Updating an Existing Language
86
+
87
+ `updateLocale` merges new values into a language that is already registered, leaving the remaining keys untouched. It is useful for overriding a handful of labels without redefining a full translation.
88
+
89
+ ```js
90
+ import { updateLocale } from '@primereact/core/locale';
91
+
92
+ updateLocale('en', {
93
+ clear: 'Reset',
94
+ apply: 'Confirm'
95
+ });
96
+ ```
97
+
98
+ If the language does not exist yet, `updateLocale` registers it, behaving like `defineLocale`.
99
+
100
+ ## Reading Messages
101
+
102
+ ### In Components
103
+
104
+ `useLocale` is the React hook for reading the active locale. It re-renders the calling component when the language changes.
105
+
106
+ ```jsx
107
+ import { useLocale } from '@primereact/core/locale';
108
+
109
+ function ClearButton() {
110
+ const { t, lang, messages } = useLocale();
111
+
112
+ return <button aria-label={t('clear')}>{t('clear')}</button>;
113
+ }
114
+ ```
115
+
116
+ | Field | Description |
117
+ | ---------- | --------------------------------------------- |
118
+ | `lang` | Active language code, such as `en` or `de`. |
119
+ | `messages` | Full message object of the active language. |
120
+ | `t` | Translates a key against the active language. |
121
+
122
+ Re-rendering on a language change relies on the context published by `PrimeReactProvider`, which applications normally have at their root. A component rendered outside any provider still reads the correct messages on first render, but will not update when the language changes later.
123
+
124
+ ### Outside Components
125
+
126
+ `$t` performs the same lookup without a React context, which suits utilities, event handlers and module-level code.
127
+
128
+ ```js
129
+ import { $t } from '@primereact/core/locale';
130
+
131
+ $t('clear'); // 'Clear'
132
+ ```
133
+
134
+ Nested keys use dot notation.
135
+
136
+ ```js
137
+ $t('aria.selectRow'); // 'Row Selected'
138
+ ```
139
+
140
+ Messages containing placeholders accept replacement values. Positional placeholders such as `{0}` are filled from the argument order, while named ones are filled from an object.
141
+
142
+ ```js
143
+ $t('searchMessage', 5); // '5 results are available'
144
+ $t('selectionMessage', 3); // '3 items selected'
145
+ $t('aria.stars', { star: 4 }); // '4 stars'
146
+ ```
147
+
148
+ ## Reacting to Language Changes
149
+
150
+ Language changes emit a `locale:change` event. Components handle this automatically through `useLocale`; the event is only needed for code living outside React, such as syncing a third-party library.
151
+
152
+ ```js
153
+ import { LocaleService } from '@primereact/core/locale';
154
+
155
+ const onChange = ({ lang }) => console.log('Language is now', lang);
156
+
157
+ LocaleService.on('locale:change', onChange);
158
+
159
+ // remove the listener when it is no longer needed
160
+ LocaleService.off('locale:change', onChange);
161
+ ```
162
+
163
+ ## Inspecting the Registry
164
+
165
+ `$l` returns a facade over the registry, which helps when building a language switcher.
166
+
167
+ ```js
168
+ import { $l } from '@primereact/core/locale';
169
+
170
+ $l().langs; // ['en', 'es']
171
+ $l().get('es'); // message object of the Spanish locale
172
+ ```
173
+
174
+ ## Message Keys
175
+
176
+ Built-in messages are grouped as follows.
177
+
178
+ | Group | Keys |
179
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
180
+ | Filter operators | `startsWith`, `contains`, `notContains`, `endsWith`, `equals`, `notEquals`, `noFilter`, `lt`, `lte`, `gt`, `gte`, `dateIs`, `dateIsNot`, `dateBefore`, `dateAfter` |
181
+ | Filter menu | `clear`, `apply`, `matchAll`, `matchAny`, `addRule`, `removeRule` |
182
+ | Actions | `accept`, `reject`, `choose`, `upload`, `cancel`, `completed`, `pending` |
183
+ | Dates | `dayNames`, `dayNamesShort`, `dayNamesMin`, `monthNames`, `monthNamesShort`, `today`, `weekHeader`, `firstDayOfWeek`, `dateFormat` |
184
+ | Date navigation | `chooseYear`, `chooseMonth`, `chooseDate`, `prevDecade`, `nextDecade`, `prevYear`, `nextYear`, `prevMonth`, `nextMonth`, `prevHour`, `nextHour`, `prevMinute`, `nextMinute`, `prevSecond`, `nextSecond`, `am`, `pm` |
185
+ | Password strength | `weak`, `medium`, `strong`, `passwordPrompt` |
186
+ | Empty and status messages | `emptyMessage`, `emptyFilterMessage`, `emptySearchMessage`, `emptySelectionMessage`, `searchMessage`, `selectionMessage` |
187
+ | Files | `fileSizeTypes`, `fileChosenMessage`, `noFileChosenMessage` |
188
+ | Regional settings | `firstDayOfWeek`, `dateFormat`, `showMonthAfterYear` |
189
+ | Accessibility | Nested under `aria`, covering screen reader labels such as `aria.selectRow`, `aria.expandRow`, `aria.showFilterMenu`, `aria.zoomImage`, `aria.listLabel` and pagination labels. |
190
+
191
+ Not every entry is a string. `firstDayOfWeek` is a number, `showMonthAfterYear` is a boolean, and `dayNames`, `monthNames` and `fileSizeTypes` are arrays.
192
+
193
+ The complete list with default English values is in `packages/@primereact/core/src/locale/defaultLocale.ts`.
194
+
195
+ ## Ready-Made Translations
196
+
197
+ Writing a translation from scratch is rarely necessary. The community maintained [PrimeLocale](https://github.com/primefaces/primelocale) repository publishes complete translations for 70+ languages, shared across all Prime libraries. Each file covers every built-in message key, so nothing is left resolving to `undefined`.
198
+
199
+ ### Copying a File
200
+
201
+ Grab the JSON file for the desired language from the repository, for example `tr.json`, and place it in the project.
202
+
203
+ Each file wraps its messages in a single key named after the language:
204
+
205
+ ```json
206
+ {
207
+ "tr": {
208
+ "clear": "Temizle",
209
+ "apply": "Uygula",
210
+ "aria": { "selectRow": "Satır Seçildi" }
211
+ }
212
+ }
213
+ ```
214
+
215
+ That wrapper has to be unwrapped before registering, otherwise every lookup resolves to `undefined`:
216
+
217
+ ```js
218
+ import { defineLocale, Locale } from '@primereact/core/locale';
219
+ import tr from './locales/tr.json';
220
+
221
+ defineLocale('tr', tr.tr);
222
+ Locale.use('tr');
223
+ ```
224
+
225
+ The same unwrapping applies when the language is registered through the provider:
226
+
227
+ ```jsx
228
+ import { PrimeReactProvider } from '@primereact/core';
229
+ import tr from './locales/tr.json';
230
+
231
+ <PrimeReactProvider locale="tr" locales={{ tr: tr.tr }}>
232
+ <App />
233
+ </PrimeReactProvider>;
234
+ ```
235
+
236
+ ### Installing the Package
237
+
238
+ The translations are also published to npm, which avoids maintaining copies by hand.
239
+
240
+ ```bash
241
+ npm install primelocale
242
+ ```
243
+
244
+ ```js
245
+ import { defineLocale, Locale } from '@primereact/core/locale';
246
+ import { tr } from 'primelocale/js/tr.js';
247
+
248
+ defineLocale('tr', tr);
249
+ Locale.use('tr');
250
+ ```
251
+
252
+ The package entry points export the messages directly, so no unwrapping is needed there.
253
+
254
+ Regional variants are named with an underscore in the package and a hyphen in the JSON files. Brazilian Portuguese is `primelocale/js/pt_BR.js` when imported and `pt-BR.json` when copied.
255
+
256
+ ### Adjusting a Translation
257
+
258
+ A ready-made translation can be tuned without editing the file, by layering overrides on top of it:
259
+
260
+ ```js
261
+ defineLocale('tr', tr.tr);
262
+ updateLocale('tr', { clear: 'Sıfırla' });
263
+ ```
264
+
265
+ Contributions of new languages and corrections are welcome in the PrimeLocale repository, and benefit every Prime library at once.
266
+
267
+ ## Migrating from v10
268
+
269
+ The locale helpers previously imported from `primereact/api` have been replaced.
270
+
271
+ | v10 | v11 |
272
+ | -------------------------------------- | ---------------------------------------------------------------- |
273
+ | `locale('de')` | `Locale.use('de')`, or the `locale` prop on `PrimeReactProvider` |
274
+ | `addLocale('es', {...})` | `defineLocale('es', {...})` |
275
+ | `updateLocaleOption(key, value, lang)` | `updateLocale(lang, { key: value })` |
276
+ | `updateLocaleOptions({...}, lang)` | `updateLocale(lang, {...})` |
277
+ | `localeOption(key)` | `$t(key)`, or `t(key)` from `useLocale()` |
278
+ | `localeOptions(lang)` | `$l().get(lang)`, or `messages` from `useLocale()` |
279
+
280
+ One behavioural difference is worth noting: locale state is now shared with other Prime libraries in the same application rather than being private to PrimeReact. Setting a language from PrimeReact also affects PrimeVue or PrimeNG components running alongside it.