@intlayer/core 2.0.13 → 3.0.1

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 (107) hide show
  1. package/dist/cjs/getHTMLLang.cjs +29 -0
  2. package/dist/cjs/getHTMLLang.cjs.map +1 -0
  3. package/dist/cjs/getHTMLTextDir.cjs +258 -0
  4. package/dist/cjs/getHTMLTextDir.cjs.map +1 -0
  5. package/dist/cjs/getLocaleName.cjs +233 -459
  6. package/dist/cjs/getLocaleName.cjs.map +1 -1
  7. package/dist/cjs/index.cjs +9 -0
  8. package/dist/cjs/index.cjs.map +1 -1
  9. package/dist/cjs/localeDetector.cjs +50 -0
  10. package/dist/cjs/localeDetector.cjs.map +1 -0
  11. package/dist/cjs/transpiler/content_transformers/translation/types.cjs.map +1 -1
  12. package/dist/cjs/types/declarationContent.cjs.map +1 -1
  13. package/dist/cjs/types/dictionary.cjs.map +1 -1
  14. package/dist/cjs/types/index.cjs.map +1 -1
  15. package/dist/cjs/types/keyPath.cjs.map +1 -1
  16. package/dist/cjs/types/nodeType.cjs +4 -0
  17. package/dist/cjs/types/nodeType.cjs.map +1 -1
  18. package/dist/esm/getHTMLLang.mjs +5 -0
  19. package/dist/esm/getHTMLLang.mjs.map +1 -0
  20. package/dist/esm/getHTMLTextDir.mjs +234 -0
  21. package/dist/esm/getHTMLTextDir.mjs.map +1 -0
  22. package/dist/esm/getLocaleName.mjs +233 -459
  23. package/dist/esm/getLocaleName.mjs.map +1 -1
  24. package/dist/esm/index.mjs +6 -0
  25. package/dist/esm/index.mjs.map +1 -1
  26. package/dist/esm/localeDetector.mjs +16 -0
  27. package/dist/esm/localeDetector.mjs.map +1 -0
  28. package/dist/esm/types/index.mjs.map +1 -1
  29. package/dist/esm/types/nodeType.mjs +4 -0
  30. package/dist/esm/types/nodeType.mjs.map +1 -1
  31. package/dist/types/getHTMLLang.d.ts +16 -0
  32. package/dist/types/getHTMLLang.d.ts.map +1 -0
  33. package/dist/types/getHTMLTextDir.d.ts +18 -0
  34. package/dist/types/getHTMLTextDir.d.ts.map +1 -0
  35. package/dist/types/getLocaleName.d.ts +3 -0
  36. package/dist/types/getLocaleName.d.ts.map +1 -0
  37. package/dist/types/index.d.ts +11 -0
  38. package/dist/types/index.d.ts.map +1 -0
  39. package/dist/types/localeDetector.d.ts +8 -0
  40. package/dist/types/localeDetector.d.ts.map +1 -0
  41. package/dist/types/localeList.d.ts +3 -0
  42. package/dist/types/localeList.d.ts.map +1 -0
  43. package/dist/{cjs → types}/transpiler/content_transformers/enumeration/enumeration.d.ts +6 -7
  44. package/dist/types/transpiler/content_transformers/enumeration/enumeration.d.ts.map +1 -0
  45. package/dist/{cjs → types}/transpiler/content_transformers/enumeration/findMatchingCondition.d.ts +3 -6
  46. package/dist/types/transpiler/content_transformers/enumeration/findMatchingCondition.d.ts.map +1 -0
  47. package/dist/{cjs → types}/transpiler/content_transformers/enumeration/getEnumerationContent.d.ts +3 -6
  48. package/dist/types/transpiler/content_transformers/enumeration/getEnumerationContent.d.ts.map +1 -0
  49. package/dist/types/transpiler/content_transformers/enumeration/index.d.ts +4 -0
  50. package/dist/types/transpiler/content_transformers/enumeration/index.d.ts.map +1 -0
  51. package/dist/types/transpiler/content_transformers/index.d.ts +3 -0
  52. package/dist/types/transpiler/content_transformers/index.d.ts.map +1 -0
  53. package/dist/{cjs → types}/transpiler/content_transformers/translation/getTranslationContent.d.ts +5 -8
  54. package/dist/types/transpiler/content_transformers/translation/getTranslationContent.d.ts.map +1 -0
  55. package/dist/types/transpiler/content_transformers/translation/index.d.ts +4 -0
  56. package/dist/types/transpiler/content_transformers/translation/index.d.ts.map +1 -0
  57. package/dist/{cjs → types}/transpiler/content_transformers/translation/translation.d.ts +3 -7
  58. package/dist/types/transpiler/content_transformers/translation/translation.d.ts.map +1 -0
  59. package/dist/{cjs → types}/transpiler/content_transformers/translation/types.d.ts +10 -11
  60. package/dist/types/transpiler/content_transformers/translation/types.d.ts.map +1 -0
  61. package/dist/types/transpiler/index.d.ts +2 -0
  62. package/dist/types/transpiler/index.d.ts.map +1 -0
  63. package/dist/types/types/declarationContent.d.ts +25 -0
  64. package/dist/types/types/declarationContent.d.ts.map +1 -0
  65. package/dist/types/types/dictionary.d.ts +13 -0
  66. package/dist/types/types/dictionary.d.ts.map +1 -0
  67. package/dist/types/types/index.d.ts +5 -0
  68. package/dist/types/types/index.d.ts.map +1 -0
  69. package/dist/types/types/keyPath.d.ts +19 -0
  70. package/dist/types/types/keyPath.d.ts.map +1 -0
  71. package/dist/types/types/nodeType.d.ts +9 -0
  72. package/dist/types/types/nodeType.d.ts.map +1 -0
  73. package/dist/types/utils/isSameKeyPath.d.ts +3 -0
  74. package/dist/types/utils/isSameKeyPath.d.ts.map +1 -0
  75. package/package.json +31 -17
  76. package/dist/cjs/getLocaleName.d.ts +0 -5
  77. package/dist/cjs/index.d.ts +0 -16
  78. package/dist/cjs/localeList.d.ts +0 -5
  79. package/dist/cjs/transpiler/content_transformers/enumeration/index.d.ts +0 -4
  80. package/dist/cjs/transpiler/content_transformers/index.d.ts +0 -9
  81. package/dist/cjs/transpiler/content_transformers/translation/index.d.ts +0 -6
  82. package/dist/cjs/transpiler/index.d.ts +0 -9
  83. package/dist/cjs/types/declarationContent.d.ts +0 -26
  84. package/dist/cjs/types/dictionary.d.ts +0 -17
  85. package/dist/cjs/types/index.d.ts +0 -9
  86. package/dist/cjs/types/keyPath.d.ts +0 -17
  87. package/dist/cjs/types/nodeType.d.ts +0 -6
  88. package/dist/cjs/utils/isSameKeyPath.d.ts +0 -6
  89. package/dist/esm/getLocaleName.d.mts +0 -5
  90. package/dist/esm/index.d.mts +0 -16
  91. package/dist/esm/localeList.d.mts +0 -5
  92. package/dist/esm/transpiler/content_transformers/enumeration/enumeration.d.mts +0 -39
  93. package/dist/esm/transpiler/content_transformers/enumeration/findMatchingCondition.d.mts +0 -33
  94. package/dist/esm/transpiler/content_transformers/enumeration/getEnumerationContent.d.mts +0 -32
  95. package/dist/esm/transpiler/content_transformers/enumeration/index.d.mts +0 -4
  96. package/dist/esm/transpiler/content_transformers/index.d.mts +0 -9
  97. package/dist/esm/transpiler/content_transformers/translation/getTranslationContent.d.mts +0 -28
  98. package/dist/esm/transpiler/content_transformers/translation/index.d.mts +0 -6
  99. package/dist/esm/transpiler/content_transformers/translation/translation.d.mts +0 -28
  100. package/dist/esm/transpiler/content_transformers/translation/types.d.mts +0 -62
  101. package/dist/esm/transpiler/index.d.mts +0 -9
  102. package/dist/esm/types/declarationContent.d.mts +0 -26
  103. package/dist/esm/types/dictionary.d.mts +0 -17
  104. package/dist/esm/types/index.d.mts +0 -9
  105. package/dist/esm/types/keyPath.d.mts +0 -17
  106. package/dist/esm/types/nodeType.d.mts +0 -6
  107. package/dist/esm/utils/isSameKeyPath.d.mts +0 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeType.d.ts","sourceRoot":"","sources":["../../../src/types/nodeType.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,SAAS,cAAc;CACxB"}
