@sofit/view-locale 0.1.0 → 0.1.1

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.
@@ -0,0 +1,75 @@
1
+ # Javascript Node CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-javascript/ for more details
4
+ #
5
+ version: 2
6
+
7
+ defaults: &defaults
8
+ working_directory: ~/repo
9
+ docker:
10
+ - image: circleci/node:8.11.1
11
+
12
+ jobs:
13
+ test:
14
+ <<: *defaults
15
+ steps:
16
+ - checkout
17
+
18
+ # Download and cache dependencies
19
+ - restore_cache:
20
+ keys:
21
+ - v1-dependencies-{{ checksum "package.json" }}
22
+ # fallback to using the latest cache if no exact match is found
23
+ - v1-dependencies-
24
+
25
+ - run: npm install --production
26
+
27
+ - save_cache:
28
+ paths:
29
+ - node_modules
30
+ key: v1-dependencies-{{ checksum "package.json" }}
31
+
32
+ - run:
33
+ name: Run tests
34
+ command: npm test
35
+
36
+ - persist_to_workspace:
37
+ root: ~/repo
38
+ paths: .
39
+
40
+ build:
41
+ <<: *defaults
42
+ steps:
43
+ - attach_workspace:
44
+ at: ~/repo
45
+ - run:
46
+ name: Build from typescript to javascript
47
+ command: npm run build
48
+
49
+ deploy:
50
+ <<: *defaults
51
+ steps:
52
+ - attach_workspace:
53
+ at: ~/repo
54
+ - run:
55
+ name: Authenticate with registry
56
+ command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
57
+ - run:
58
+ name: Publish package
59
+ command: npm publish
60
+
61
+ workflows:
62
+ version: 2
63
+ test-build-deploy:
64
+ jobs:
65
+ - test
66
+ - build:
67
+ requires:
68
+ - test
69
+ - deploy:
70
+ requires:
71
+ - test
72
+ - build
73
+ filters:
74
+ branches:
75
+ only: master
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "@sofit/view-locale",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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 ./",
11
- "preversion": "npm t && tslint --project",
12
- "prepublish": "npm t && npm run build"
10
+ "build": "tslint --project ./ && tsc --p ./"
13
11
  },
14
12
  "author": "desenvolvimento@sofit4.com.br",
15
13
  "contributors": [
@@ -22,15 +20,15 @@
22
20
  },
23
21
  "dependencies": {
24
22
  "typescript": "^2.8.3",
25
- "@types/node": "^9.6.6"
26
- },
27
- "devDependencies": {
23
+ "@types/node": "^9.6.6",
28
24
  "@types/jest": "^22.2.3",
29
25
  "jest": "^22.4.3",
30
- "nodemon": "^1.17.3",
31
26
  "ts-jest": "^22.4.4",
32
- "ts-node": "^6.0.0",
33
27
  "tslint": "^5.9.1",
34
28
  "tslint-eslint-rules": "^5.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "nodemon": "^1.17.3",
32
+ "ts-node": "^6.0.0"
35
33
  }
36
- }
34
+ }
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { locale, Locale } from './runner';
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
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;
@@ -1,10 +0,0 @@
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
- }
package/dist/languages.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/runner.d.ts DELETED
@@ -1,11 +0,0 @@
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 DELETED
@@ -1,48 +0,0 @@
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;
@@ -1,6 +0,0 @@
1
- export declare const button: {
2
- maria: {
3
- ptBR: string;
4
- es: string;
5
- };
6
- };
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.button = {
4
- maria: {
5
- ptBR: 'maira',
6
- es: 'pedro'
7
- }
8
- };
@@ -1,2 +0,0 @@
1
- export * from './modules/vehicle';
2
- export * from './common/buttons';
@@ -1,7 +0,0 @@
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"));
@@ -1,18 +0,0 @@
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
- };
@@ -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
- };