
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
JavaScript plugin for adding multilingual website.
npm install lieu
or download lieu.js from /dist.
import Lieu from 'lieu';
const lieu = new Lieu({/* ... */});
const Lieu = require('lieu');
const lieu = new Lieu({/* ... */});
<script src="https://cdn.jsdelivr.net/npm/lieu"></script>
import Lieu from 'lieu';
const lieu = new Lieu({
isDebug: true, // default "false"
initialLanguage: 'en', // default automatically or the first language in the list
attributeName: 'data-lieu', // default "data-lieu"
languages: {
en: {
name: 'English',
locales: {
'Hello': 'Hello!',
'Bye': 'Bye!',
'HelloName': 'Hello %{name} %{surname}!',
},
},
tr: {
name: 'Türk',
locales: {
'Hello': 'Merhaba!',
'Bye': 'Hoşçakal!',
'HelloName': 'Merhaba %{name} %{surname}!',
},
},
// ...{pt: {...}, zh: {...}, /* ... */}
},
// or
// languages: require('languages.json'),
// Hooks
onSetLang(newLang, oldLang){ /* your code */ } , //
onGetLang(){ /* your code */ } , //
});
import Lieu from 'lieu';
const lieu = new Lieu({/* ... */});
// translate strings
lieu.trans('Hello'); // "Merhaba!" (if Turkish is selected)
// replacing parameters in translation strings
lieu.trans('HelloName', { name: 'John', surname: 'Doe' }); // "Hello John Doe!" (if English is selected)
// other methods
lieu.setLang('tr'); // set new language
lieu.getLang('tr'); // get language
lieu.getLangs(); // get all languages
<span data-lieu="Hello"></span>
<span data-lieu="Bye"></span>
<script src="https://cdn.jsdelivr.net/npm/lieu"></script>
<script>
const lieu = new Lieu({ /* ... */ });
</script>
option | type | required | description |
---|---|---|---|
languages | object / json | true | List of languages and string translations |
initialLanguage | string | false | Selected default language. If not specified, it will be determined automatically. If you do not have any language, then the first one in the list of languages will be selected |
isDebug | boolean | false | If true , warns in the console about errors and not found translations in languages |
attributeName | string | false | String localization attribute for HTML usage |
hook | arguments | description |
---|---|---|
onSetLang | (newLang, oldLang) | executed when using the setLang() method |
onGetLang | () | executed when using the getLang() method |
The author will be grateful to all developers for any suggestions to improve the plugin. Fork and submit pull requests. Thank you!
1.1.0 - 2022-07-29
Thanks co-authored @AndyKuhorenko
FAQs
Javascript plugin for localize string.
The npm package lieu receives a total of 0 weekly downloads. As such, lieu popularity was classified as not popular.
We found that lieu demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.