@@ -0,0 +1,3 @@
1
+ import type { KeyPath } from '../types';
2
+ export declare const isSameKeyPath: (keyPath1: KeyPath[], keyPath2: KeyPath[]) => boolean;
3
+ //# sourceMappingURL=isSameKeyPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSameKeyPath.d.ts","sourceRoot":"","sources":["../../../src/utils/isSameKeyPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,aAAa,aAAc,OAAO,EAAE,YAAY,OAAO,EAAE,YAMnE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "2.0.13",
3
+ "version": "3.0.1",
4
4
  "private": false,
5
5
  "description": "IntLayer - Layer of abstraction between the business logic and the data access layer. Manage internationalization in a simple way, through TypeScript, JavaScript or JSON declaration file.",
6
6
  "keywords": [
@@ -17,27 +17,27 @@
17
17
  ],
18
18
  "homepage": "https://intlayer.org",
19
19
  "bugs": {
20
- "url": "https://github.com/aypineau/intlayer/issues"
20
+ "url": "https://github.com/aymericzip/intlayer/issues"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "git+https://github.com/aypineau/intlayer.git"
24
+ "url": "git+https://github.com/aymericzip/intlayer.git"
25
25
  },
26
26
  "license": "Apache-2.0",
27
27
  "author": {
28
28
  "name": "Aymeric PINEAU",
29
- "url": "https://github.com/aypineau"
29
+ "url": "https://github.com/aymericzip"
30
30
  },
