@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.
@@ -37,7 +37,7 @@ jobs:
37
37
  root: ~/repo
38
38
  paths: .
39
39
 
40
- build:
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 package
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
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@sofit/view-locale",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Traduções do Sofit View",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md ADDED
@@ -0,0 +1 @@
1
+ # @sofit/view-auth