The jQuery.i18n.properties of Web front-end internationalization

Source: Internet
Author: User
Tags i18n locale

the jQuery.i18n.properties of Web front-end internationalizationjQuery.i18n.properties Introduction

Internationalization is an important part of today's web application development process, and jQuery.i18n.properties is a lightweight jQuery internationalization plugin that makes it easy to internationalize the Web front end without any changes to the backend.

Compared with other international tools, the JQuery.i18n.properties plug-in has the characteristics of simple, easy-to-use, cohesion-low coupling.

The International English word is: internationalization. Also known as i18n, "I" is the first letter of the word, "18" is the number of words between "I" and "N", and "N" represents the last letter of the word.

JQuery.i18n.properties uses the. properties file to internationalize JavaScript. The JQuery.i18n.properties plugin first loads the default resource file (strings.properties) and then loads the resource file (strings_zh.properties) for the specific locale. This ensures that the default value is always valid when translations for a language are not available.

Developers can use JavaScript variables or maps to get resources from the resource manager via key.

It has several prominent features:

1. Load the default resource file in order and the resource file for the specified locale to ensure that the default value is always available

2. Browser language is used by default when no language is specified

3. Ability to use placeholders

4. Key support namespace in resource file

5. Support for values across rows

jQuery.i18n.properties use

JQuery.i18n.properties's API design is also very streamlined and understandable, with just a few frequently used APIs, loading the configuration API:jQuery.i18n.properties (); getting the resource API "support for placeholder usage": JQuery.i18n.prop (). Get browser language:JQuery.i18n.browserLang ().

JQuery.i18n.properties (Settings) This method loads the resource file. The settings is a series of key-value pairs that configure the load option.

Steps (in HTML, for example):

1. Introduction of script files

<script type= "Text/javascript" src= "jquery/jquery-1.8.3.min.js" ></script><script type= "text/ JavaScript "src=" Js/jquery.i18n.properties-min-1.0.9.js "></script>
2, write the front-end code

<body>    <label data-locale= "hupu_username" > User name: </label><input type= "text" >    < Label data-locale= "Hupu_password" > Password: </label><input type= "password" > </body>

3, write the international running script

<script type= "Text/javascript" >loadproperties (); function loadProperties () {$.i18n.properties ({name: ' Hupu-lang ', Path: ' i18n/', Mode: ' Map ', Language:$.i18n.browserlang (), Callback:function () {$ ("[Data-locale]"). each ( Function () {$ (this). HTML ($.i18n.prop ($ (this). Data ("locale"));}); } }); }</script>

for now, the latest version is 1.2.0. Open Source Address: https://github.com/jquery-i18n-properties/jquery-i18n-properties. It's great to know that many other children's shoes can go up and look at the source code themselves. I'm donuts. Jiangzi programming will have fun.


The jQuery.i18n.properties of Web front-end internationalization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.