@nimpl/i18n 2.0.0 → 3.0.0-canary.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.
@@ -3,7 +3,7 @@ import { type I18nOptions } from "./types";
3
3
  type ClientTranslationProps = {
4
4
  term: string;
5
5
  components?: {
6
- [key: string]: JSX.Element;
6
+ [key: string]: React.ReactElement;
7
7
  };
8
8
  query?: I18nOptions["query"];
9
9
  removeUnusedQueries?: I18nOptions["removeUnusedQueries"];
@@ -3,7 +3,7 @@ import { type I18nOptions } from "./types";
3
3
  type ServerTranslationProps = {
4
4
  term: string;
5
5
  components?: {
6
- [key: string]: JSX.Element;
6
+ [key: string]: React.ReactElement;
7
7
  };
8
8
  query?: I18nOptions["query"];
9
9
  removeUnusedQueries?: I18nOptions["removeUnusedQueries"];
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
5
  };
@@ -35,7 +36,7 @@ const Translation = ({ term, text, components }) => {
35
36
  if (component) {
36
37
  const children = parts
37
38
  .slice(targetTag.position + 1, tagIndex + 1)
38
- .filter((c) => Boolean(c.props.children));
39
+ .filter((c) => Boolean(c && typeof c === "object" && "props" in c && c.props.children));
39
40
  parts.splice(targetTag.position + 1, // parts на 1 больше
40
41
  tagIndex - targetTag.position, react_1.default.cloneElement(component, { key: `${tagIndex}-${targetIndex}` }, children.length ? children : component.props.children));
41
42
  }
@@ -8,7 +8,14 @@ const get_pathname_1 = require("@nimpl/getters/get-pathname");
8
8
  const get_params_1 = require("@nimpl/getters/get-params");
9
9
  const loadI18nData = async () => {
10
10
  const config = await (0, getConfig_1.default)();
11
- const language = await config.getLanguage({ pathname: (0, get_pathname_1.getPathname)(), params: (0, get_params_1.getParams)() });
11
+ const language = await config.getLanguage({
12
+ get pathname() {
13
+ return (0, get_pathname_1.getPathname)();
14
+ },
15
+ get params() {
16
+ return (0, get_params_1.getParams)();
17
+ },
18
+ });
12
19
  if (!language || !config.languages.includes(language)) {
13
20
  throw new Error(`Can\' load data for language "${language}", valid languages are: ${config.languages.join(", ")}`);
14
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimpl/i18n",
3
- "version": "2.0.0",
3
+ "version": "3.0.0-canary.0",
4
4
  "description": "i18n library for working with translations in server and client components",
5
5
  "exports": {
6
6
  "./ClientTranslation": {
@@ -59,16 +59,16 @@
59
59
  "devDependencies": {
60
60
  "@types/node": "16.11.12",
61
61
  "@types/object-path": "0.11.4",
62
- "@types/react": "18.2.43",
62
+ "@types/react": "19.1.1",
63
63
  "@types/webpack": "5.28.5",
64
- "react": "18.2.0",
64
+ "react": "19.1.0",
65
65
  "typescript": "5.3.2"
66
66
  },
67
67
  "peerDependencies": {
68
- "react": ">= 18.2.0"
68
+ "react": ">= 19.1.0"
69
69
  },
70
70
  "dependencies": {
71
- "@nimpl/getters": "1.3.4",
71
+ "@nimpl/getters": "2.1.1",
72
72
  "html-entities": "2.4.0",
73
73
  "object-path": "0.11.8"
74
74
  }