@gucciogucci/simply-translation
Advanced tools
Comparing version 1.0.2 to 1.1.1
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e){const t=e.default,a=navigator.language,r=e.languages[a]?JSON.stringify(e.languages[a]):JSON.stringify(e.languages[t]);localStorage.setItem("translate",r)},exports.simplyTranslate=function(e,t){let a=JSON.parse(localStorage.getItem("translate"))[e];return t&&t.forEach(((e,t)=>{a=a.replace(`{${t}}`,e)})),a}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e){const t=e.default;let a;if(void 0!==e.source&&"url_pathname_slot2"===e.source){const[,,e]=window.location.pathname.split("/");a=e}else a=void 0!==e.source&&"html"===e.source?document.documentElement.lang.toLowerCase():navigator.language;const o=e.languages[a]?JSON.stringify(e.languages[a]):JSON.stringify(e.languages[t]);localStorage.setItem("translate",o)},exports.simplyTranslate=function(e,t){let a=JSON.parse(localStorage.getItem("translate"))[e];return t&&t.forEach(((e,t)=>{a=a.replace(`{${t}}`,e)})),a}; |
{ | ||
"name": "@gucciogucci/simply-translation", | ||
"version": "1.0.2", | ||
"version": "1.1.1", | ||
"description": "Simply Translation library", | ||
@@ -27,3 +27,2 @@ "main": "dist/index.min.js", | ||
"homepage": "https://github.com/GuccioGucci/simply-translation#readme", | ||
"dependencies": {}, | ||
"jest": { | ||
@@ -44,10 +43,9 @@ "name": "Simply Translation", | ||
"@babel/core": "^7.12.9", | ||
"@babel/plugin-transform-modules-commonjs": "^7.12.1", | ||
"@rollup/plugin-eslint": "^8.0.1", | ||
"babel-eslint": "^10.1.0", | ||
"husky": "^3.1.0", | ||
"jest": "^26.6.3", | ||
"rollup": "^2.34.2", | ||
"rollup-plugin-eslint": "^7.0.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"@babel/plugin-transform-modules-commonjs": "^7.12.1", | ||
"jest": "^26.6.3" | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
@@ -62,3 +60,6 @@ "husky": { | ||
"dist/*" | ||
] | ||
], | ||
"dependencies": { | ||
"husky": "^7.0.4" | ||
} | ||
} |
@@ -65,4 +65,28 @@ # simply-translation | ||
### Simply translate | ||
### Configuration | ||
By default, _SimplyTranslation_ use browser language as language selector, you can change it adding `source` value to __url_pathname_slot2__ path or __html__ lang attribute: | ||
| attribute name | required | type | value | description | | ||
|---|---|---|---|---| | ||
| default | yes | {string} | en | set up default JSON file | | ||
| source | no | {string} | null \| url_pathname_slot2 \| html | - __null or blank__: use browser language<br>- __url_pathname_slot2__: use URL second slot (e.g.: https://www.domain.com/uk/it/ lang will be _it_)<br>- __html__: use HTML lang attribute `<html lang="en" ... >` | | ||
| languages | yes | {object} | {'en-US': en, 'it-IT': it, ...} | mapping languages files | | ||
Example: | ||
```js | ||
loadTranslation({ | ||
default: 'en', | ||
source: 'url_pathname_slot2', | ||
languages: { | ||
'en': en, | ||
'zh_hk': zh_hk, | ||
'zh': zh, | ||
} | ||
}); | ||
``` | ||
### How to use it | ||
First import the component and then call it with the corresponding key and add attributes in an array in case. | ||
@@ -69,0 +93,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
12357
8
3
108
1
+ Addedhusky@^7.0.4
+ Addedhusky@7.0.4(transitive)