From 9fdd942bb4de345bfa6e9770bb88c62d744e47d8 Mon Sep 17 00:00:00 2001 From: Karim Oulad Chalha Date: Tue, 29 Jan 2019 23:16:39 +0100 Subject: [PATCH] RELEASE: v1.0.2 fixing some problemes --- README.MD | 27 +++++++-------------------- demo/demo.js | 3 +-- demo/index.html | 6 +++--- dist/jquery.l10n.js | 2 +- dist/jquery.l10n.js.map | 2 +- jquery.l10n.js | 14 +++++++------- package.json | 2 +- 7 files changed, 21 insertions(+), 35 deletions(-) diff --git a/README.MD b/README.MD index d407cde..48394d2 100755 --- a/README.MD +++ b/README.MD @@ -52,14 +52,14 @@ Create a dictionary variable, then initialize the plugin "Hello world!": "Bonjour monde", ... }, - ja: { + jp: { "Hello world!": "こんにちは世界", ... } }; const l10n = $('.gettext').l10n({ - lang: 'ja', + lang: 'jp', dictList: words }); ``` @@ -83,29 +83,17 @@ you can also use it via javascript code ## Options ```javascript - $(selector).l10n{ + $(selector).l10n({ lang: 'en', - dynamicLang: false, dictList: words - } + }); ``` * The `selector` can be any CSS selector `.class`, `#id`, `[attribute]`, But not recommended to use CSS `elements` or `:pseudo-classes` * lang: Code for the language to be translated to.
default: `en` - -* dynamicLang: if this option is set to `true` it will get `localStorage` `lang` item value `localStorage.getitem('lang')` -, If not found, it will use html lang attribute value ``
, -and if set `true` it will override `lang` option so you don't need set it value example: - ```javascript - $(selector).l10n{ - dynamicLang: true, - dictList: words - } - ``` - default: false - +> lang will be used in the first run or when localStorage is empty. * dictList: The set of dictionaries of words and sentence to be used in the plugin. ## Methods @@ -127,13 +115,12 @@ This function gets your desired text and translates it, if it's translation exis ### setLanguage -This function is only needed when `dynamicLang` option set to `true` so that you can change your language or via you JS script. +This function is needed so that you can change your language via you JS script. #### Paramters * lang: A string with you desired language code. -* reload (optional): To decide if you wish this function to reload the page or not. ```javascript - l10n.setLanguage('ar', false); + l10n.setLanguage('ar'); ``` \ No newline at end of file diff --git a/demo/demo.js b/demo/demo.js index b2b5d4a..d7d6ebe 100755 --- a/demo/demo.js +++ b/demo/demo.js @@ -1,13 +1,12 @@ (function ($) { const l10n = $('.l10n').l10n({ - dynamicLang: true, dictList: words }); $('#via-js').html(l10n.getText('Your plugin is not working')); $('button').click(function() { - l10n.setLanguage($(this).data('lang'), $(this).data('reload')); + l10n.setLanguage($(this).data('lang')); }); }(jQuery)); diff --git a/demo/index.html b/demo/index.html index e6bd78d..0250a9d 100755 --- a/demo/index.html +++ b/demo/index.html @@ -16,9 +16,9 @@

Demo

Plato - - - + + +