An Efficient i18n translation library for Angular JS framework
Download prodution unminified.
Command: bower install ngHtmled
-
<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
-
.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 whenautoDetect
is false. Read the False section underautoDetect
.
- Can be dependency injected anywhere to get the properties or configuration in your controller, factory or services
$HTMLed.bundle(KEY)
: IfKEY
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 passedKEY
.$HTMLed.configuration()
: Returns the configuration setup made.
Please feel free to log the issues on github or ask a stackoverflow question and mail the link to me.
Run grunt
for building and grunt serve
for preview.
Running grunt test
will run the unit tests with karma.
This project is generated with yo angular generator version 0.15.1.