GithubHelp home page GithubHelp logo

fgasper / angular-dynamic-locale Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lgalfaso/angular-dynamic-locale

0.0 3.0 0.0 178 KB

Module to be able to change the locale at an angularjs application

License: MIT License

JavaScript 98.13% Shell 1.87%

angular-dynamic-locale's Introduction

Angular Dynamic Locale


Usage

Requirements

  • AngularJS v1.0.7+ is currently required.

Changing the locale

This module defines two services, these are tmhDynamicLocale and tmhDynamicLocaleCache.

The service tmhDynamicLocale provides has one method set(newLocale) to change the locale.

tmhDynamicLocale.set('it');

Keep in mind that the locale will be changed asynchronously

After the locale is changed, the event '$localeChangeSuccess' will be triggered.

Calling tmhDynamicLocale.set will return a promise that will be resolved when the locale is loaded and will resolve to the new locale.

The service tmhDynamicLocaleCache is a $cache of all the loaded locales, where the key is the locale id and the value is the locale object.

This module expects for the angular locales to be present at angular/i18n/angular-locale_{{locale}}.js. If the locales are at another URL, this can be changed at tmhDynamicLocaleProvider using localeLocationPattern(string).

It is possible to specify a storage location for the locale using tmhDynamicLocaleProvider.useStorage(storageName), the name of the storage must follow the same signature as $cookieStore. The default storage location is to use a $cache, this default storage is not persistent.

It is possible to ask the storage to be $cookieStore using the shortcut tmhDynamicLocaleProvider.useCookieStorage(), internally this is exactly as performing tmhDynamicLocaleProvider.useStorage('$cookieStore')

Installation

Add the module to your dependencies

angular.module('myApp', ['tmh.dynamicLocale', ...])

Development

Requirements

  1. Install Node.js and NPM (should come with)

  2. Install global dependencies grunt-cli and bower:

    $ npm install -g grunt-cli bower
  3. Install local dependencies:

    $ npm install
    $ bower install

Running the tests

$ grunt karma:unit

to run the test once

or

$ grunt karma:autotest

to run the tests continuously

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.