smartloc 2.0.2 → 2.0.4

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 (100) hide show
  1. package/adapters/adapter-base.d.ts +12 -0
  2. package/adapters/adapter-base.js +56 -0
  3. package/adapters/adapter-base.js.map +1 -0
  4. package/adapters/index.d.ts +4 -0
  5. package/adapters/index.js +32 -0
  6. package/adapters/index.js.map +1 -0
  7. package/adapters/json.d.ts +6 -0
  8. package/adapters/json.js +23 -0
  9. package/adapters/json.js.map +1 -0
  10. package/adapters/xliff.d.ts +6 -0
  11. package/adapters/xliff.js +35 -0
  12. package/adapters/xliff.js.map +1 -0
  13. package/cli/cli.d.ts +2 -0
  14. package/cli/cli.js +129 -0
  15. package/cli/cli.js.map +1 -0
  16. package/cli/collect.d.ts +14 -0
  17. package/{src/cli/collect.ts → cli/collect.js} +59 -75
  18. package/cli/collect.js.map +1 -0
  19. package/cli/interfaces.js +3 -0
  20. package/cli/interfaces.js.map +1 -0
  21. package/cli/reconciliate.d.ts +6 -0
  22. package/{src/cli/reconciliate.ts → cli/reconciliate.js} +35 -40
  23. package/cli/reconciliate.js.map +1 -0
  24. package/cli/utils.d.ts +6 -0
  25. package/{src/cli/utils.ts → cli/utils.js} +16 -12
  26. package/cli/utils.js.map +1 -0
  27. package/core/default-locale.d.ts +10 -0
  28. package/{src/core/default-locale.tsx → core/default-locale.js} +23 -28
  29. package/core/default-locale.js.map +1 -0
  30. package/{src/core/interfaces.ts → core/interfaces.d.ts} +15 -20
  31. package/core/interfaces.js +3 -0
  32. package/core/interfaces.js.map +1 -0
  33. package/core/json-utils.d.ts +19 -0
  34. package/{src/core/json-utils.ts → core/json-utils.js} +27 -33
  35. package/core/json-utils.js.map +1 -0
  36. package/core/literal.d.ts +13 -0
  37. package/{src/core/literal.ts → core/literal.js} +20 -19
  38. package/core/literal.js.map +1 -0
  39. package/core/load.d.ts +32 -0
  40. package/core/load.js +50 -0
  41. package/core/load.js.map +1 -0
  42. package/core/locale-list.d.ts +27 -0
  43. package/{src/core/locale-list.ts → core/locale-list.js} +35 -38
  44. package/core/locale-list.js.map +1 -0
  45. package/core/locale.d.ts +15 -0
  46. package/{src/core/locale.tsx → core/locale.js} +29 -28
  47. package/core/locale.js.map +1 -0
  48. package/core/smartloc.d.ts +39 -0
  49. package/{src/core/smartloc.tsx → core/smartloc.js} +104 -122
  50. package/core/smartloc.js.map +1 -0
  51. package/core/tag.d.ts +13 -0
  52. package/core/tag.js +26 -0
  53. package/core/tag.js.map +1 -0
  54. package/core/utils.d.ts +4 -0
  55. package/core/utils.js +30 -0
  56. package/core/utils.js.map +1 -0
  57. package/express.d.ts +12 -0
  58. package/{src/express.ts → express.js} +33 -41
  59. package/express.js.map +1 -0
  60. package/graphql.d.ts +13 -0
  61. package/{src/graphql.ts → graphql.js} +62 -74
  62. package/graphql.js.map +1 -0
  63. package/index.js +30 -1
  64. package/index.js.map +1 -0
  65. package/node/index.d.ts +1 -0
  66. package/node/index.js +18 -0
  67. package/node/index.js.map +1 -0
  68. package/node/load.d.ts +12 -0
  69. package/node/load.js +37 -0
  70. package/node/load.js.map +1 -0
  71. package/package.json +3 -22
  72. package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +0 -111
  73. package/.vscode/launch.json +0 -65
  74. package/.vscode/settings.json +0 -14
  75. package/.vscode/tasks.json +0 -27
  76. package/build/README.md +0 -225
  77. package/build/package.json +0 -60
  78. package/bun.lock +0 -310
  79. package/samples/express/main.ts +0 -37
  80. package/samples/express/package.json +0 -10
  81. package/samples/graphql/main.ts +0 -73
  82. package/samples/graphql/package.json +0 -15
  83. package/src/adapters/adapter-base.ts +0 -58
  84. package/src/adapters/index.ts +0 -31
  85. package/src/adapters/json.ts +0 -18
  86. package/src/adapters/xliff.ts +0 -30
  87. package/src/cli/cli.ts +0 -137
  88. package/src/core/load.ts +0 -82
  89. package/src/core/tag.ts +0 -48
  90. package/src/core/utils.tsx +0 -24
  91. package/src/node/index.ts +0 -1
  92. package/src/node/load.ts +0 -32
  93. package/test/collect.spec.ts +0 -45
  94. package/test/reconciliation.spec.ts +0 -132
  95. package/test/serialization.spec.ts +0 -162
  96. package/test/translation.spec.ts +0 -61
  97. package/tsconfig.json +0 -37
  98. package/tslint.json +0 -103
  99. /package/{src/cli/interfaces.ts → cli/interfaces.d.ts} +0 -0
  100. /package/{src/index.ts → index.d.ts} +0 -0
