Skip to content

Commit c49752b

Browse files
authored
Docs: Clarify locale precedence when using PrimeReactProvider (#8453)
1 parent 806337a commit c49752b

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

components/doc/configuration/locale/setuplocaledoc.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DocSectionText } from '@/components/doc/common/docsectiontext';
44
export function SetupLocaleDoc(props) {
55
const code = {
66
basic: `
7-
//_app.js
7+
// _app.js
88
import { PrimeReactProvider } from 'primereact/api';
99
1010
export default function MyApp({ Component }) {
@@ -15,7 +15,7 @@ export default function MyApp({ Component }) {
1515
1616
return (
1717
<PrimeReactProvider value={value}>
18-
<App />
18+
<Component />
1919
</PrimeReactProvider>
2020
);
2121
}
@@ -26,9 +26,35 @@ export default function MyApp({ Component }) {
2626
<>
2727
<DocSectionText {...props}>
2828
<p>
29-
To establish the default locale for your entire application, you can utilize the <i>PrimeReactProvider</i>.
29+
To establish the default locale for your entire application, you can utilize the
30+
<i> PrimeReactProvider</i>.
31+
</p>
32+
33+
<p>
34+
When <b>PrimeReactProvider</b> is used, it becomes the primary source of locale configuration for all PrimeReact components.
35+
</p>
36+
37+
<h5>Locale Precedence</h5>
38+
<p>Locale resolution follows the order below:</p>
39+
<ul>
40+
<li>
41+
<code>locale</code> prop defined on a component
42+
</li>
43+
<li>
44+
<code>PrimeReactProvider</code> (<code>context.locale</code>)
45+
</li>
46+
<li>
47+
Global <code>PrimeReact.locale</code> set via <code>locale()</code>
48+
</li>
49+
<li>Browser locale</li>
50+
</ul>
51+
52+
<p>
53+
This means that once <b>PrimeReactProvider</b> is present, calling
54+
<code> locale()</code> alone is not sufficient. The locale must be provided explicitly through the provider.
3055
</p>
3156
</DocSectionText>
57+
3258
<DocSectionCode code={code} hideToggleCode import hideStackBlitz />
3359
</>
3460
);

0 commit comments

Comments
 (0)