Skip to content
/ ngHTMLed Public

simple and light i18n translation library for Angular JS framework

Notifications You must be signed in to change notification settings

nirus/ngHTMLed

Repository files navigation

ngHTMLed v 0.1 intial release

An Efficient i18n translation library for Angular JS framework

Source

Download prodution unminified.

Install via Bower

Command: bower install ngHtmled

Directive API usage: Refer main.html.

  • <strings text-id="TEXT_ID">DEFAULT_TEXT_HERE</strings> DEFAULT_TEXT_HERE is rendered when a valid text-id is not available in properties file.

  • <strings format>%txt{"ID_1"} and %txt{"ID_2"}</strings> format flag in the directive instructs the compiler service that the rendering string is dependent on more than one key from the properties file. Used to construct a sentence with more than one key in the string.

  • <strings text-id="TEXT_ID"></strings> is replaced by the string from properties file pointed by TEXT_ID

Config API usage: Refer app.js

  • .properties file should be a valid JSON file. Validate using jsonviewer online.

  • autoDetect - (Type: Boolean) :

    • True: It is used to detect the browser specific language settings. If you set it as true, it get's the browser language settings and automatically load it for you. Here is the catch when set as "true" - You should have the ".properties" file name exactly matching the name of the browser language returned. You can use this JSfiddle Link to get or see the language name set for the browser. For example if it returns "en-US" your ".properties" file for that specific language should be named as "en-US.properties". The framework will load it automatically and display the page in that language as specified.

    • False: If you want to explicitly load the language irrespective of your browser settings, then make "autoDetect" to "false" in the Global variable. This will load the language file given in "langPref". Just mention as "langPref: en-US", this load "en-US.properties" file.

  • langBundle : Location or folder name of your properties file residing in.

  • langPref : Valid only when autoDetect is false. Read the False section under autoDetect.

Dependency injection: $HTMLed

  • Can be dependency injected anywhere to get the properties or configuration in your controller, factory or services
    • $HTMLed.bundle(KEY): If KEY is null Returns the json object of properties file from which you can access as key/pair value in your code. Else will return the value for the passed KEY.
    • $HTMLed.configuration(): Returns the configuration setup made.

Issue's tracking and questionaire

Please feel free to log the issues on github or ask a stackoverflow question and mail the link to me.

To run the sample app

Run grunt for building and grunt serve for preview.

Testing

Running grunt test will run the unit tests with karma.

Project base

This project is generated with yo angular generator version 0.15.1.

About

simple and light i18n translation library for Angular JS framework

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published