Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

atma-i18n

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atma-i18n

Localization Module

latest
Source
npmnpm
Version
0.5.9
Version published
Maintainers
1
Created
Source

Localization Module (NodeJS and Browser)

Build Status NPM version Bower version

  • MaskJS Localization Util
  • Localization Function

Node.js

Resolve language from the current request(middleware)

Browser

Resolve language from navigator.language or location.query ('/?language=en')

If the language is not supported, the default one is taken.

Formatter

Atma-Formatter is used to format/interpolate strings.

Pluralization

Refer to the atma-formatter.

Usage

Mask Util

~[L: ID [,...expressions]] ~[L: (expression) [,...expressions]]

  • Simple: ~[L:fooId]

  • Formatting:

    Example:

    	header > '~[L:welcomeId, name]'
    	// same as
    	header > '~[L:"welcomeId", name]'
    
    $L.extend('en', {
    	welcome: 'Hello {0}!'
    });
    mask.render(template, { name: 'Baz' });
    
  • get i18n ID from model: Example:

    	var menu = [ 'todo', 'task' ]
    	ul {
    		for (item of menu) {
    			li > '~[L:("m_" + item)]'
    		}
    	}
    
    $L.extend('en', {
    	m_todo: 'My Todos',
    	m_task: 'My Tasks'
    });
    mask.render(template);
    
Function

Browser @see examples

	$L('titleHello');

Node

	connect
		.use($L.middleware({
			support: [ 'en', 'de', 'ru' ],
			path: '/public/localization/%%.json'
		});
	// Aftewards each `req` has `$L` function.
	// Or use direct
	$L.fromReq(req)('id');

Configuration

IncludeJS
Browser

Load this library with IncludeJS - after defining the list of supported languages and the path to translations, it will load also supported translations

include
	.embed('/atma/localization.js?path=/public/i18n/%%.json&langs=de,it,fr')
	.done(function(){
		// appropriate translationis is loaded and ready to use
		$L('welcome', 'Baz')
	});
	
NodeJS

Use the middleware function so that not all translations are loaded at once, but only with the first incomming request.

(c) MIT, Atma.js Project

FAQs

Package last updated on 25 Feb 2018

Did you know?

Socket

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.

Install

Related posts