npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

elo7-i18n-amd

v1.1.0

Published

i18n management

Downloads

4

Readme

I18n-amd

I18n-amd internationalization library

I18n.js is a library that helps working with internationalization on javascript. This library uses amd structure. Build Status

Install

Install with npm: npm install elo7-i18n-amd

Dependency

I18n-amd depends on an amd implementation. We suggest async-define implementation for dependency lookup. I18n-amd also depends on ajax-amd and a stable version is already defined in package.json. You only need to install with npm and load i18n-amd and ajax-amd files on your page. I18n-amd expects an endpoint with the url "/i18n/{messageKey}" to return a JSON response with the following structure:

{
	version: 1,
	message: "Confirm",
	key: "words.Confirm"
}

This one should be implemented on your web application.

For pluralized keys it's expect the following message structure:

{
	version: 1,
	message: "No product",
	key: "products.zero"
},
{
	version: 1,
	message: "One product",
	key: "products.one"
},
{
	version: 1,
	message: "{0} products",
	key: "products.other"
}

For formatted messages, it's expect the following message structure:

{
	version: 1,
	message: "Hello {0}! Have a {1} day!",
	key: "args.example"
}

Methods

get

.get(key)

Description:

Returns an internationalized message for the given key. This method caches the key, value and version on localStorage to avoid unecessary requests. The current version of your application is stored on sessionStorage, if the message version doesn't match current version, a new request is done to update the cached value with the new message.

Sample:
define(['i18n'], function(i18n) {
	// words.Confirm=Confirm
	i18n.get('words.Confirm'); // Returns "Confirm"
});

count

.count(key, size)

Description:

Returns the pluralized internationalized message for the given key. It's also replace {0} with the size parameter. This method uses get method and caches the message on the same way.

Sample:
define(['i18n'], function(i18n) {
	i18n.count('products', 0); // Returns "No product"
	i18n.count('products', 1); // Returns "One product"
	i18n.count('products', 2); // Returns "2 products"
});

args

.args(key, args...)

Description:

Returns internationalized message for the given key formatted with arguments. The message should contains {n} to be replaced with the argument[n]. This method also uses get method on background and caches the message on the same way.

Sample:
define(['i18n'], function(i18n) {
	i18n.args('args.example', 'Bielo', 'nice'); // Returns "Hello Bielo! Have a nice day!"
});

domain

.domain("example.com")

Description:

Sets an optional domain which i18n lib will make requests for the internationalization. This variable needs to be set before any get() usage if the domain isn't the same as the current page.

Sample:
define(['i18n'], function(i18n) {
	i18n.domain("some-domain.com");
});

License

Event-amd is released under the BSD. Have at it.


Copyright :copyright: 2019 Elo7# i18n-amd