@lingui/react 6.0.0-next.0 → 6.0.0-next.2
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/dist/index.mjs +5 -5
- package/macro/{index.d.cts → index.d.mts} +1 -1
- package/macro/index.mjs +22 -0
- package/package.json +13 -12
- package/macro/index.cjs +0 -6
- /package/macro/{browser.cjs → browser.mjs} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -23,19 +23,19 @@ const I18nProvider = ({
|
|
|
23
23
|
defaultComponent,
|
|
24
24
|
children
|
|
25
25
|
}) => {
|
|
26
|
-
const latestKnownLocale = useRef(i18n.locale);
|
|
26
|
+
const latestKnownLocale = useRef(i18n.locale || null);
|
|
27
27
|
const makeContext = useCallback(
|
|
28
28
|
() => ({
|
|
29
|
-
i18n,
|
|
29
|
+
i18n: new Proxy(i18n, {}),
|
|
30
30
|
defaultComponent,
|
|
31
31
|
_: i18n.t.bind(i18n)
|
|
32
32
|
}),
|
|
33
33
|
[i18n, defaultComponent]
|
|
34
34
|
);
|
|
35
|
-
const [context, setContext] = useState(makeContext
|
|
35
|
+
const [context, setContext] = useState(makeContext);
|
|
36
36
|
useEffect(() => {
|
|
37
37
|
const updateContext = () => {
|
|
38
|
-
latestKnownLocale.current = i18n.locale;
|
|
38
|
+
latestKnownLocale.current = i18n.locale || null;
|
|
39
39
|
setContext(makeContext());
|
|
40
40
|
};
|
|
41
41
|
const unsubscribe = i18n.on("change", updateContext);
|
|
@@ -44,7 +44,7 @@ const I18nProvider = ({
|
|
|
44
44
|
}
|
|
45
45
|
return unsubscribe;
|
|
46
46
|
}, [i18n, makeContext]);
|
|
47
|
-
if (
|
|
47
|
+
if (latestKnownLocale.current === null) {
|
|
48
48
|
process.env.NODE_ENV === "development" && console.log(
|
|
49
49
|
"I18nProvider rendered `null`. A call to `i18n.activate` needs to happen in order for translations to be activated and for the I18nProvider to render.This is not an error but an informational message logged only in development."
|
|
50
50
|
);
|
package/macro/index.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import babelPluginMacros from "babel-plugin-macros"
|
|
2
|
+
import { macro } from "@lingui/babel-plugin-lingui-macro/macro"
|
|
3
|
+
|
|
4
|
+
const { createMacro } = babelPluginMacros
|
|
5
|
+
|
|
6
|
+
export default createMacro(macro, {
|
|
7
|
+
configName: "lingui",
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
// the following shims for the case when this import used by nodejs code without transpilation
|
|
11
|
+
function printError() {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`The macro you imported from "@lingui/react/macro" is being executed outside the context of compilation. \n` +
|
|
14
|
+
`This indicates that you don't configured correctly one of the "babel-plugin-macros" / "@lingui/swc-plugin" / "babel-plugin-lingui-macro"`,
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Trans = printError
|
|
19
|
+
export const Plural = printError
|
|
20
|
+
export const Select = printError
|
|
21
|
+
export const SelectOrdinal = printError
|
|
22
|
+
export const useLingui = printError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/react",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "React components for translations",
|
|
6
6
|
"type": "module",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"./server": "./dist/server.mjs",
|
|
49
49
|
"./macro": {
|
|
50
|
-
"browser": "./macro/browser.
|
|
51
|
-
"types": "./macro/index.d.
|
|
52
|
-
"default": "./macro/index.
|
|
50
|
+
"browser": "./macro/browser.mjs",
|
|
51
|
+
"types": "./macro/index.d.mts",
|
|
52
|
+
"default": "./macro/index.mjs"
|
|
53
53
|
},
|
|
54
54
|
"./package.json": "./package.json"
|
|
55
55
|
},
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"LICENSE",
|
|
58
58
|
"README.md",
|
|
59
59
|
"dist/",
|
|
60
|
-
"macro/browser.
|
|
61
|
-
"macro/index.d.
|
|
62
|
-
"macro/index.
|
|
60
|
+
"macro/browser.mjs",
|
|
61
|
+
"macro/index.d.mts",
|
|
62
|
+
"macro/index.mjs"
|
|
63
63
|
],
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"babel-plugin-macros": "2 || 3",
|
|
@@ -71,20 +71,21 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@lingui/babel-plugin-lingui-macro": "6.0.0-next.
|
|
75
|
-
"@lingui/core": "6.0.0-next.
|
|
74
|
+
"@lingui/babel-plugin-lingui-macro": "6.0.0-next.2",
|
|
75
|
+
"@lingui/core": "6.0.0-next.2"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@lingui/test-utils": "3.0.3",
|
|
79
79
|
"@testing-library/react": "^14.0.0",
|
|
80
80
|
"@types/react": "^18.2.13",
|
|
81
|
-
"eslint
|
|
82
|
-
"eslint-plugin-react
|
|
81
|
+
"eslint": "^9.39.3",
|
|
82
|
+
"eslint-plugin-react": "^7.37.5",
|
|
83
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
83
84
|
"happy-dom": "^20.0.10",
|
|
84
85
|
"react": "^18.2.0",
|
|
85
86
|
"react-dom": "^18.2.0",
|
|
86
87
|
"unbuild": "3.6.1",
|
|
87
88
|
"vitest": "4.0.18"
|
|
88
89
|
},
|
|
89
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "f4bcdd555ceef0bed58b2f3075096efd4daaeec2"
|
|
90
91
|
}
|
package/macro/index.cjs
DELETED
|
File without changes
|