All Projects → aligoren → local.js

aligoren / local.js

Licence: other
Localization script for web sites which has the multiple languages.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to local.js

Localisation
Repository for translation and discussion for OpenRCT2.
Stars: ✭ 49 (+226.67%)
Mutual labels:  localization, localisation
go-locale
GoLang library used to retrieve the current locale(s) of the operating system.
Stars: ✭ 16 (+6.67%)
Mutual labels:  localization, locale
Localizr
Localizr is a Tool that handles and automates the generation of localization files for IOS and Android so there will be only one source of truth for all of your localization strings.
Stars: ✭ 33 (+120%)
Mutual labels:  localization, locale
inlang
Open Source Localization Solution for Software.
Stars: ✭ 160 (+966.67%)
Mutual labels:  localization, localisation
laravel-localizer
Automatically detect and set an app locale that matches your visitor's preference.
Stars: ✭ 34 (+126.67%)
Mutual labels:  localization, locale
loco-php-sdk
Loco SDK for PHP including REST API client
Stars: ✭ 12 (-20%)
Mutual labels:  localization, localisation
locale-switcher
Browser Extension to quickly change your browser locale.
Stars: ✭ 75 (+400%)
Mutual labels:  localization, locale
rosetta
A blazing fast internationalization (i18n) library for Crystal with compile-time key lookup.
Stars: ✭ 23 (+53.33%)
Mutual labels:  localization, locale
Localizr.swift
Simplified and automated Localization process library in IOS. Please check https://github.com/michaelhenry/Localizr for more info.
Stars: ✭ 18 (+20%)
Mutual labels:  localization, locale
poeditor-cli
POEditor CLI
Stars: ✭ 29 (+93.33%)
Mutual labels:  localization, localisation
update localization
A Python Script that helps dealing with localizations in Xcode. It keeps track of Items that are already translated and doesnt replace them like genstrings does but appends new items. Moreover it is possible to specify extensions of files that should be scanned and to specify ignore patterns for Files that should be ignored
Stars: ✭ 39 (+160%)
Mutual labels:  localization, localisation
cldr-engine
Internationalization and localization in Typescript with Unicode CLDR, batteries included
Stars: ✭ 34 (+126.67%)
Mutual labels:  localization, locale
wp-loco
MIRROR of the official Loco Wordpress plugin "Loco Translate"
Stars: ✭ 35 (+133.33%)
Mutual labels:  localization, localisation
awesome-translations
😎 Awesome lists about Internationalization & localization stuff. l10n, g11n, m17n, i18n. Translations! 🌎🌍
Stars: ✭ 54 (+260%)
Mutual labels:  localization, locale
laravel-localized-routes
A convenient way to set up and use localized routes in a Laravel app.
Stars: ✭ 257 (+1613.33%)
Mutual labels:  localization, locale
GoogleSheet-Database
unity google sheet core module
Stars: ✭ 23 (+53.33%)
Mutual labels:  localization
Localizater
Laravel localization package for wrapping routes in multiple locale prefixes
Stars: ✭ 48 (+220%)
Mutual labels:  localization
CMRNet
Code for "CMRNet: Camera to LiDAR-Map Registration" (ITSC 2019) - WIP
Stars: ✭ 70 (+366.67%)
Mutual labels:  localization
micvision
Micvision package provide exploration and location for robot using navigation and cartographer packages
Stars: ✭ 21 (+40%)
Mutual labels:  localization
serge-plugins
Serge (Continuous localization platform https://serge.io/) Plugins
Stars: ✭ 17 (+13.33%)
Mutual labels:  localization

local.js

Localization script for web sites which has the multiple languages.

Usage

HTML Element

Html element must have data-local element. The values of all attributes must be defined as follows:

<button data-local="btn.welcome.text"></button>

<button data-local="btn.other"></button>

These values will be defined in the json language object.

import local.js file

After that import local.js file like below

import Local from "./local";

Init local.js

Parameters:

locals: JSON object. That must be declared.
lang: Default language prefix that you declared in your JSON language Object | optional
cacheable: Boolean variable. When you work remote file you can use this feature
const local = new Local({
    locals: locals,
    lang: 'en',
    cacheable: false
});

With Static Json Variable

JSON structure

You can declare nested json structure

const locals = {
	"tr": {
		"btn": {
			"welcome": {
				"text": "Merhaba hoşgeldin"
			},
			"other": "Diğeri"
		}
	},
	"en": {
		"btn": {
			"welcome": {
				"text": "Hi Welcome"
			},
			"other": "Other"
		}
	}
}

Run local.js

You must set default language prefix if you did not set with constructor.

local.run('en')

That all!

With Remote Json File

Your json language file must be same as above json structure.

JSON Structure

{
	"tr": {
		"btn": {
			"welcome": {
				"text": "Merhaba hoşgeldin"
			},
			"other": "Diğeri"
		}
	},
	"en": {
		"btn": {
			"welcome": {
				"text": "Hi Welcome"
			},
			"other": "Other"
		}
	}
}

When local.js run first time language object will store in localStorage. If you set cacheable property to true, your script will not send http requests again. It will use localStorage instead of http request.

const local = new Local({
    locals: 'http://localhost:3000/locals.json'
    cacheable: true
});

local.run('tr');

Another Example

If you want to change language dynamic you can use like this:

const btn = document.querySelector(".btn");

btn.addEventListener("click", () => {
    local.run('tr');
})
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].