31
31
  "contributors": [
32
32
  {
33
33
  "name": "Aymeric Pineau",
34
34
  "email": "ay.pineau@gmail.com",
35
- "url": "https://github.com/aypineau"
35
+ "url": "https://github.com/aymericzip"
36
36
  }
37
37
  ],
38
38
  "exports": {
39
39
  ".": {
40
- "types": "./dist/esm/index.d.mts",
40
+ "types": "./dist/types/index.d.ts",
41
41
  "require": "./dist/cjs/index.cjs",
42
42
  "import": "./dist/esm/index.mjs"
43
43
  },
@@ -45,6 +45,7 @@
45
45
  },
46
46
  "main": "dist/cjs/index.cjs",
47
47
  "module": "dist/esm/index.mjs",
48
+ "types": "dist/types/index.d.ts",
48
49
  "typesVersions": {
49
50
  "*": {
50
51
  "package.json": [
@@ -57,18 +58,28 @@
57
58
  "./package.json"
58
59
  ],
59
60
  "dependencies": {
60
- "chokidar": "^3.6.0",
61
- "@intlayer/config": "^2.0.13"
61
+ "@formatjs/intl-localematcher": "^0.5.4",
62
+ "chokidar": "^4.0.1",
63
+ "negotiator": "^0.6.3",
64
+ "@intlayer/config": "^3.0.1"
62
65
  },
63
66
  "devDependencies": {
67
+ "@types/negotiator": "^0.6.3",
64
68
  "@types/node": "^20.14.9",
65
69
  "@types/react": "^18.3.3",
70
+ "concurrently": "^8.2.2",
71
+ "eslint": "^9.11.1",
72
+ "prettier": "3.3.3",
66
73
  "react": "^18.3.1",
67
74
  "rimraf": "5.0.5",
68
- "tsup": "^8.1.0",
75
+ "tsc-alias": "^1.8.10",
76
+ "tsup": "^8.3.0",
69
77
  "typescript": "^5.5.2",
78
+ "@intlayer/backend": "^3.0.1",
70
79
  "@utils/eslint-config": "^1.0.4",
71
- "@utils/ts-config": "^1.0.4"
80
+ "@utils/ts-config": "^1.0.4",
81
+ "@utils/ts-config-types": "^1.0.4",
82
+ "@utils/tsup-config": "^1.0.4"
72
83
  },
73
84
  "peerDependencies": {
74
85
  "react": "^18.2.0"
@@ -80,17 +91,20 @@
80
91
  "access": "public"
81
92
  },
82
93
  "bug": {
83
- "url": "https://github.com/aypineau/intlayer/issues"
94
+ "url": "https://github.com/aymericzip/intlayer/issues"
84
95
  },
85
96
  "scripts": {
86
- "build": "tsup",
97
+ "build": "pnpm build:package & pnpm build:types",
98
+ "build:package": "tsup",
99
+ "build:types": "tsc --project ./tsconfig.types.json && tsc-alias --project ./tsconfig.types.json",
87
100
  "clean": "rimraf ./dist",
88
- "dev": "tsup --watch",
89
- "lint": "eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs",
90
- "lint:fix": "eslint . --ext .ts,.tsx,.js,.jsx,.cjs,.mjs --fix",
91
- "prettier:fix": "prettier --write src/**/*",
101
+ "dev": "concurrently --prefix none \"tsup --watch\" \"tsc --project ./tsconfig.types.json --watch\" \"tsc-alias --project ./tsconfig.types.json --watch\"",
102
+ "lint": "eslint . --cache",
103
+ "lint:fix": "eslint . --cache --fix",
104
+ "prettier": "prettier . --check",
105
+ "prettier:fix": "prettier . --write",
92
106
  "process-files": "ts-node src/transpiler/processFilesCLI.ts --dir $npm_config_dir --extension $npm_config_extension --no-node-snapshot",
93
107
  "test": "",
94
- "typecheck": "tsup--project ./tsconfig.json --noEmit"
108
+ "typecheck": "tsup --project ./tsconfig.json --noEmit"
95
109
  }
96
110
  }
@@ -1,5 +0,0 @@
1
- import { Locales } from '@intlayer/config/client';
2
-
3
- declare const getLocaleName: (locale: Locales) => string;
4
-
5
- export { getLocaleName };
@@ -1,16 +0,0 @@
1
- export { t } from './transpiler/content_transformers/translation/translation.js';
2
- export { getTranslationContent } from './transpiler/content_transformers/translation/getTranslationContent.js';
3
- export { CustomizableLanguageContent, LanguageContent, CustomLocales as Locales, TranslationContent } from './transpiler/content_transformers/translation/types.js';
4
- export { EnumerationContent, QuantityContent, enu } from './transpiler/content_transformers/enumeration/enumeration.js';
5
- export { getEnumerationContent } from './transpiler/content_transformers/enumeration/getEnumerationContent.js';
6
- export { findMatchingCondition } from './transpiler/content_transformers/enumeration/findMatchingCondition.js';
7
- export { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './types/declarationContent.js';
8
- export { NodeType } from './types/nodeType.js';
9
- export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.js';
10
- export { Dictionary, DictionaryValue } from './types/dictionary.js';
11
- export { getLocaleName } from './getLocaleName.js';
12
- export { localeList } from './localeList.js';
13
- export { isSameKeyPath } from './utils/isSameKeyPath.js';
14
- import '@intlayer/config/client';
15
- import 'intlayer';
16
- import 'react';
@@ -1,5 +0,0 @@
1
- import { Locales } from '@intlayer/config/client';
2
-
3
- declare const localeList: Locales[];
4
-
5
- export { localeList };
@@ -1,4 +0,0 @@
1
- export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration.js';
2
- export { getEnumerationContent } from './getEnumerationContent.js';
3
- export { findMatchingCondition } from './findMatchingCondition.js';
4
- import '../../../types/nodeType.js';
@@ -1,9 +0,0 @@
1
- export { t } from './translation/translation.js';
2
- export { getTranslationContent } from './translation/getTranslationContent.js';
3
- export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './translation/types.js';
4
- export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration/enumeration.js';
5
- export { getEnumerationContent } from './enumeration/getEnumerationContent.js';
6
- export { findMatchingCondition } from './enumeration/findMatchingCondition.js';
7
- import '@intlayer/config/client';
8
- import 'intlayer';
9
- import '../../types/nodeType.js';
@@ -1,6 +0,0 @@
1
- export { t } from './translation.js';
2
- export { getTranslationContent } from './getTranslationContent.js';
3
- export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './types.js';
4
- import '@intlayer/config/client';
5
- import 'intlayer';
6
- import '../../../types/nodeType.js';
@@ -1,9 +0,0 @@
1
- export { t } from './content_transformers/translation/translation.js';
2
- export { getTranslationContent } from './content_transformers/translation/getTranslationContent.js';
3
- export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './content_transformers/translation/types.js';
4
- export { EnterFormat, EnumerationContent, QuantityContent, enu } from './content_transformers/enumeration/enumeration.js';
5
- export { getEnumerationContent } from './content_transformers/enumeration/getEnumerationContent.js';
6
- export { findMatchingCondition } from './content_transformers/enumeration/findMatchingCondition.js';
7
- import '@intlayer/config/client';
8
- import 'intlayer';
9
- import '../types/nodeType.js';
@@ -1,26 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { TranslationContent } from '../transpiler/content_transformers/translation/types.js';
3
- import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.js';
4
- import '@intlayer/config/client';
5
- import 'intlayer';
6
- import './nodeType.js';
7
-
8
- type TypedNode = TranslationContent<unknown> | EnumerationContent<unknown>;
9
- type ContentValue = string | string[] | number | number[] | {
10
- [key: string]: ContentValue;
11
- } | (() => ContentValue) | Promise<ContentValue> | TypedNode;
12
- type Content = Record<string, ContentValue | ContentValue[] | undefined>;
13
- type FlatContentValue = string | {
14
- [key: string]: FlatContentValue;
15
- } | TypedNode;
16
- type FlatContent = Record<string, FlatContentValue | undefined>;
17
- type ReplaceContentValue<T> = {
18
- [P in keyof T]: T[P] extends string | number | boolean | null | ReactNode ? ContentValue : T[P] extends object ? ReplaceContentValue<T[P]> : ReplaceContentValueArray<T[P]>;
19
- };
20
- type ReplaceContentValueArray<T> = T extends (infer U)[] ? ReplaceContentValue<U>[] : ReplaceContentValue<T>;
21
- type DeclarationContent<T = undefined> = (T extends undefined ? Content : ReplaceContentValue<T>) & {
22
- id: string;
23
- filePath?: string;
24
- };
25
-
26
- export type { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode };
@@ -1,17 +0,0 @@
1
- import { TranslationContent } from '../transpiler/content_transformers/translation/types.js';
2
- import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.js';
3
- import '@intlayer/config/client';
4
- import 'intlayer';
5
- import './nodeType.js';
6
-
7
- type RecursiveDictionaryValue = number | string | {
8
- [paramKey: string]: RecursiveDictionaryValue;
9
- } | RecursiveDictionaryValue[];
10
- type DictionaryValue = RecursiveDictionaryValue | TranslationContent<RecursiveDictionaryValue> | EnumerationContent<RecursiveDictionaryValue>;
11
- type Dictionary = {
12
- id: string;
13
- filePath: string;
14
- [key: string]: DictionaryValue;
15
- };
16
-
17
- export type { Dictionary, DictionaryValue, RecursiveDictionaryValue };
@@ -1,9 +0,0 @@
1
- export { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './declarationContent.js';
2
- export { NodeType } from './nodeType.js';
3
- export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './keyPath.js';
4
- export { Dictionary, DictionaryValue } from './dictionary.js';
5
- import 'react';
6
- import '../transpiler/content_transformers/translation/types.js';
7
- import '@intlayer/config/client';
8
- import 'intlayer';
9
- import '../transpiler/content_transformers/enumeration/enumeration.js';
@@ -1,17 +0,0 @@
1
- import { NodeType } from './nodeType.js';
2
-
3
- type ObjectExpressionNode = {
4
- type: 'ObjectExpression';
5
- key: string;
6
- };
7
- type ArrayExpressionNode = {
8
- type: 'ArrayExpression';
9
- key: number;
10
- };
11
- type TranslationOrEnumerationNode = {
12
- type: NodeType;
13
- key: string;
14
- };
15
- type KeyPath = ObjectExpressionNode | ArrayExpressionNode | TranslationOrEnumerationNode;
16
-
17
- export type { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode };
@@ -1,6 +0,0 @@
1
- declare enum NodeType {
2
- Translation = "translation",
3
- Enumeration = "enumeration"
4
- }
5
-
6
- export { NodeType };
@@ -1,6 +0,0 @@
1
- import { KeyPath } from '../types/keyPath.js';
2
- import '../types/nodeType.js';
3
-
4
- declare const isSameKeyPath: (keyPath1: KeyPath[], keyPath2: KeyPath[]) => boolean;
5
-
6
- export { isSameKeyPath };
@@ -1,5 +0,0 @@
1
- import { Locales } from '@intlayer/config/client';
2
-
3
- declare const getLocaleName: (locale: Locales) => string;
4
-
5
- export { getLocaleName };
@@ -1,16 +0,0 @@
1
- export { t } from './transpiler/content_transformers/translation/translation.mjs';
2
- export { getTranslationContent } from './transpiler/content_transformers/translation/getTranslationContent.mjs';
3
- export { CustomizableLanguageContent, LanguageContent, CustomLocales as Locales, TranslationContent } from './transpiler/content_transformers/translation/types.mjs';
4
- export { EnumerationContent, QuantityContent, enu } from './transpiler/content_transformers/enumeration/enumeration.mjs';
5
- export { getEnumerationContent } from './transpiler/content_transformers/enumeration/getEnumerationContent.mjs';
6
- export { findMatchingCondition } from './transpiler/content_transformers/enumeration/findMatchingCondition.mjs';
7
- export { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './types/declarationContent.mjs';
8
- export { NodeType } from './types/nodeType.mjs';
9
- export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './types/keyPath.mjs';
10
- export { Dictionary, DictionaryValue } from './types/dictionary.mjs';
11
- export { getLocaleName } from './getLocaleName.mjs';
12
- export { localeList } from './localeList.mjs';
13
- export { isSameKeyPath } from './utils/isSameKeyPath.mjs';
14
- import '@intlayer/config/client';
15
- import 'intlayer';
16
- import 'react';
@@ -1,5 +0,0 @@
1
- import { Locales } from '@intlayer/config/client';
2
-
3
- declare const localeList: Locales[];
4
-
5
- export { localeList };
@@ -1,39 +0,0 @@
1
- import { NodeType } from '../../../types/nodeType.mjs';
2
-
3
- type Positif = number | `${number}`;
4
- type Negatif = `-${number}`;
5
- type Numbers = Positif | Negatif;
6
- type Equal = Numbers;
7
- type EqualString = `=${Numbers}`;
8
- type Superior = `>${Numbers}`;
9
- type SuperiorOrEqual = `>=${Numbers}`;
10
- type Inferior = `<${Numbers}`;
11
- type InferiorOrEqual = `<=${Numbers}`;
12
- type EnterFormat = Equal | EqualString | Superior | SuperiorOrEqual | Inferior | InferiorOrEqual;
13
- type QuantityContent<Content> = Record<EnterFormat, Content>;
14
- type EnumerationContent<Content> = {
15
- nodeType: NodeType.Enumeration;
16
- [NodeType.Enumeration]: Partial<QuantityContent<Content>>;
17
- };
18
- /**
19
- * Function intended to be used to build intlayer dictionaries.
20
- *
21
- * Allow to pick a content based on a quantity.
22
- *
23
- * Usage:
24
- *
25
- * ```ts
26
- * const content = enu({
27
- * '<=-2.3': 'You have less than -2.3',
28
- * '<1': 'You have less than one',
29
- * '2': 'You have two',
30
- * '>=3': 'You have three or more',
31
- * });
32
- * ```
33
- *
34
- * The order of the keys will define the priority of the content.
35
- *
36
- */
37
- declare const enumeration: <Content>(content?: Partial<QuantityContent<Content>>) => EnumerationContent<Content>;
38
-
39
- export { type EnterFormat, type EnumerationContent, type QuantityContent, enumeration as enu };
@@ -1,33 +0,0 @@
1
- import { QuantityContent, EnterFormat } from './enumeration.mjs';
2
- import '../../../types/nodeType.mjs';
3
-
4
- /**
5
- * Find the matching condition for a quantity.
6
- *
7
- * Usage:
8
- *
9
- * ```ts
10
- * const key = findMatchingCondition({
11
- * '<=-2.3': 'You have less than -2.3',
12
- * '<1': 'You have less than one',
13
- * '2': 'You have two',
14
- * '>=3': 'You have three or more',
15
- * }, 2);
16
- * // '2'
17
- * ```
18
- *
19
- * The order of the keys will define the priority of the content.
20
- *
21
- * ```ts
22
- * const key = findMatchingCondition({
23
- * '<4': 'You have less than four',
24
- * '2': 'You have two',
25
- * }, 2);
26
- * // '<4'
27
- * ```
28
- *
29
- * If no keys match, the default key is '1'.
30
- */
31
- declare const findMatchingCondition: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => EnterFormat;
32
-
33
- export { findMatchingCondition };
@@ -1,32 +0,0 @@
1
- import { QuantityContent } from './enumeration.mjs';
2
- import '../../../types/nodeType.mjs';
3
-
4
- /**
5
- * Allow to pick a content based on a quantity.
6
- *
7
- * Usage:
8
- *
9
- * ```ts
10
- * const content = getEnumerationContent({
11
- * '<=-2.3': 'You have less than -2.3',
12
- * '<1': 'You have less than one',
13
- * '2': 'You have two',
14
- * '>=3': 'You have three or more',
15
- * }, 2);
16
- * // 'You have two'
17
- * ```
18
- *
19
- * The order of the keys will define the priority of the content.
20
- *
21
- * ```ts
22
- * const content = getEnumerationContent({
23
- * '<4': 'You have less than four',
24
- * '2': 'You have two',
25
- * }, 2);
26
- * // 'You have less than four'
27
- * ```
28
- *
29
- */
30
- declare const getEnumerationContent: <Content>(enumerationContent: QuantityContent<Content>, quantity: number) => Content;
31
-
32
- export { getEnumerationContent };
@@ -1,4 +0,0 @@
1
- export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration.mjs';
2
- export { getEnumerationContent } from './getEnumerationContent.mjs';
3
- export { findMatchingCondition } from './findMatchingCondition.mjs';
4
- import '../../../types/nodeType.mjs';
@@ -1,9 +0,0 @@
1
- export { t } from './translation/translation.mjs';
2
- export { getTranslationContent } from './translation/getTranslationContent.mjs';
3
- export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './translation/types.mjs';
4
- export { EnterFormat, EnumerationContent, QuantityContent, enu } from './enumeration/enumeration.mjs';
5
- export { getEnumerationContent } from './enumeration/getEnumerationContent.mjs';
6
- export { findMatchingCondition } from './enumeration/findMatchingCondition.mjs';
7
- import '@intlayer/config/client';
8
- import 'intlayer';
9
- import '../../types/nodeType.mjs';
@@ -1,28 +0,0 @@
1
- import { Locales } from '@intlayer/config/client';
2
- import { CustomizableLanguageContent } from './types.mjs';
3
- import 'intlayer';
4
- import '../../../types/nodeType.mjs';
5
-
6
- type GetTranslationContent = <Content = string>(languageContent: CustomizableLanguageContent<Content>, locale: Locales) => Content;
7
- /**
8
- *
9
- * Allow to pick a content based on a locale.
10
- * If not locale found, it will return the content related to the default locale.
11
- *
12
- * Usage:
13
- *
14
- * ```ts
15
- * const content = getTranslationContent({
16
- * en: 'Hello',
17
- * fr: 'Bonjour',
18
- * }, 'fr');
19
- * // 'Bonjour'
20
- * ```
21
- *
22
- * Using TypeScript:
23
- * - this function will require each locale to be defined if defined in the project configuration.
24
- * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
25
- */
26
- declare const getTranslationContent: GetTranslationContent;
27
-
28
- export { getTranslationContent };
@@ -1,6 +0,0 @@
1
- export { t } from './translation.mjs';
2
- export { getTranslationContent } from './getTranslationContent.mjs';
3
- export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './types.mjs';
4
- import '@intlayer/config/client';
5
- import 'intlayer';
6
- import '../../../types/nodeType.mjs';
@@ -1,28 +0,0 @@
1
- import { TranslationContent } from './types.mjs';
2
- import '@intlayer/config/client';
3
- import 'intlayer';
4
- import '../../../types/nodeType.mjs';
5
-
6
- /**
7
- *
8
- * Function intended to be used to build intlayer dictionaries.
9
- *
10
- * Get the content of a translation based on the locale.
11
- *
12
- * Usage:
13
- *
14
- * ```ts
15
- * translation<string>({
16
- * "en": "Hello",
17
- * "fr": "Bonjour",
18
- * // ... any other available locale
19
- * })
20
- * ```
21
- *
22
- * Using TypeScript:
23
- * - this function require each locale to be defined if defined in the project configuration.
24
- * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.
25
- */
26
- declare const translation: <Content = string>(content?: any) => TranslationContent<Content>;
27
-
28
- export { translation as t };
@@ -1,62 +0,0 @@
1
- import { LocalesValues } from '@intlayer/config/client';
2
- import { IConfigLocales } from 'intlayer';
3
- import { NodeType } from '../../../types/nodeType.mjs';
4
-
5
- /**
6
- * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
7
- * If not, it will return never
8
- */
9
- type ConfigLocales = keyof IConfigLocales<unknown>;
10
- /**
11
- * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
12
- * If not, it will return all available locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
13
- */
14
- type CustomLocales = ConfigLocales extends never ? LocalesValues : ConfigLocales;
15
- /**
16
- * Record of locales and content
17
- *
18
- * const myVar1: LanguageContent<string> = {
19
- * "en": "",
20
- * "fr": ""
21
- * }
22
- *
23
- * const myVar2: LanguageContent<{age: number, name: string}> = {
24
- * "en": {age: 1, name: "test"},
25
- * "fr": {age: 1, name: "test"}
26
- * }
27
- */
28
- type LanguageContent<Content> = Partial<Record<LocalesValues, Content>>;
29
- /**
30
- * Valid
31
- * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {
32
- * "en": "test",
33
- * "fr": "test"
34
- * }
35
- *
36
- * const test: CustomizableLanguageContent<number> = {
37
- * "fr": 1,
38
- * "en": 1,
39
- * ... any other available locale
40
- * }
41
- *
42
- * Invalid
43
- *
44
- * const test: CustomizableLanguageContent<string> = {
45
- * "en": "test",
46
- * "fr": "test",
47
- * "sss": "test" // Does not exist in Locales
48
- * }
49
- *
50
- * const test: CustomizableLanguageContent<string, Locales.ENGLISH | Locales.FRENCH> = {
51
- * "fr": "test"
52
- * // Locales.ENGLISH is missing
53
- * }
54
- *
55
- */
56
- type CustomizableLanguageContent<Content = string> = ConfigLocales extends never ? LanguageContent<Content> : IConfigLocales<Content>;
57
- type TranslationContent<Content> = {
58
- nodeType: NodeType.Translation;
59
- [NodeType.Translation]: LanguageContent<Content>;
60
- };
61
-
62
- export type { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent };
@@ -1,9 +0,0 @@
1
- export { t } from './content_transformers/translation/translation.mjs';
2
- export { getTranslationContent } from './content_transformers/translation/getTranslationContent.mjs';
3
- export { ConfigLocales, CustomLocales, CustomizableLanguageContent, LanguageContent, TranslationContent } from './content_transformers/translation/types.mjs';
4
- export { EnterFormat, EnumerationContent, QuantityContent, enu } from './content_transformers/enumeration/enumeration.mjs';
5
- export { getEnumerationContent } from './content_transformers/enumeration/getEnumerationContent.mjs';
6
- export { findMatchingCondition } from './content_transformers/enumeration/findMatchingCondition.mjs';
7
- import '@intlayer/config/client';
8
- import 'intlayer';
9
- import '../types/nodeType.mjs';
@@ -1,26 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { TranslationContent } from '../transpiler/content_transformers/translation/types.mjs';
3
- import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.mjs';
4
- import '@intlayer/config/client';
5
- import 'intlayer';
6
- import './nodeType.mjs';
7
-
8
- type TypedNode = TranslationContent<unknown> | EnumerationContent<unknown>;
9
- type ContentValue = string | string[] | number | number[] | {
10
- [key: string]: ContentValue;
11
- } | (() => ContentValue) | Promise<ContentValue> | TypedNode;
12
- type Content = Record<string, ContentValue | ContentValue[] | undefined>;
13
- type FlatContentValue = string | {
14
- [key: string]: FlatContentValue;
15
- } | TypedNode;
16
- type FlatContent = Record<string, FlatContentValue | undefined>;
17
- type ReplaceContentValue<T> = {
18
- [P in keyof T]: T[P] extends string | number | boolean | null | ReactNode ? ContentValue : T[P] extends object ? ReplaceContentValue<T[P]> : ReplaceContentValueArray<T[P]>;
19
- };
20
- type ReplaceContentValueArray<T> = T extends (infer U)[] ? ReplaceContentValue<U>[] : ReplaceContentValue<T>;
21
- type DeclarationContent<T = undefined> = (T extends undefined ? Content : ReplaceContentValue<T>) & {
22
- id: string;
23
- filePath?: string;
24
- };
25
-
26
- export type { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode };
@@ -1,17 +0,0 @@
1
- import { TranslationContent } from '../transpiler/content_transformers/translation/types.mjs';
2
- import { EnumerationContent } from '../transpiler/content_transformers/enumeration/enumeration.mjs';
3
- import '@intlayer/config/client';
4
- import 'intlayer';
5
- import './nodeType.mjs';
6
-
7
- type RecursiveDictionaryValue = number | string | {
8
- [paramKey: string]: RecursiveDictionaryValue;
9
- } | RecursiveDictionaryValue[];
10
- type DictionaryValue = RecursiveDictionaryValue | TranslationContent<RecursiveDictionaryValue> | EnumerationContent<RecursiveDictionaryValue>;
11
- type Dictionary = {
12
- id: string;
13
- filePath: string;
14
- [key: string]: DictionaryValue;
15
- };
16
-
17
- export type { Dictionary, DictionaryValue, RecursiveDictionaryValue };
@@ -1,9 +0,0 @@
1
- export { Content, ContentValue, DeclarationContent, FlatContent, FlatContentValue, TypedNode } from './declarationContent.mjs';
2
- export { NodeType } from './nodeType.mjs';
3
- export { ArrayExpressionNode, KeyPath, ObjectExpressionNode, TranslationOrEnumerationNode } from './keyPath.mjs';
4
- export { Dictionary, DictionaryValue } from './dictionary.mjs';
5
- import 'react';
6
- import '../transpiler/content_transformers/translation/types.mjs';
7
- import '@intlayer/config/client';
8
- import 'intlayer';
9
- import '../transpiler/content_transformers/enumeration/enumeration.mjs';