In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Web developers should know what jQuery i18n knowledge, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
When designing a website, an important consideration is internationalization. Every region and country in the world has different expectations for how texts, messages, numbers and dates should appear. Each user of a particular application expects all text and messages to be displayed in a familiar format. JavaScript has a good internationalization solution called jQuery.i18n. JQuery i18n is used for localization of MediaWiki and many other international websites.
Characteristics of JQuery I18n
Keep the code separate from i18n content. This feature keeps the code modular and allows developers to load the i18n functionality they need.
Use the JSON format.
Allows you to change the language without refreshing the page.
Processing in the plural does not use additional messages. Rule processing is done using Unicode Consortium's generic locale data repository (Common Locale Data Repository,CLDR).
Correct sentences according to gender by passing gender values.
The grammatical form is supported.
JQuery i18n directory
The general way to format a directory using jQuery i18n is to have an i18n folder with an JSON file for each language code stored in this directory. A sample directory is shown in Figure 1.
Figure 1. The directory of JSON files for each language code.
JQuery I18n message file format
JQuery i18n uses JSON files, which allow users to store information in a lightweight format for data exchange. JSON files are very useful because:
They allow translators to easily access the text to be translated. This is useful if you need to send JSON files for translation services.
They block direct access to the database.
The JSON file consists of an ordered list of name-value pairs or values. In the JSON file for internationalization, the message key-message pair contains the names and values of all language pairs. Each key is a lowercase letter, separates words with "-", and is associated with values in the selected language. The JSON file can contain @ metadata, which stores non-messaging information about the file, such as copyright and author information. A separate JSON file is usually created for each language type; however, all translations can also be placed in a single file. The advantage of a separate JSON file is that the file is less complex. However, a single JSON file helps ensure that fields do not duplicate when embedding multilingual data. Here is an example of a JSON file that contains a single language and @ metadata:
{"@ metadata": {"author": "Colleen", "description": "An example JSON file", "last-updated": "2016-09-21", "message-documentation": "qqq"}, "greeting": "Hello", "bye": "Goodbye"}
An example of a JSON file with multiple languages and @ metadata is provided below:
{"metadata": {"author": "Fred", "description": "An example JSON file", "last-updated": "2016-09-21", "message-documentation": "qqq", "arrayGroups": {"label": {"en": "label_en", "fr": "label_fr"}, "en": {"greeting": "Hello" "bye": "Goodbye"} "fr": {"greeting": "Bonjour", "bye": "Au revoir"}}
Usage
Some ways to use jquery.i18n are shown in the table below.
Use area
Description
Toggle locale
You can use the locale option to get the locale of a web page:
$.i18n ({
Locale: 'fr' / / Locale is French
})
Switch to another locale after the plug-in initializes:
$. I18n (). Locale = 'ml'
Message loading
You can load messages for a specific locale or multiple locales.
$.i18n () .load
})
Data API
Localized messages can be displayed without using JavaScript.
Message format-placeholder
These parameters are indicated in the message by $1 PLURAL:$1 "2" 3, and the syntax is {{PLURAL:$1 | pluralform1 | pluralform2 | … }} and replaced by the runtime.
Message format-plural
In English, there are only two plural forms, but in many other languages there are more than two plural forms.
Message format-gender
{{GENDER... The syntax uses the gender of the placeholder to change the syntax dynamically.
Translation
There are several ways to translate a jquery.i18n application:
Edit the JSON file. This applies to small applications with a limited number of languages.
There is a translation interface for the application. This option applies to proprietary or proprietary applications with many translators.
JQuery.I18n.Properties
JQuery.i18n.properties is a jQuery plug-in for internationalization. Similar to Java, jquery i18n uses the resource software set ('.properties' file). The resource software set is used to store region-specific information, such as text messages. They allow easy access to region-specific information and easily add zones by adding additional resource software sets. The '.properties' file contains region-specific key-value pairs and parses these files based on language and country codes.
Use Jquery.I18n.Properties
The jquery.i18n.properties.js plug-in can be downloaded from https://github.com/jquery-i18n-properties/jquery-i18n-properties. The plug-in should be included in the section of the HTML page. The version of jquery you use should be specified in the source file as shown below.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.