@@ -1,61 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'bun:test';
2
- import {loc, setDefaultLocale, addLocale, withLocales, clearLocales} from '../src';
3
-
4
-
5
- describe('Translation', () => {
6
-
7
- beforeEach(() => {
8
- clearLocales();
9
- setDefaultLocale('en-US');
10
- })
11
-
12
- it ('uses default when no context', () => {
13
- expect(loc('def')`this uses ${'en'} as default`.toString())
14
- .toEqual('this uses en as default');
15
- });
16
-
17
-
18
- it ('translates in context', () => {
19
- addLocale('fr-FR', {
20
- 'def': 'la langue par défaut est "{0}"',
21
- });
22
- const translated = withLocales(['fr-FR'], () => {
23
- return loc('def')`this uses ${'en'} as default`.toString()
24
- });
25
- expect(translated).toEqual('la langue par défaut est "en"');
26
- });
27
-
28
-
29
- it('fallsback on second language when main misses a translation key', () => {
30
- addLocale('gb', {});
31
- addLocale('fr-FR', {
32
- 'def': 'la langue par défaut est "{0}"',
33
- });
34
- const translated = withLocales(['gb', 'fr-FR'], () => {
35
- return loc('def')`this uses ${'en'} as default`.toString()
36
- });
37
- expect(translated).toEqual('la langue par défaut est "en"');
38
- });
39
-
40
-
41
- it ('fallsback on default language when no key', () => {
42
- addLocale('gb', {});
43
- addLocale('fr-FR', {});
44
- const translated = withLocales(['gb', 'fr-FR'], () => {
45
- return loc('def')`this uses ${'en'} as default`.toString()
46
- })
47
- expect(translated).toEqual('this uses en as default');
48
- });
49
-
50
-
51
- it ('supports auto ids', () => {
52
- addLocale('fr-FR', {
53
- // this is the sha1 of 'Bonjour'
54
- 'sha1.f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0': 'Bonjour',
55
- });
56
- const translated = withLocales(['fr-FR'], () => {
57
- return loc`Hello`.toString()
58
- })
59
- expect(translated).toEqual('Bonjour');
60
- });
61
- });
package/tsconfig.json DELETED
@@ -1,37 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
- "module": "commonjs",
6
- "outDir": "bin",
7
- "sourceMap": true,
8
- "jsx": "react-jsx",
9
- "newLine": "lf",
10
- "esModuleInterop": true,
11
- "keyofStringsOnly": false,
12
- "typeRoots": [],
13
- "declaration": true,
14
- "skipLibCheck": true,
15
- "moduleResolution": "node",
16
- "experimentalDecorators": true,
17
- "emitDecoratorMetadata": true,
18
-
19
- /* Linting */
20
- "strict": true,
21
- "noUnusedLocals": true,
22
- "noUnusedParameters": true,
23
- "erasableSyntaxOnly": false,
24
- "noUncheckedSideEffectImports": true,
25
- "noFallthroughCasesInSwitch": true,
26
- // "noUncheckedIndexedAccess": true,
27
- "noImplicitOverride": true,
28
-
29
- "baseUrl": "."
30
- },
31
- "include": [
32
- "src/**/*.ts"
33
- , "src/core/renderer.tsx" ],
34
- "exclude": [
35
- "node_modules"
36
- ]
37
- }
package/tslint.json DELETED
@@ -1,103 +0,0 @@
1
- {
2
- "linterOptions": {
3
- "exclude": [
4
- "node_modules"
5
- ]
6
- },
7
- "tslint.exclude": ["node_modules"],
8
- "rules": {
9
- "await-only-promise": true,
10
- "arrow-return-shorthand": true,
11
- "callable-types": true,
12
- "class-name": true,
13
- "no-floating-promises": true,
14
- "comment-format": [
15
- true,
16
- "check-space"
17
- ],
18
- "deprecation": {
19
- "severity": "warn"
20
- },
21
- "forin": true,
22
- "import-blacklist": [
23
- true,
24
- "rxjs/Rx",
25
- "rxjs/internal/operators"
26
- ],
27
- "interface-over-type-literal": true,
28
- "label-position": true,
29
- "member-access": false,
30
- "member-ordering": [
31
- true,
32
- {
33
- "order": [
34
- "static-field",
35
- "instance-field",
36
- "static-method",
37
- "instance-method"
38
- ]
39
- }
40
- ],
41
- "no-arg": true,
42
- "no-bitwise": true,
43
- "no-console": [
44
- true,
45
- "debug",
46
- "info",
47
- "time",
48
- "timeEnd",
49
- "trace"
50
- ],
51
- "no-construct": true,
52
- "no-debugger": true,
53
- "no-duplicate-super": true,
54
- "no-empty": false,
55
- "no-empty-interface": true,
56
- "no-eval": true,
57
- "no-inferrable-types": [
58
- true,
59
- "ignore-params"
60
- ],
61
- "no-misused-new": true,
62
- "no-non-null-assertion": true,
63
- "no-shadowed-variable": true,
64
- "no-string-literal": false,
65
- "no-string-throw": true,
66
- "no-switch-case-fall-through": true,
67
- "no-unnecessary-initializer": true,
68
- "no-unused-expression": true,
69
- "no-use-before-declare": true,
70
- "no-var-keyword": true,
71
- "object-literal-sort-keys": false,
72
- "prefer-const": true,
73
- "quotemark": [
74
- true,
75
- "single"
76
- ],
77
- "radix": true,
78
- "triple-equals": [
79
- true,
80
- "allow-null-check"
81
- ],
82
- "unified-signatures": true,
83
- "variable-name": false,
84
- "whitespace": [
85
- true,
86
- "check-branch",
87
- "check-decl",
88
- "check-operator",
89
- "check-separator",
90
- "check-type"
91
- ],
92
- "no-output-on-prefix": true,
93
- "use-input-property-decorator": true,
94
- "use-output-property-decorator": true,
95
- "use-host-property-decorator": true,
96
- "no-input-rename": true,
97
- "no-output-rename": true,
98
- "use-life-cycle-interface": true,
99
- "use-pipe-transform-interface": true,
100
- "component-class-suffix": true,
101
- "directive-class-suffix": true
102
- }
103
- }
File without changes
File without changes