Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gucciogucci/simply-translation

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gucciogucci/simply-translation - npm Package Compare versions

Comparing version 1.0.2 to 1.1.1

2

dist/index.min.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc