@sofit/view-locale 0.1.6 → 0.2.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/.circleci/config.yml +15 -1
- package/coverage/jest/results.xml +12 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +9 -1
- package/dist/joi/joi.interface.d.ts +12 -0
- package/dist/joi/joi.interface.js +2 -0
- package/dist/runner.d.ts +3 -2
- package/dist/runner.js +21 -13
- package/dist/translations/common/buttons.d.ts +2 -6
- package/dist/translations/common/database-errors.d.ts +2 -0
- package/dist/translations/common/database-errors.js +12 -0
- package/dist/translations/common/joi.d.ts +2 -0
- package/dist/translations/common/joi.js +16 -0
- package/dist/translations/index.d.ts +4 -2
- package/dist/translations/index.js +8 -5
- package/dist/translations/modules/gate/gate.d.ts +2 -0
- package/dist/translations/modules/gate/gate.js +8 -0
- package/dist/translations/translation.interface.d.ts +4 -0
- package/dist/translations/translation.interface.js +2 -0
- package/jest.config.json +10 -0
- package/lib/index.ts +4 -1
- package/lib/joi/joi.interface.ts +13 -0
- package/lib/runner.ts +19 -17
- package/lib/tests/basic.spec.ts +49 -0
- package/lib/translations/common/buttons.ts +3 -1
- package/lib/translations/common/database-errors.ts +12 -0
- package/lib/translations/common/joi.ts +16 -0
- package/lib/translations/index.ts +4 -2
- package/lib/translations/modules/gate/gate.ts +8 -0
- package/lib/translations/translation.interface.ts +5 -0
- package/package.json +9 -6
- package/dist/translations/modules/vehicle.d.ts +0 -18
- package/dist/translations/modules/vehicle.js +0 -20
- package/lib/tests/vehicle.spec.ts +0 -43
- package/lib/translations/modules/vehicle.ts +0 -20
package/.circleci/config.yml
CHANGED
|
@@ -22,13 +22,17 @@ jobs:
|
|
|
22
22
|
# fallback to using the latest cache if no exact match is found
|
|
23
23
|
- v1-dependencies-
|
|
24
24
|
|
|
25
|
-
- run: npm install
|
|
25
|
+
- run: npm install
|
|
26
26
|
|
|
27
27
|
- save_cache:
|
|
28
28
|
paths:
|
|
29
29
|
- node_modules
|
|
30
30
|
key: v1-dependencies-{{ checksum "package.json" }}
|
|
31
31
|
|
|
32
|
+
- run:
|
|
33
|
+
name: Build from typescript to javascript
|
|
34
|
+
command: npm run build
|
|
35
|
+
|
|
32
36
|
- run:
|
|
33
37
|
name: Run code quality
|
|
34
38
|
command: npm run lint
|
|
@@ -37,6 +41,13 @@ jobs:
|
|
|
37
41
|
name: Run tests
|
|
38
42
|
command: npm test
|
|
39
43
|
|
|
44
|
+
- store_artifacts:
|
|
45
|
+
path: ~/repo/coverage/lcov-report
|
|
46
|
+
destination: tests
|
|
47
|
+
|
|
48
|
+
- store_test_results:
|
|
49
|
+
path: ~/repo/coverage
|
|
50
|
+
|
|
40
51
|
- persist_to_workspace:
|
|
41
52
|
root: ~/repo
|
|
42
53
|
paths: .
|
|
@@ -55,6 +66,9 @@ jobs:
|
|
|
55
66
|
- run:
|
|
56
67
|
name: Publish new version of @sofit/view-locale
|
|
57
68
|
command: npm publish
|
|
69
|
+
- run:
|
|
70
|
+
name: Add github host
|
|
71
|
+
command: mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
|
|
58
72
|
- run:
|
|
59
73
|
name: Creating a new tag
|
|
60
74
|
command: git config user.email "desenvolvimento@sofit4.com.br" && git config user.name "Desenvolvimento Sofit AUTO" && N=`cat package.json | grep version | egrep "[0-9].[0-9].[0-9]" -o` && git tag -a v$N -m "New version of @sofit/view-locale $N" && git push --tags
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<testsuites name="Sofit view locale tests" tests="4" failures="0" time="3.04">
|
|
2
|
+
<testsuite name="Vehicle locale test" errors="0" failures="0" skipped="0" timestamp="2018-07-20T13:20:30" time="2.202" tests="4">
|
|
3
|
+
<testcase classname="Vehicle locale test Should get translations with reach" name="Vehicle locale test Should get translations with reach" time="0.006">
|
|
4
|
+
</testcase>
|
|
5
|
+
<testcase classname="Vehicle locale test Should replace correctly with reach" name="Vehicle locale test Should replace correctly with reach" time="0">
|
|
6
|
+
</testcase>
|
|
7
|
+
<testcase classname="Vehicle locale test Should get translations with raw" name="Vehicle locale test Should get translations with raw" time="0.001">
|
|
8
|
+
</testcase>
|
|
9
|
+
<testcase classname="Vehicle locale test Should replace correctly with raw" name="Vehicle locale test Should replace correctly with raw" time="0">
|
|
10
|
+
</testcase>
|
|
11
|
+
</testsuite>
|
|
12
|
+
</testsuites>
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
+
if (mod && mod.__esModule) return mod;
|
|
4
|
+
var result = {};
|
|
5
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
+
result["default"] = mod;
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const i18n = __importStar(require("./translations"));
|
|
11
|
+
exports.i18n = i18n;
|
|
3
12
|
var runner_1 = require("./runner");
|
|
4
|
-
exports.locale = runner_1.locale;
|
|
5
13
|
exports.Locale = runner_1.Locale;
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IValidationErrorItem } from './joi/joi.interface';
|
|
1
2
|
import { IAccessKey, LANGUAGES } from './languages';
|
|
2
3
|
export interface IReplaces {
|
|
3
4
|
[key: string]: string;
|
|
@@ -6,6 +7,6 @@ export declare class Locale {
|
|
|
6
7
|
private readonly language;
|
|
7
8
|
constructor(language: LANGUAGES);
|
|
8
9
|
reach(accessKey: IAccessKey, replaces?: IReplaces): string;
|
|
9
|
-
raw(
|
|
10
|
+
raw(path: string, replaces?: IReplaces): string;
|
|
11
|
+
joi(detail: IValidationErrorItem): string;
|
|
10
12
|
}
|
|
11
|
-
export declare function locale(language: LANGUAGES): Locale;
|
package/dist/runner.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
3
|
+
if (mod && mod.__esModule) return mod;
|
|
4
|
+
var result = {};
|
|
5
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
6
|
+
result["default"] = mod;
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const TRANSLATIONS = __importStar(require("./translations"));
|
|
3
11
|
class Locale {
|
|
4
12
|
constructor(language) {
|
|
5
13
|
this.language = language;
|
|
@@ -19,9 +27,10 @@ class Locale {
|
|
|
19
27
|
}
|
|
20
28
|
return 'Translation not found';
|
|
21
29
|
}
|
|
22
|
-
raw(
|
|
30
|
+
raw(path, replaces) {
|
|
23
31
|
const paths = path.split('.');
|
|
24
|
-
let target =
|
|
32
|
+
let target = TRANSLATIONS[paths[0]];
|
|
33
|
+
paths.shift();
|
|
25
34
|
for (const element of paths) {
|
|
26
35
|
target = target[element];
|
|
27
36
|
if (!target) {
|
|
@@ -33,16 +42,15 @@ class Locale {
|
|
|
33
42
|
}
|
|
34
43
|
return 'Translation not found';
|
|
35
44
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
joi(detail) {
|
|
46
|
+
const accessKey = TRANSLATIONS.joi[detail.type];
|
|
47
|
+
if (accessKey) {
|
|
48
|
+
if (detail.context) {
|
|
49
|
+
detail.context.label = this.raw(detail.context.label);
|
|
50
|
+
}
|
|
51
|
+
return this.reach(TRANSLATIONS.joi[detail.type], detail.context);
|
|
52
|
+
}
|
|
53
|
+
return `There is no translation for joi type '${detail.type}'`;
|
|
45
54
|
}
|
|
46
|
-
return cache[language];
|
|
47
55
|
}
|
|
48
|
-
exports.
|
|
56
|
+
exports.Locale = Locale;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.databaseErrors = {
|
|
4
|
+
generic: {
|
|
5
|
+
ptBR: 'Ocorreu um erro ao processar a requisição.',
|
|
6
|
+
es: 'Se produjo un error al procesar la solicitud.'
|
|
7
|
+
},
|
|
8
|
+
unique_constraint: {
|
|
9
|
+
ptBR: 'Já existe um {{label}} com valor "{{value}}".',
|
|
10
|
+
es: 'Ya existe un {{label}} con valor "{{value}}".'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joi = {
|
|
4
|
+
'string.base': {
|
|
5
|
+
ptBR: 'Campo "{{label}}" deve ser um texto.',
|
|
6
|
+
es: 'Campo "{{label}}" debe se uno texto.'
|
|
7
|
+
},
|
|
8
|
+
'number.base': {
|
|
9
|
+
ptBR: 'Campo "{{label}}" precisa se um numero.',
|
|
10
|
+
es: ''
|
|
11
|
+
},
|
|
12
|
+
'number.min': {
|
|
13
|
+
ptBR: 'Campo "{{label}}" precisa ter no minimo {{limit}}',
|
|
14
|
+
es: ''
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var gate_1 = require("./modules/gate/gate");
|
|
4
|
+
exports.gate = gate_1.gate;
|
|
5
|
+
var buttons_1 = require("./common/buttons");
|
|
6
|
+
exports.button = buttons_1.button;
|
|
7
|
+
var joi_1 = require("./common/joi");
|
|
8
|
+
exports.joi = joi_1.joi;
|
|
9
|
+
var database_errors_1 = require("./common/database-errors");
|
|
10
|
+
exports.databaseErrors = database_errors_1.databaseErrors;
|
package/jest.config.json
CHANGED
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
"transform": {
|
|
6
6
|
"^.+\\.ts$": "ts-jest"
|
|
7
7
|
},
|
|
8
|
+
"reporters": [
|
|
9
|
+
"default",
|
|
10
|
+
[
|
|
11
|
+
"jest-junit",
|
|
12
|
+
{
|
|
13
|
+
"suiteName": "Sofit view locale tests",
|
|
14
|
+
"output":"./coverage/jest/results.xml"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
],
|
|
8
18
|
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
|
|
9
19
|
"moduleFileExtensions": [
|
|
10
20
|
"ts",
|
package/lib/index.ts
CHANGED
package/lib/runner.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IValidationErrorItem } from './joi/joi.interface';
|
|
2
|
+
import { IAccessKey, LANGUAGES } from './languages';
|
|
3
|
+
import * as TRANSLATIONS from './translations';
|
|
2
4
|
|
|
3
5
|
export interface IReplaces {
|
|
4
6
|
[key: string]: string;
|
|
@@ -30,21 +32,20 @@ export class Locale {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
return text;
|
|
33
|
-
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
return 'Translation not found';
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
public raw(context: any, path: string, replaces?: IReplaces): string {
|
|
40
|
+
public raw(path: string, replaces?: IReplaces): string {
|
|
41
41
|
|
|
42
42
|
const paths = path.split('.');
|
|
43
|
-
let target =
|
|
43
|
+
let target = TRANSLATIONS[paths[0]];
|
|
44
|
+
|
|
45
|
+
paths.shift();
|
|
44
46
|
|
|
45
47
|
for (const element of paths) {
|
|
46
48
|
|
|
47
|
-
// tslint:disable-next-line
|
|
48
49
|
target = target[element];
|
|
49
50
|
|
|
50
51
|
if (!target) {
|
|
@@ -55,25 +56,26 @@ export class Locale {
|
|
|
55
56
|
|
|
56
57
|
if (target) {
|
|
57
58
|
|
|
58
|
-
// tslint:disable-next-line
|
|
59
59
|
return this.reach(target, replaces);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return 'Translation not found';
|
|
63
63
|
}
|
|
64
|
-
}
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
ptBR: null,
|
|
68
|
-
es: null
|
|
69
|
-
};
|
|
65
|
+
public joi(detail: IValidationErrorItem) {
|
|
70
66
|
|
|
71
|
-
|
|
67
|
+
const accessKey = TRANSLATIONS.joi[detail.type];
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
if (accessKey) {
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
}
|
|
71
|
+
if (detail.context) {
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
detail.context.label = this.raw(detail.context.label as string);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return this.reach(TRANSLATIONS.joi[detail.type], detail.context as IReplaces);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return `There is no translation for joi type '${detail.type}'`;
|
|
80
|
+
}
|
|
79
81
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { i18n, Locale } from '../index';
|
|
2
|
+
|
|
3
|
+
describe('Vehicle locale test', () => {
|
|
4
|
+
|
|
5
|
+
const localeptBR = new Locale('ptBR');
|
|
6
|
+
const localeptES = new Locale('es');
|
|
7
|
+
|
|
8
|
+
it('Should get translations with reach', () => {
|
|
9
|
+
|
|
10
|
+
expect(localeptBR.reach(i18n.gate.name))
|
|
11
|
+
.toEqual(i18n.gate.name.ptBR);
|
|
12
|
+
expect(localeptES.reach(i18n.gate.name))
|
|
13
|
+
.toEqual(i18n.gate.name.es);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('Should replace correctly with reach', () => {
|
|
17
|
+
|
|
18
|
+
expect(localeptBR.reach(i18n.databaseErrors.unique_constraint, {
|
|
19
|
+
label: 'label',
|
|
20
|
+
value: 'value'
|
|
21
|
+
})).toEqual('Já existe um label com valor "value".');
|
|
22
|
+
|
|
23
|
+
expect(localeptES.reach(i18n.databaseErrors.unique_constraint, {
|
|
24
|
+
label: 'label2',
|
|
25
|
+
value: 'value2'
|
|
26
|
+
})).toEqual('Ya existe un label2 con valor "value2".');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('Should get translations with raw', () => {
|
|
30
|
+
|
|
31
|
+
expect(localeptBR.raw('databaseErrors.generic'))
|
|
32
|
+
.toEqual(i18n.databaseErrors.generic.ptBR);
|
|
33
|
+
expect(localeptES.raw('databaseErrors.generic'))
|
|
34
|
+
.toEqual(i18n.databaseErrors.generic.es);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('Should replace correctly with raw', () => {
|
|
38
|
+
|
|
39
|
+
expect(localeptBR.raw('databaseErrors.unique_constraint', {
|
|
40
|
+
label: 'label',
|
|
41
|
+
value: 'value'
|
|
42
|
+
})).toEqual('Já existe um label com valor "value".');
|
|
43
|
+
|
|
44
|
+
expect(localeptES.raw('databaseErrors.unique_constraint', {
|
|
45
|
+
label: 'label2',
|
|
46
|
+
value: 'value2'
|
|
47
|
+
})).toEqual('Ya existe un label2 con valor "value2".');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ITranslation } from '../translation.interface';
|
|
2
|
+
|
|
3
|
+
export const databaseErrors: ITranslation = {
|
|
4
|
+
generic: {
|
|
5
|
+
ptBR: 'Ocorreu um erro ao processar a requisição.',
|
|
6
|
+
es: 'Se produjo un error al procesar la solicitud.'
|
|
7
|
+
},
|
|
8
|
+
unique_constraint: {
|
|
9
|
+
ptBR: 'Já existe um {{label}} com valor "{{value}}".',
|
|
10
|
+
es: 'Ya existe un {{label}} con valor "{{value}}".'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ITranslation } from '../translation.interface';
|
|
2
|
+
|
|
3
|
+
export const joi: ITranslation = {
|
|
4
|
+
'string.base': {
|
|
5
|
+
ptBR: 'Campo "{{label}}" deve ser um texto.',
|
|
6
|
+
es: 'Campo "{{label}}" debe se uno texto.'
|
|
7
|
+
},
|
|
8
|
+
'number.base': {
|
|
9
|
+
ptBR: 'Campo "{{label}}" precisa se um numero.',
|
|
10
|
+
es: ''
|
|
11
|
+
},
|
|
12
|
+
'number.min': {
|
|
13
|
+
ptBR: 'Campo "{{label}}" precisa ter no minimo {{limit}}',
|
|
14
|
+
es: ''
|
|
15
|
+
}
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sofit/view-locale",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Traduções do Sofit View",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"test": "jest --config ./jest.config.json",
|
|
9
9
|
"dev": "nodemon",
|
|
10
10
|
"lint": "tslint --project ./",
|
|
11
|
-
"build": "tsc --p ./"
|
|
11
|
+
"build": "tsc --p ./",
|
|
12
|
+
"postinstall": "node .vscode/commit-msg.js"
|
|
12
13
|
},
|
|
13
14
|
"author": "desenvolvimento@sofit4.com.br",
|
|
14
15
|
"contributors": [
|
|
@@ -21,14 +22,16 @@
|
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"typescript": "^2.8.3",
|
|
24
|
-
"@types/node": "^9.6.6"
|
|
25
|
+
"@types/node": "^9.6.6"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@sofit/tslint-rules": "0.1.11",
|
|
25
29
|
"@types/jest": "^22.2.3",
|
|
30
|
+
"jest-junit": "^5.1.0",
|
|
26
31
|
"jest": "^22.4.3",
|
|
27
32
|
"ts-jest": "^22.4.4",
|
|
28
33
|
"tslint": "^5.9.1",
|
|
29
|
-
"tslint-eslint-rules": "^5.1.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
34
|
+
"tslint-eslint-rules": "^5.1.0",
|
|
32
35
|
"nodemon": "^1.17.3",
|
|
33
36
|
"ts-node": "^6.0.0"
|
|
34
37
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { locale } from '../index';
|
|
2
|
-
import * as translations from '../translations';
|
|
3
|
-
|
|
4
|
-
describe('Vehicle locale test', () => {
|
|
5
|
-
|
|
6
|
-
it('Should get translations with reach', () => {
|
|
7
|
-
|
|
8
|
-
expect(locale('ptBR').reach(translations.vehicle.messages.not_found))
|
|
9
|
-
.toEqual(translations.vehicle.messages.not_found.ptBR);
|
|
10
|
-
expect(locale('es').reach(translations.vehicle.messages.not_found))
|
|
11
|
-
.toEqual(translations.vehicle.messages.not_found.es);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('Should replace correctly with reach', () => {
|
|
15
|
-
|
|
16
|
-
expect(locale('ptBR').reach(translations.vehicle.messages.test, {
|
|
17
|
-
variable: 'varai'
|
|
18
|
-
})).toEqual('Teste de coisa pra varai');
|
|
19
|
-
|
|
20
|
-
expect(locale('es').reach(translations.vehicle.messages.test, {
|
|
21
|
-
variable: 'varai'
|
|
22
|
-
})).toEqual('Carai varai');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('Should get translations with raw', () => {
|
|
26
|
-
|
|
27
|
-
expect(locale('ptBR').raw(translations.vehicle, 'messages.not_found'))
|
|
28
|
-
.toEqual(translations.vehicle.messages.not_found.ptBR);
|
|
29
|
-
expect(locale('es').raw(translations.vehicle, 'messages.not_found'))
|
|
30
|
-
.toEqual(translations.vehicle.messages.not_found.es);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('Should replace correctly with raw', () => {
|
|
34
|
-
|
|
35
|
-
expect(locale('ptBR').raw(translations.vehicle, 'messages.test', {
|
|
36
|
-
variable: 'varai'
|
|
37
|
-
})).toEqual('Teste de coisa pra varai');
|
|
38
|
-
|
|
39
|
-
expect(locale('es').raw(translations.vehicle, 'messages.test', {
|
|
40
|
-
variable: 'varai'
|
|
41
|
-
})).toEqual('Carai varai');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export const vehicle = {
|
|
3
|
-
label: {
|
|
4
|
-
name: {
|
|
5
|
-
ptBR: 'Nome',
|
|
6
|
-
es: 'Nuombre'
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
|
-
messages: {
|
|
10
|
-
/** Não encontrado */
|
|
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
|
-
};
|