All Projects → atapas → i18n-js-npm

atapas / i18n-js-npm

Licence: MIT license
i18n-web is a simple tool helps in externalizing the strings in a JavaScript based Application such that, Internationalization(i18n) can be achieved easily. It has the additional capability of parameterizing the strings to get the dynamic content Internationalized.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to i18n-js-npm

Weblate
Web based localization tool with tight version control integration.
Stars: ✭ 2,719 (+19321.43%)
Mutual labels:  internationalization
L10ns
Internationalization workflow and formatting
Stars: ✭ 234 (+1571.43%)
Mutual labels:  internationalization
arbify flutter
Flutter package providing Arbify support.
Stars: ✭ 18 (+28.57%)
Mutual labels:  internationalization
Tumblthree
A Tumblr Backup Application
Stars: ✭ 211 (+1407.14%)
Mutual labels:  internationalization
Tourism Demo
Flutter app backed by Redux, shows animations, internationalization (i18n), ClipPath, fonts and others...
Stars: ✭ 232 (+1557.14%)
Mutual labels:  internationalization
A18n
Automated I18n solution for JavaScript/TypeScript/React
Stars: ✭ 244 (+1642.86%)
Mutual labels:  internationalization
Rails Api Base
Rails 5 RESTful api template
Stars: ✭ 197 (+1307.14%)
Mutual labels:  internationalization
universal-react-relay-starter-kit
A starter kit for React in combination with Relay including a GraphQL server, server side rendering, code splitting, i18n, SEO.
Stars: ✭ 14 (+0%)
Mutual labels:  internationalization
Lang.js
🎭 Laravel Translator class in JavaScript!
Stars: ✭ 232 (+1557.14%)
Mutual labels:  internationalization
i18n-literally
🍦 A simple way to introduce internationalization to your JS
Stars: ✭ 80 (+471.43%)
Mutual labels:  internationalization
Flutter sheet localization
Generate Flutter localization from a simple online Google Sheets.
Stars: ✭ 212 (+1414.29%)
Mutual labels:  internationalization
Actingweb firstapp
Starter app for Flutter that includes many different production app features; some not typically included in demo apps.
Stars: ✭ 224 (+1500%)
Mutual labels:  internationalization
Flutter translate
Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
Stars: ✭ 245 (+1650%)
Mutual labels:  internationalization
Intl Relativeformat
Formats JavaScript dates to relative time strings (e.g., "3 hours ago").
Stars: ✭ 211 (+1407.14%)
Mutual labels:  internationalization
AndroidTools
🔧 Many useful tools for Android development, adb wrapper, smali, languages etc.
Stars: ✭ 32 (+128.57%)
Mutual labels:  internationalization
Vue Inter
Simple yet powerful 1kB i18n library for Vue.js
Stars: ✭ 198 (+1314.29%)
Mutual labels:  internationalization
Counterpart
A translation and localization library for Node.js and the browser.
Stars: ✭ 239 (+1607.14%)
Mutual labels:  internationalization
I18N-Portable
Simple and cross platform internationalization/translations for Xamarin and .NET
Stars: ✭ 102 (+628.57%)
Mutual labels:  internationalization
expense-manager
Developers : Checkout this repo for complete CI-CD of flutter with fastlane. Android/iOS both apps are getting deployed on stores with Fastlane.
Stars: ✭ 28 (+100%)
Mutual labels:  internationalization
React Native Globalize
Internationalization (i18n) for React Native
Stars: ✭ 246 (+1657.14%)
Mutual labels:  internationalization

i18n-web

i18n-web is a simple tool helps in externalizing the strings in a JavaScript based Application such that, Internationalization(i18n) can be achieved easily. It has the additional capability of parameterizing the strings to get the dynamic content Internationalized.

Install

  • Using yarn: yarn add i18n-web
  • Using npm: npm install i18n-web

What is String Externalization?

String Externalization means, instead of writing the user(or customer) facing strings in source files(.html, .js, .java etc), we keep them in an external file like .properties, .json etc and load from there. This is to help Internationalization (i18n).

What is Internationalization (i18n)?

In Software, Internationalization (i18n) is the process to support various local languages like, English(en), Spanish(es), German(de) etc.

All the browsers come with the in-built support of languages which can be used to identify the local language to support for the application.

How String Externalization help in Internationalization (i18n) of the Web Applications?

A Web Application may have the need of supporting multiple languages based on the targeted users. If the Application Strings are Externalized outside of the source files, it is easy and flexible to support i18n.

Lets consider, all the application strings are in a file called en.json and this file can be loaded into the application to retrieve the strings when the app is running in English Language.

{
    'username': 'User Name',
    'password': 'Password',
    'hasBlog': '{0} has a blog named, {1}. This is on {2}.'
}

Now there could be equivalent es.json file which can be loaded into the application when browser supported language is Spanish instead of English.

{
    'username': 'Nombre de usuario',
    'password': 'Contraseña',
    'hasBlog': '{0} tiene un blog llamado {1}. Esto está en {2}.'
}

i18n-web Usage

Basic Setup and Structure

The tool i18n-web helps in externalizing the string and thus, internationalizing your web app with few quick and easy steps.

  • Create a folder called i18n at the same level of node_modules folder of your app.
  • Create en.js, es.js, de.js etc file to contain your application specific strings externalized. You must add all required language .js files that your app would support.

Here is an example of the en.js and es.js file.

// en.js
const en = {
    'username': 'User Name',
    'password': 'Password',
    'hasBlog': '{0} has a blog named, {1}. This is on {2}.'
}

export { en };
// es.js
const es = {
    'username': 'Nombre de usuario',
    'password': 'Contraseña',
    'hasBlog': '{0} tiene un blog llamado {1}. Esto está en {2}.'
}

export { es };
  • Create another file called, index.js where you can aggregate the all modules and export together like this:
export { en } from './en.js';
export { es } from './es.js';

Example Directory Structure:

myapp                         
    └── i18n
        └── en.js
        └── es.js
        └── de.js
        └── fr.js
        └── index.js                
    └── node_modules                    

Using it in UI Code

  • In your UI Code, import it as,
import i18n from 'i18n-web';
  • Use it like:
// When no parameters. Just Key is passed
console.log(i18n('usename'));

// Output: 

// 'User Name' for English 

// 'Nombre de usuario' for Spanish 
// With parameters.
const params = ['Tapas', 'greenroos', 'JavaScript'];
let hasBlog = i18n('hasBlog', ...params);
console.log(hasBlog);

// Output: 

// 'Tapas has a blog named, greenroots. This is on JavaScript.' for English and 

// 'Tapas tiene un blog llamado greenroots. Esto está en JavaScript.' for Spanish 

Tested with

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].