@sofit/view-locale 0.1.1 → 0.1.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/.circleci/config.yml +2 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/languages.d.ts +10 -0
- package/dist/languages.js +2 -0
- package/dist/runner.d.ts +11 -0
- package/dist/runner.js +48 -0
- package/dist/translations/common/buttons.d.ts +6 -0
- package/dist/translations/common/buttons.js +8 -0
- package/dist/translations/index.d.ts +2 -0
- package/dist/translations/index.js +7 -0
- package/dist/translations/modules/vehicle.d.ts +18 -0
- package/dist/translations/modules/vehicle.js +20 -0
- package/package.json +1 -1
- package/readme.md +1 -0
package/.circleci/config.yml
CHANGED
|
@@ -37,7 +37,7 @@ jobs:
|
|
|
37
37
|
root: ~/repo
|
|
38
38
|
paths: .
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
deploy:
|
|
41
41
|
<<: *defaults
|
|
42
42
|
steps:
|
|
43
43
|
- attach_workspace:
|
|
@@ -45,17 +45,11 @@ jobs:
|
|
|
45
45
|
- run:
|
|
46
46
|
name: Build from typescript to javascript
|
|
47
47
|
command: npm run build
|
|
48
|
-
|
|
49
|
-
deploy:
|
|
50
|
-
<<: *defaults
|
|
51
|
-
steps:
|
|
52
|
-
- attach_workspace:
|
|
53
|
-
at: ~/repo
|
|
54
48
|
- run:
|
|
55
49
|
name: Authenticate with registry
|
|
56
50
|
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
|
|
57
51
|
- run:
|
|
58
|
-
name: Publish
|
|
52
|
+
name: Publish new version of @sofit/view-auth
|
|
59
53
|
command: npm publish
|
|
60
54
|
|
|
61
55
|
workflows:
|
|
@@ -63,13 +57,9 @@ workflows:
|
|
|
63
57
|
test-build-deploy:
|
|
64
58
|
jobs:
|
|
65
59
|
- test
|
|
66
|
-
- build:
|
|
67
|
-
requires:
|
|
68
|
-
- test
|
|
69
60
|
- deploy:
|
|
70
61
|
requires:
|
|
71
62
|
- test
|
|
72
|
-
- build
|
|
73
63
|
filters:
|
|
74
64
|
branches:
|
|
75
65
|
only: master
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { locale, Locale } from './runner';
|
package/dist/index.js
ADDED
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IAccessKey, LANGUAGES } from './languages';
|
|
2
|
+
export interface IReplaces {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class Locale {
|
|
6
|
+
private readonly language;
|
|
7
|
+
constructor(language: LANGUAGES);
|
|
8
|
+
reach(accessKey: IAccessKey, replaces?: IReplaces): string;
|
|
9
|
+
raw(context: any, path: string, replaces?: IReplaces): string;
|
|
10
|
+
}
|
|
11
|
+
export declare function locale(language: LANGUAGES): Locale;
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class Locale {
|
|
4
|
+
constructor(language) {
|
|
5
|
+
this.language = language;
|
|
6
|
+
}
|
|
7
|
+
reach(accessKey, replaces) {
|
|
8
|
+
let text = accessKey[this.language];
|
|
9
|
+
if (Boolean(text)) {
|
|
10
|
+
if (replaces !== undefined) {
|
|
11
|
+
for (const key in replaces) {
|
|
12
|
+
if (replaces.hasOwnProperty(key)) {
|
|
13
|
+
const value = replaces[key];
|
|
14
|
+
text = text.replace(`{{${key}}}`, value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
return 'Translation not found';
|
|
21
|
+
}
|
|
22
|
+
raw(context, path, replaces) {
|
|
23
|
+
const paths = path.split('.');
|
|
24
|
+
let target = context;
|
|
25
|
+
for (const element of paths) {
|
|
26
|
+
target = target[element];
|
|
27
|
+
if (!target) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (target) {
|
|
32
|
+
return this.reach(target, replaces);
|
|
33
|
+
}
|
|
34
|
+
return 'Translation not found';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Locale = Locale;
|
|
38
|
+
const cache = {
|
|
39
|
+
ptBR: null,
|
|
40
|
+
es: null
|
|
41
|
+
};
|
|
42
|
+
function locale(language) {
|
|
43
|
+
if (cache[language] === null) {
|
|
44
|
+
cache[language] = new Locale(language);
|
|
45
|
+
}
|
|
46
|
+
return cache[language];
|
|
47
|
+
}
|
|
48
|
+
exports.locale = locale;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vehicle = {
|
|
4
|
+
label: {
|
|
5
|
+
name: {
|
|
6
|
+
ptBR: 'Nome',
|
|
7
|
+
es: 'Nuombre'
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
messages: {
|
|
11
|
+
not_found: {
|
|
12
|
+
ptBR: 'Não encontrado',
|
|
13
|
+
es: 'nao coisado'
|
|
14
|
+
},
|
|
15
|
+
test: {
|
|
16
|
+
ptBR: 'Teste de coisa pra {{variable}}',
|
|
17
|
+
es: 'Carai {{variable}}'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
package/package.json
CHANGED
package/readme.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @sofit/view-auth
|