Skip to content

Commit 2505727

Browse files
committed
Debug playgound
1 parent ea8dd63 commit 2505727

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codegouvfr/react-dsfr",
3-
"version": "0.0.88",
3+
"version": "0.0.89-rc.0",
44
"description": "French State Design System React integration library",
55
"repository": {
66
"type": "git",

src/lib/i18n.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ const langContext = createContext<string | undefined>(undefined);
1313
export function useLang(): string | undefined {
1414
const lang = useContext(langContext);
1515

16+
console.log(
17+
`useLang: context: ${lang}, ${
18+
isBrowser ? "browser" : "node"
19+
}, langIfNoProvider: ${langIfNoProvider}`
20+
);
21+
1622
if (lang === undefined) {
1723
return langIfNoProvider ?? (!isBrowser ? undefined : navigator.language);
1824
}
@@ -81,8 +87,13 @@ export function createComponentI18nApi<
8187
function useTranslation() {
8288
const lang = useLang();
8389

90+
console.log(`useTranslation: useLang() === ${lang}`);
91+
8492
const bestMatchLang = useMemo(() => {
93+
console.log("run use memo");
94+
8595
if (lang === undefined) {
96+
console.log("useTranslation: undefined so return fr");
8697
return "fr";
8798
}
8899

@@ -91,6 +102,8 @@ export function createComponentI18nApi<
91102
"languageLike": lang
92103
});
93104

105+
console.log(`useTranslation: bestApproxLang: ${bestApproxLang}`);
106+
94107
return bestApproxLang ?? "fr";
95108
}, [lang]);
96109

src/lib/start.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async function startReactDsfrWithOptionalNextParams(params: Params, nextParams?:
3838
isStarted = true;
3939

4040
if (langIfNoProvider !== undefined) {
41+
console.log(`start(), setLangToUseIfProviderNotUsed, ${langIfNoProvider}`);
4142
setLangToUseIfProviderNotUsed(langIfNoProvider);
4243
}
4344

src/next.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ export function createNextDsfrIntegrationApi(params: Params): NextDsfrIntegratio
119119
{
120120
startDsfrReactParams.langIfNoProvider ??= "fr";
121121

122+
console.log(
123+
`startDsfrReactParams.langIfNoProvider: ${startDsfrReactParams.langIfNoProvider}`
124+
);
125+
122126
if (isBrowser) {
123127
startReactDsfrNext(startDsfrReactParams, {
124128
doPersistDarkModePreferenceWithCookie,

0 commit comments

Comments
 (0)