smartloc 1.2.2 → 2.0.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.
- package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +111 -0
- package/.vscode/launch.json +65 -0
- package/.vscode/settings.json +14 -0
- package/.vscode/tasks.json +27 -0
- package/README.md +225 -0
- package/build/README.md +225 -0
- package/build/package.json +60 -0
- package/bun.lock +310 -0
- package/index.js +1 -26
- package/package.json +17 -18
- package/samples/express/main.ts +37 -0
- package/samples/express/package.json +10 -0
- package/samples/graphql/main.ts +73 -0
- package/samples/graphql/package.json +15 -0
- package/src/adapters/adapter-base.ts +58 -0
- package/src/adapters/index.ts +31 -0
- package/src/adapters/json.ts +18 -0
- package/src/adapters/xliff.ts +30 -0
- package/src/cli/cli.ts +137 -0
- package/src/cli/collect.ts +196 -0
- package/src/cli/interfaces.ts +7 -0
- package/src/cli/reconciliate.ts +119 -0
- package/src/cli/utils.ts +36 -0
- package/src/core/default-locale.tsx +54 -0
- package/src/core/interfaces.ts +49 -0
- package/{core/json-utils.js → src/core/json-utils.ts} +45 -34
- package/src/core/literal.ts +66 -0
- package/src/core/load.ts +82 -0
- package/src/core/locale-list.ts +128 -0
- package/src/core/locale.tsx +75 -0
- package/src/core/smartloc.tsx +338 -0
- package/src/core/tag.ts +40 -0
- package/src/core/utils.tsx +24 -0
- package/src/express.ts +93 -0
- package/{graphql.js → src/graphql.ts} +80 -68
- package/src/index.ts +7 -0
- package/src/node/index.ts +1 -0
- package/src/node/load.ts +32 -0
- package/test/collect.spec.ts +45 -0
- package/test/reconciliation.spec.ts +132 -0
- package/test/serialization.spec.ts +162 -0
- package/test/translation.spec.ts +61 -0
- package/tsconfig.json +37 -0
- package/tslint.json +103 -0
- package/adapters/adapter-base.d.ts +0 -10
- package/adapters/adapter-base.js +0 -46
- package/adapters/adapter-base.js.map +0 -1
- package/adapters/index.d.ts +0 -3
- package/adapters/index.js +0 -33
- package/adapters/index.js.map +0 -1
- package/adapters/json.d.ts +0 -6
- package/adapters/json.js +0 -22
- package/adapters/json.js.map +0 -1
- package/adapters/xliff.d.ts +0 -6
- package/adapters/xliff.js +0 -32
- package/adapters/xliff.js.map +0 -1
- package/cli/cli.d.ts +0 -2
- package/cli/cli.js +0 -128
- package/cli/cli.js.map +0 -1
- package/cli/collect.d.ts +0 -12
- package/cli/collect.js +0 -151
- package/cli/collect.js.map +0 -1
- package/cli/interfaces.d.ts +0 -25
- package/cli/interfaces.js +0 -3
- package/cli/interfaces.js.map +0 -1
- package/cli/reconciliate.d.ts +0 -6
- package/cli/reconciliate.js +0 -108
- package/cli/reconciliate.js.map +0 -1
- package/cli/utils.d.ts +0 -7
- package/cli/utils.js +0 -54
- package/cli/utils.js.map +0 -1
- package/core/base-loc.d.ts +0 -3
- package/core/base-loc.js +0 -20
- package/core/base-loc.js.map +0 -1
- package/core/default-locale.d.ts +0 -8
- package/core/default-locale.js +0 -42
- package/core/default-locale.js.map +0 -1
- package/core/interfaces.d.ts +0 -32
- package/core/interfaces.js +0 -3
- package/core/interfaces.js.map +0 -1
- package/core/json-utils.d.ts +0 -19
- package/core/json-utils.js.map +0 -1
- package/core/literal.d.ts +0 -9
- package/core/literal.js +0 -52
- package/core/literal.js.map +0 -1
- package/core/locale-list.d.ts +0 -19
- package/core/locale-list.js +0 -84
- package/core/locale-list.js.map +0 -1
- package/core/locale.d.ts +0 -13
- package/core/locale.js +0 -34
- package/core/locale.js.map +0 -1
- package/core/locstr-array.d.ts +0 -10
- package/core/locstr-array.js +0 -48
- package/core/locstr-array.js.map +0 -1
- package/core/smartloc.d.ts +0 -64
- package/core/smartloc.js +0 -222
- package/core/smartloc.js.map +0 -1
- package/core/tag.d.ts +0 -5
- package/core/tag.js +0 -17
- package/core/tag.js.map +0 -1
- package/core/utils.d.ts +0 -1
- package/core/utils.js +0 -13
- package/core/utils.js.map +0 -1
- package/express.d.ts +0 -12
- package/express.js +0 -85
- package/express.js.map +0 -1
- package/graphql.d.ts +0 -12
- package/graphql.js.map +0 -1
- package/index.d.ts +0 -7
- package/index.js.map +0 -1
- package/node/index.d.ts +0 -1
- package/node/index.js +0 -14
- package/node/index.js.map +0 -1
- package/node/load.d.ts +0 -12
- package/node/load.js +0 -44
- package/node/load.js.map +0 -1
|
@@ -0,0 +1,61 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IFormatAdapter, Translation } from '../cli/interfaces';
|
|
2
|
-
export declare abstract class AdapterBase implements IFormatAdapter {
|
|
3
|
-
private target;
|
|
4
|
-
constructor(target: string);
|
|
5
|
-
loadFile(filePath: string): Promise<Translation>;
|
|
6
|
-
protected abstract doLoadFile(content: string): Promise<Translation>;
|
|
7
|
-
loadLocales(locales: string[]): Promise<Translation[]>;
|
|
8
|
-
write(translation: Translation): Promise<void>;
|
|
9
|
-
protected abstract contentFor(translation: Translation): Promise<string>;
|
|
10
|
-
}
|
package/adapters/adapter-base.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AdapterBase = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
class AdapterBase {
|
|
10
|
-
constructor(target) {
|
|
11
|
-
this.target = target;
|
|
12
|
-
}
|
|
13
|
-
async loadFile(filePath) {
|
|
14
|
-
if (!await fs_extra_1.default.pathExists(filePath)) {
|
|
15
|
-
return {
|
|
16
|
-
resources: {},
|
|
17
|
-
targetLanguage: null,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const content = await fs_extra_1.default.readFile(filePath, 'utf8');
|
|
21
|
-
return await this.doLoadFile(content);
|
|
22
|
-
}
|
|
23
|
-
async loadLocales(locales) {
|
|
24
|
-
if (!await fs_extra_1.default.pathExists(this.target)) {
|
|
25
|
-
return locales.map(x => ({
|
|
26
|
-
resources: {},
|
|
27
|
-
targetLanguage: x,
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
const ret = [];
|
|
31
|
-
for (const f of locales) {
|
|
32
|
-
const t = await this.loadFile(path_1.default.join(this.target, `${f}.json`));
|
|
33
|
-
t.targetLanguage = f;
|
|
34
|
-
ret.push(t);
|
|
35
|
-
}
|
|
36
|
-
return ret;
|
|
37
|
-
}
|
|
38
|
-
async write(translation) {
|
|
39
|
-
await fs_extra_1.default.ensureDir(this.target);
|
|
40
|
-
const content = await this.contentFor(translation);
|
|
41
|
-
const toFile = path_1.default.join(this.target, translation.targetLanguage + '.json');
|
|
42
|
-
await fs_extra_1.default.writeFile(toFile, content, 'utf8');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.AdapterBase = AdapterBase;
|
|
46
|
-
//# sourceMappingURL=adapter-base.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-base.js","sourceRoot":"","sources":["../../src/adapters/adapter-base.ts"],"names":[],"mappings":";;;;;;AACA,wDAA0B;AAC1B,gDAAwB;AAExB,MAAsB,WAAW;IAE7B,YAAoB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAClC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC3B,IAAI,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAChC,OAAO;gBACH,SAAS,EAAE,EAAE;gBACb,cAAc,EAAE,IAAI;aACvB,CAAC;SACL;QACD,MAAM,OAAO,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAID,KAAK,CAAC,WAAW,CAAC,OAAiB;QAC/B,IAAI,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACnC,OAAO,OAAO,CAAC,GAAG,CAAc,CAAC,CAAC,EAAE,CAAC,CAAC;gBAClC,SAAS,EAAE,EAAE;gBACb,cAAc,EAAE,CAAC;aACpB,CAAC,CAAC,CAAC;SACP;QACD,MAAM,GAAG,GAAkB,EAAE,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;YACrB,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YACnE,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC;YACrB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACf;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,WAAwB;QAChC,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,cAAc,GAAG,OAAO,CAAC,CAAC;QAC5E,MAAM,kBAAE,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;CAGJ;AA1CD,kCA0CC"}
|
package/adapters/index.d.ts
DELETED
package/adapters/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadLocaleFrom = exports.getAdapter = void 0;
|
|
4
|
-
const xliff_1 = require("./xliff");
|
|
5
|
-
const json_1 = require("./json");
|
|
6
|
-
function getAdapter(format, dir) {
|
|
7
|
-
switch (format) {
|
|
8
|
-
case 'xliff':
|
|
9
|
-
return new xliff_1.XliffAdapter(dir);
|
|
10
|
-
case 'json':
|
|
11
|
-
return new json_1.JsonAdapter(dir);
|
|
12
|
-
default:
|
|
13
|
-
throw new Error('Unknown translation format: ' + format);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.getAdapter = getAdapter;
|
|
17
|
-
async function loadLocaleFrom(path) {
|
|
18
|
-
const [ext] = /\.[a-z]+$/.exec(path.toLowerCase()) || [null];
|
|
19
|
-
let adapter;
|
|
20
|
-
switch (ext) {
|
|
21
|
-
case '.json':
|
|
22
|
-
adapter = new json_1.JsonAdapter(null);
|
|
23
|
-
break;
|
|
24
|
-
case '.xlf':
|
|
25
|
-
adapter = new xliff_1.XliffAdapter(null);
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
return await adapter.loadFile(path);
|
|
31
|
-
}
|
|
32
|
-
exports.loadLocaleFrom = loadLocaleFrom;
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
package/adapters/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":";;;AACA,mCAAuC;AACvC,iCAAqC;AAErC,SAAgB,UAAU,CAAC,MAAc,EAAE,GAAW;IAClD,QAAQ,MAAM,EAAE;QACZ,KAAK,OAAO;YACR,OAAO,IAAI,oBAAY,CAAC,GAAG,CAAC,CAAC;QACjC,KAAK,MAAM;YACP,OAAO,IAAI,kBAAW,CAAC,GAAG,CAAC,CAAC;QAChC;YACI,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,MAAM,CAAC,CAAC;KAChE;AACL,CAAC;AATD,gCASC;AAEM,KAAK,UAAU,cAAc,CAAC,IAAY;IAC7C,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,OAAuB,CAAC;IAC5B,QAAQ,GAAG,EAAE;QACT,KAAK,OAAO;YACR,OAAO,GAAG,IAAI,kBAAW,CAAC,IAAI,CAAC,CAAC;YAChC,MAAM;QACV,KAAK,MAAM;YACP,OAAO,GAAG,IAAI,oBAAY,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM;QACV;YACI,OAAO,IAAI,CAAC;KACnB;IACD,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAdD,wCAcC"}
|
package/adapters/json.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Translation } from '../cli/interfaces';
|
|
2
|
-
import { AdapterBase } from './adapter-base';
|
|
3
|
-
export declare class JsonAdapter extends AdapterBase {
|
|
4
|
-
protected doLoadFile(content: string): Promise<Translation>;
|
|
5
|
-
protected contentFor(translation: Translation): Promise<any>;
|
|
6
|
-
}
|
package/adapters/json.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.JsonAdapter = void 0;
|
|
7
|
-
const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
|
|
8
|
-
const utils_1 = require("../cli/utils");
|
|
9
|
-
const adapter_base_1 = require("./adapter-base");
|
|
10
|
-
class JsonAdapter extends adapter_base_1.AdapterBase {
|
|
11
|
-
async doLoadFile(content) {
|
|
12
|
-
const parsed = JSON.parse(content);
|
|
13
|
-
return utils_1.ungroupTranslation(parsed);
|
|
14
|
-
}
|
|
15
|
-
async contentFor(translation) {
|
|
16
|
-
const data = utils_1.toGroupedTranslation(translation);
|
|
17
|
-
const content = json_stable_stringify_1.default(data, { space: ' ' });
|
|
18
|
-
return content;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.JsonAdapter = JsonAdapter;
|
|
22
|
-
//# sourceMappingURL=json.js.map
|
package/adapters/json.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/adapters/json.ts"],"names":[],"mappings":";;;;;;AAGA,kFAA+C;AAC/C,wCAAwE;AAExE,iDAA6C;AAE7C,MAAa,WAAY,SAAQ,0BAAW;IAE9B,KAAK,CAAC,UAAU,CAAC,OAAe;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAuB,CAAC;QACzD,OAAO,0BAAkB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,UAAU,CAAC,WAAwB;QAC/C,MAAM,IAAI,GAAG,4BAAoB,CAAC,WAAW,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,+BAAU,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAZD,kCAYC"}
|
package/adapters/xliff.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Translation } from '../cli/interfaces';
|
|
2
|
-
import { AdapterBase } from './adapter-base';
|
|
3
|
-
export declare class XliffAdapter extends AdapterBase {
|
|
4
|
-
protected doLoadFile(content: string): Promise<Translation>;
|
|
5
|
-
protected contentFor(translation: Translation): Promise<string>;
|
|
6
|
-
}
|
package/adapters/xliff.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.XliffAdapter = void 0;
|
|
7
|
-
const js2xliff_1 = __importDefault(require("xliff/js2xliff"));
|
|
8
|
-
const xliff2js_1 = __importDefault(require("xliff/xliff2js"));
|
|
9
|
-
const utils_1 = require("../cli/utils");
|
|
10
|
-
const adapter_base_1 = require("./adapter-base");
|
|
11
|
-
class XliffAdapter extends adapter_base_1.AdapterBase {
|
|
12
|
-
async doLoadFile(content) {
|
|
13
|
-
const parsed = await new Promise((res, rej) => xliff2js_1.default(content, (err, val) => err ? rej(err) : res(val)));
|
|
14
|
-
return utils_1.ungroupTranslation(parsed);
|
|
15
|
-
}
|
|
16
|
-
async contentFor(translation) {
|
|
17
|
-
const data = utils_1.toGroupedTranslation(translation);
|
|
18
|
-
return await new Promise((res, rej) => js2xliff_1.default(data, async (err, result) => {
|
|
19
|
-
if (err) {
|
|
20
|
-
return rej(err);
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
res(result);
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
rej(e);
|
|
27
|
-
}
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.XliffAdapter = XliffAdapter;
|
|
32
|
-
//# sourceMappingURL=xliff.js.map
|
package/adapters/xliff.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xliff.js","sourceRoot":"","sources":["../../src/adapters/xliff.ts"],"names":[],"mappings":";;;;;;AAEA,8DAAsC;AACtC,8DAAsC;AAEtC,wCAAwE;AACxE,iDAA6C;AAE7C,MAAa,YAAa,SAAQ,0BAAW;IAE/B,KAAK,CAAC,UAAU,CAAC,OAAe;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,kBAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/H,OAAO,0BAAkB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAES,KAAK,CAAC,UAAU,CAAC,WAAwB;QAC/C,MAAM,IAAI,GAAG,4BAAoB,CAAC,WAAW,CAAC,CAAC;QAC/C,OAAO,MAAM,IAAI,OAAO,CAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,kBAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;YAChF,IAAI,GAAG,EAAE;gBACL,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;aACnB;YACD,IAAI;gBACA,GAAG,CAAC,MAAM,CAAC,CAAC;aACf;YAAC,OAAO,CAAC,EAAE;gBACR,GAAG,CAAC,CAAC,CAAC,CAAC;aACV;QACL,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AApBD,oCAoBC"}
|
package/cli/cli.d.ts
DELETED
package/cli/cli.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const collect_1 = require("./collect");
|
|
10
|
-
const reconciliate_1 = require("./reconciliate");
|
|
11
|
-
const adapters_1 = require("../adapters");
|
|
12
|
-
// === arguments parsing ===
|
|
13
|
-
function isValidLocale(x) {
|
|
14
|
-
return typeof x === 'string' && !!x && /^[a-zA-Z]+(\-[a-zA-Z]+)?$/.test(x);
|
|
15
|
-
}
|
|
16
|
-
function defaultArgs(b) {
|
|
17
|
-
return b.positional('format', {
|
|
18
|
-
describe: 'The output format',
|
|
19
|
-
choices: ['json', 'xliff'],
|
|
20
|
-
default: 'xliff',
|
|
21
|
-
})
|
|
22
|
-
.positional('outDir', {
|
|
23
|
-
describe: 'The translation output directory',
|
|
24
|
-
default: 'i18n',
|
|
25
|
-
normalize: true,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
const ret = yargs_1.default
|
|
29
|
-
.scriptName('smartloc')
|
|
30
|
-
.command('add', 'Add a new locale', b => defaultArgs(b).demandCommand(), args => {
|
|
31
|
-
console.log(args);
|
|
32
|
-
})
|
|
33
|
-
.command('collect', 'Collects all strings to translate', b => defaultArgs(b)
|
|
34
|
-
.positional('source', {
|
|
35
|
-
describe: 'The source directory where to look for translations (defaults to current working directory)',
|
|
36
|
-
type: 'string',
|
|
37
|
-
normalize: true,
|
|
38
|
-
})
|
|
39
|
-
.positional('defaultLocale', {
|
|
40
|
-
description: 'Sets the default locale (the locale used in code for your strings)',
|
|
41
|
-
type: 'string',
|
|
42
|
-
coerce: x => {
|
|
43
|
-
if (!isValidLocale(x)) {
|
|
44
|
-
console.error('Invalid locale ' + x);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
return x;
|
|
48
|
-
},
|
|
49
|
-
})
|
|
50
|
-
.positional('generateDefault', {
|
|
51
|
-
description: 'Also generates a translation file for the default locale',
|
|
52
|
-
type: 'boolean',
|
|
53
|
-
})
|
|
54
|
-
.positional('generateDefault', {
|
|
55
|
-
description: 'Also generates the default locale translation file (which does not need to be translated)',
|
|
56
|
-
type: 'boolean',
|
|
57
|
-
})
|
|
58
|
-
.positional('locales', {
|
|
59
|
-
description: 'Comma separated list of locales to generate (others than the default one)',
|
|
60
|
-
type: 'string',
|
|
61
|
-
coerce: x => {
|
|
62
|
-
if (typeof x !== 'string' || !x || !/^[a-zA-Z]+(\-[a-zA-Z]+)?$/.test(x)) {
|
|
63
|
-
console.error('Invalid locale ' + x);
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
66
|
-
return x;
|
|
67
|
-
},
|
|
68
|
-
}), async (args) => {
|
|
69
|
-
var _a;
|
|
70
|
-
try {
|
|
71
|
-
const locales = (_a = args.locales) === null || _a === void 0 ? void 0 : _a.split(',').map(x => x.trim()).filter(x => x !== args.defaultLocale);
|
|
72
|
-
if (!(locales === null || locales === void 0 ? void 0 : locales.length)) {
|
|
73
|
-
console.error('You must provide at least one locale thats different from your default locale');
|
|
74
|
-
process.exit(1);
|
|
75
|
-
}
|
|
76
|
-
if (locales.some(x => !isValidLocale(x))) {
|
|
77
|
-
console.error('--locales argument is invalid');
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
80
|
-
// collect from sources
|
|
81
|
-
console.log('Collecting from sources...');
|
|
82
|
-
const { collected, files } = collect_1.collect(args.source, args.defaultLocale);
|
|
83
|
-
console.log(`...found ${Object.keys(collected.resources).length} translatable items over ${files} files with default language ${collected.targetLanguage}`);
|
|
84
|
-
// create adapter
|
|
85
|
-
const outdir = path_1.default.join(process.cwd(), args.outDir);
|
|
86
|
-
const adapter = adapters_1.getAdapter(args.format, outdir);
|
|
87
|
-
// load other locales
|
|
88
|
-
const others = (await adapter.loadLocales(locales))
|
|
89
|
-
.filter(x => x.targetLanguage !== collected.targetLanguage);
|
|
90
|
-
console.log(`Updating ${others.length} other translations...`);
|
|
91
|
-
// reconciliate existing
|
|
92
|
-
for (const l of others) {
|
|
93
|
-
const collectedCopy = JSON.parse(JSON.stringify(collected));
|
|
94
|
-
const { dirty, missing, same } = reconciliate_1.reconciliate(l, collectedCopy);
|
|
95
|
-
const feats = [];
|
|
96
|
-
if (dirty) {
|
|
97
|
-
feats.push(`${dirty} dirty translations (source changed)`);
|
|
98
|
-
}
|
|
99
|
-
if (missing) {
|
|
100
|
-
feats.push(`${missing} missing translations`);
|
|
101
|
-
}
|
|
102
|
-
if (same.length) {
|
|
103
|
-
feats.push(`${same.length} translations matching original (ex: ${same[0]})`);
|
|
104
|
-
}
|
|
105
|
-
if (!feats.length) {
|
|
106
|
-
console.log(`${l.targetLanguage} is OK ♥`);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
console.log(`${l.targetLanguage} has ${feats.join(', ')}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// write others
|
|
113
|
-
console.log(`Writing results...`);
|
|
114
|
-
for (const l of others) {
|
|
115
|
-
await adapter.write(l);
|
|
116
|
-
}
|
|
117
|
-
if (args.defaultLocale) {
|
|
118
|
-
await adapter.write(collected);
|
|
119
|
-
}
|
|
120
|
-
console.log(`I'm done ♥`);
|
|
121
|
-
}
|
|
122
|
-
catch (e) {
|
|
123
|
-
console.error('Command failed', e);
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
.argv;
|
|
128
|
-
//# sourceMappingURL=cli.js.map
|
package/cli/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;;AAEA,kDAAqD;AACrD,gDAAwB;AACxB,uCAAoC;AACpC,iDAA8C;AAC9C,0CAAyC;AAEzC,4BAA4B;AAE5B,SAAS,aAAa,CAAC,CAAS;IAC5B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,WAAW,CAAI,CAAU;IAC9B,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE;QACtB,QAAQ,EAAE,mBAAmB;QAC7B,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QAC1B,OAAO,EAAE,OAAO;KACnB,CAAC;SACD,UAAU,CAAC,QAAQ,EAAE;QAClB,QAAQ,EAAE,kCAAkC;QAC5C,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,IAAI;KAClB,CAAC,CAAA;AACV,CAAC;AAED,MAAM,GAAG,GAAG,eAAK;KAChB,UAAU,CAAC,UAAU,CAAC;KACtB,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,WAA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M,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SAC1B;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SAClC;QACD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;KAC7B;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACnB;AACL,CAAC,CAAC;KACD,IAAI,CAAC"}
|
package/cli/collect.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Translation } from './interfaces';
|
|
2
|
-
export interface Loc {
|
|
3
|
-
id: string;
|
|
4
|
-
file: string;
|
|
5
|
-
line: number;
|
|
6
|
-
source: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function collect(source: string, forceLocale?: string): {
|
|
9
|
-
collected: Translation;
|
|
10
|
-
files: number;
|
|
11
|
-
};
|
|
12
|
-
export declare function collectFromSource(content: string, ids: Map<string, Loc>, all: Loc[], f?: string): void;
|