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

localization-js

v1.0.0

Published

Javascript platform for localization and globalization of documents, web pages, web applications et cetra. Edit

Downloads

4

Readme

Localization.js

Javascript platform for localization and globalization of documents, web pages, web applications et cetra.

Localization.js uses JSON-documents to store translations. A typical file structure of an app using Localization.js would be:

 locale/ 
 	config.json
 	en-us/
 		login.json
 	no-nb/
 		login.json
 app.js

##Usage localization.js is rather lightweight and easy to setup.

  1. Create a new instance var lang = new Localization();
  2. Initialize the instance Localization.initialize(config_path, completedCallback);
  3. Set locale lang.setLocale(language);
  4. Load modules lang.loadModule(module_filename, callback);
  5. Start processing text lang.processContent(data, variableArray);

For more, please see the example of usage (below).

###Example of usage The following example is from one of my hybrid web apps.

app.js

var lang = new Localization();
lang.initialize('locale/config.json', function(){
    //Initialized     
    lang.setLocale('no-nb'); //e.g. "en-us"
    
    lang.loadModule('login.json', function(){
        //Loaded
	
		//Fetch some data over ajax	
		$.get('./login.html', function(data){
		
			//Convert content to language
			data = lang.processContent(data, [
			    'login_title',
			    'login_email_placeholder',
			    'login_password_placeholder',
			    'login_button_text',
			    'login_not_a_member_text',
			    'login_sign_up'
			]);
			
			$('#pre-login').html(data);
			login.bindings();
		});
	 
	 	//end lang.loadModule		
    });
    //end lang.initialize
});

./locale/config.json (localization.js configuration file)

{
    "supported_locales": ["no-nb", "en-us"]
}

./locale/en-us/login.json (English American language file)

{
    "title": "login",
    "content": {
        "login_title": "Login",
        "login_email_placeholder": "E-mail",
        "login_password_placeholder": "Password",
        "login_button_text": "Login",
        "login_not_a_member_text": "Not a member?",
        "login_sign_up": "Sign up"
    }
}

./locale/no-nb/login.json (Norwegian language file)

{
    "title": "login",
    "content": {
        "login_title": "Innlogging",
        "login_email_placeholder": "E-post",
        "login_password_placeholder": "Passord",
        "login_button_text": "Logg inn",
        "login_not_a_member_text": "Ikke medlem?",
        "login_sign_up": "Opprett bruker"
    }
}

##License MIT License

Copyright (c) 2016 Erlend Ellingsen

See LICENSE-file.