JQuery Extension To Replace Text For Client-Side Internationalization

Internationalization is a customizable jQuery webpage localization plugin that makes it easy to client-side translate any strings within your document.

The compiler package supports AMD, commonjs, commonjs2, and context-specific variable injection (UMD) as an export format: you can use a unit compiler if you want.

Must Read: JavaScript Client-Side HTML Table Sorting Library

How to make use of it:

Installation:

# NPM
$ npm install internationalisation

1. Install and import internationalization into your challenge.

$ npm install internationalisation --save

2. Or embrace the compiled model on the net web page to comply with:

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="//unpkg.com/internationalisation"></script>

3. Add an alternate model of your text as these:

<h1>
  Hello World!
  <!--deDE:Hallo Welt!-->
  <!--frFR:Bonjour le monde!-->
</h1>

4. Create the links to change between languages.

<a href="#language-deDE">de</a>
<a href="#language-enUS">en</a>
<a href="#language-frFR">fr</a>

5. Initialize the plugin with default options.

$(($) => $.Language())

6. Default configuration choices.

$(($) => $.Language({

  // Selector prefix for all nodes to take into account.
  domNodeSelectorPrefix: 'body',

  // Initial language to use
  default: 'enUS',

  // List of all supported languages.
  selection: [],

  // Initial set language (if omitted it will be guest.
  initial: null,

  // Template delimiter to recognize dynamic content.
  templateDelimiter: {pre: '{{', post: '}}'},

  // Indicates whether a fade effect should be performed.
  fadeEffect: true,

  // Saves informations how parent dom nodes should be animated when containing text will be switched.
  textNodeParent: {
      show: [{opacity: 1}, {duration: 'fast'}],
      hideAnimation: [{opacity: 0}, {duration: 'fast'}]
  },

  // Pattern to introduce a pre replacement language node.
  preReplacementLanguagePattern: '^\\|({1})

7. Callback features are accessible.

$(($) => $.Language({

  // Callback which will be triggered after a language switch has been finished.
  onSwitched: this.constructor.noop,

  // Callback which will be triggered after a language check has been performed. 
  // Needed if some nodes have another language active then others. 
  // Useful if only some parts of the dom tree was updated and a full language update isn't required.
  onEnsured: this.constructor.noop,

  // Callback which should be called before a language switch should be performed.
  onSwitch: this.constructor.noop,

  // Callback which should be called before a language switch should be ensured.
  onEnsure: this.constructor.noop,

}))

See Also –

Client-Side Javascript JSON To HTML Templating Library | json2html
Custom Basic Form Validator/Checker in jQuery | inputfollow.js
How to Encode and Decode Strings Using Base64 | base64.js


See Demo And Download

Replace-Text-For-Client-Side-Internationalization

Official Website(thaibault): Click Here

This superior jQuery/javascript plugin is developed by thaibault. For extra Advanced Usage, please go to the official website.

Related Posts

Google-Translate-Dropdown-Customize-With-Country-Flag

Google Translate Dropdown Customize With Country Flag | GT API

Flag google translates jQuery text that takes advantage of the Google Cloud Translation API to translate web content between languages by selecting a country from the dropdown…

Bootstrap-Fileinput

HTML 5 File Input Optimized for Bootstrap 4.x./3.x with File Preview | Bootstrap Fileinput

bootstrap-fileinput is an improved HTML 5 file input  Bootstrap 5.x, 4.x and 3.x with file preview for different files, provides multiple selections, resumable section uploads, and more….

HStack-and-VStack-in-CSS

CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…

alert-confirm-prompt-attention-js

Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…

Leave a Reply

Your email address will not be published. Required fields are marked *