@sofit/view-locale 0.1.1 → 0.1.3

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.
@@ -29,6 +29,10 @@ jobs:
29
29
  - node_modules
30
30
  key: v1-dependencies-{{ checksum "package.json" }}
31
31
 
32
+ - run:
33
+ name: Run code quality
34
+ command: npm run lint
35
+
32
36
  - run:
33
37
  name: Run tests
34
38
  command: npm test
@@ -37,7 +41,7 @@ jobs:
37
41
  root: ~/repo
38
42
  paths: .
39
43
 
40
- build:
44
+ deploy:
41
45
  <<: *defaults
42
46
  steps:
43
47
  - attach_workspace:
@@ -45,31 +49,24 @@ jobs:
45
49
  - run:
46
50
  name: Build from typescript to javascript
47
51
  command: npm run build
48
-
49
- deploy:
50
- <<: *defaults
51
- steps:
52
- - attach_workspace:
53
- at: ~/repo
54
52
  - run:
55
53
  name: Authenticate with registry
56
54
  command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
57
55
  - run:
58
- name: Publish package
56
+ name: Publish new version of @sofit/view-locale
59
57
  command: npm publish
58
+ - run:
59
+ name: Creating a new tag
60
+ command: 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
60
61
 
61
62
  workflows:
62
63
  version: 2
63
64
  test-build-deploy:
64
65
  jobs:
65
66
  - test
66
- - build:
67
- requires:
68
- - test
69
67
  - deploy:
70
68
  requires:
71
69
  - test
72
- - build
73
70
  filters:
74
71
  branches:
75
72
  only: master
@@ -0,0 +1 @@
1
+ export { locale, Locale } from './runner';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var runner_1 = require("./runner");
4
+ exports.locale = runner_1.locale;
5
+ exports.Locale = runner_1.Locale;
@@ -0,0 +1,10 @@
1
+ import { Locale } from './runner';
2
+ export declare type LANGUAGES = 'ptBR' | 'es';
3
+ export interface IAccessKey {
4
+ ptBR: string;
5
+ es: string;
6
+ }
7
+ export interface ICreator {
8
+ ptBR: Locale | null;
9
+ es: Locale | null;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,6 @@
1
+ export declare const button: {
2
+ maria: {
3
+ ptBR: string;
4
+ es: string;
5
+ };
6
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.button = {
4
+ maria: {
5
+ ptBR: 'maira',
6
+ es: 'pedro'
7
+ }
8
+ };
@@ -0,0 +1,2 @@
1
+ export * from './modules/vehicle';
2
+ export * from './common/buttons';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ function __export(m) {
3
+ for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
+ }
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ __export(require("./modules/vehicle"));
7
+ __export(require("./common/buttons"));
@@ -0,0 +1,18 @@
1
+ export declare const vehicle: {
2
+ label: {
3
+ name: {
4
+ ptBR: string;
5
+ es: string;
6
+ };
7
+ };
8
+ messages: {
9
+ not_found: {
10
+ ptBR: string;
11
+ es: string;
12
+ };
13
+ test: {
14
+ ptBR: string;
15
+ es: string;
16
+ };
17
+ };
18
+ };
@@ -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
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@sofit/view-locale",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Traduções do Sofit View",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "jest --config ./jest.config.json",
9
9
  "dev": "nodemon",
10
- "build": "tslint --project ./ && tsc --p ./"
10
+ "lint": "tslint --project ./",
11
+ "build": "tsc --p ./"
11
12
  },
12
13
  "author": "desenvolvimento@sofit4.com.br",
13
14
  "contributors": [
package/readme.md ADDED
@@ -0,0 +1,3 @@
1
+ # @sofit/view-auth
2
+
3
+ Tradução do sofit view