Implement web front-end internationalization based on jQuery.i18n
This time I will bring you the internationalization of the web front-end based on jQuery.i18n, and what are the precautions for implementing the internationalization of the web front-end based on jQuery.i18n. The following are practical cases. , let’s take a look.
Before introducing jQuery.i18n.properties, let’s first take a look at what internationalization is. The English word for internationalization 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 one letter. In computing, internationalization refers to the process of designing software that can adapt to various regional and linguistic environments.
jQuery.i18n.properties is a lightweight jQuery internationalization plug-in. Similar to resource files in Java, jQuery.i18n.properties uses .properties files to internationalize JavaScript. The jQuery.i18n.properties plug-in parses the corresponding resource files with the suffix ".properties" according to the language and country code specified by the user (or provided by the browser) (in compliance with ISO-639 and ISO-3166 standards).
Using resource files to achieve internationalization is a popular way. For example, Android applications can use resource files named after language and country encoding to achieve internationalization. The resource files in the jQuery.i18n.properties plug-in are suffixed with ".properties" and contain region-related key-value pairs. We know that Java programs can also use resource files with the .properties suffix to achieve internationalization, so this method is particularly useful when we want to share resource files between Java programs and front-end JavaScript programs. The jQuery.i18n.properties plug-in first loads the default resource file (for example: strings.properties), and then loads the resource file for a specific locale (for example: strings_zh.properties), which ensures that when a translation for a certain language is not provided , the default value is always valid. Developers can use keys in resource files as JavaScript variables (or functions) or Maps.
The following is an introduction to how to use i18n in the project. To explain, my here is different from the official website. I have not used some methods of i18n, but only used a small part, and found out the comparison. Suitable for our project.
1. First, create the resource file:
##locales/en-us/ns.jsp.json:
{ "reSendMail": { "emailSendFail": "Failed to send the email", "emailHasSendToYourEmail": "The email has be sent to your email address. " }, "login": { "pleaseWriteUserName": "Please input your username", "pleaseWritePassword": "Please input your password " }, "activeRegist": { "thisUserEmailHasUsed":"Email has already been used", "thisUserNameHasUsed":"User Name has already been used", "4to30Char":"Please enter 4-30 characters", "1to50Char":"Please enter 1-50 characters", "1to16Linkman":"Please enter 1-16 characters", "loginPage":"Login Page", "EmailMustNotEmpty": "Email can't be blank", "PWDNotEmpty": "Password can't be blank", "nameNotEmpty":"Name can't be blank", "conpanyNotEmpty":"Company can't be blank", "qqNotEmpty":"QQ can not be blank", "phoneNotEmpty":"Mobile can not be blank", "least50charEmailAddress":"No more than 50 characters for email address", "enterEmailAddressLikeThis":"Email address format 'abc@abc.com'", "enter6To32Character":"Please enter 6-32 characters", "NameMost30Character":"No more than 30 characters for name", "QQTypeIsWrong":"Incorrent QQ format", "phoneTypeNotCorrect":"Incorrent mobile format", "thisEmailHasRegistered":"Email address has already been registered", "registerFail":"Registration failed!", "TwoTimesPWDIsDifferent":"The passwords you entered do not match. Please try again." } }Chinese
Configuration file I won’t write it down, the format is the same, it is written in different modules in the form of map.
2. Introduce i18n.js on the jsp page and initialize i18n
<script></script> <script></script> <script> i18n.init({ lng:'${sessionScope.language }', ns: { namespaces: ['ns.jsp'], defaultNs: 'ns.jsp'}, useLocalStorage: false }); </script>
3.js reference
var emailflag = false; function checkemail() { check('email', 'emailmessage'); var email = $("#email").attr("value"); if(email != null && email != "") { if(email.length > 50) { setpInfo("emailp", i18n.t('activeRegist.least50charEmailAddress'), 1);//请输入50字符内的邮箱地址 } else { if(isEmail(email, $("#email"))) { checkemailForServer(email); } else { setpInfo("emailp", i18n.t('activeRegist.enterEmailAddressLikeThis'), 1);//请输入邮箱地址,格式为abc@abc.com } } } }
4. Test
Detailed explanation of the use of vue nested routing and 404 redirection
Angular HttpClient introductory tutorial
The above is the detailed content of Implement web front-end internationalization based on jQuery.i18n. For more information, please follow other related articles on the PHP Chinese website!

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.

JavaScript is at the heart of modern websites because it enhances the interactivity and dynamicity of web pages. 1) It allows to change content without refreshing the page, 2) manipulate web pages through DOMAPI, 3) support complex interactive effects such as animation and drag-and-drop, 4) optimize performance and best practices to improve user experience.

C and JavaScript achieve interoperability through WebAssembly. 1) C code is compiled into WebAssembly module and introduced into JavaScript environment to enhance computing power. 2) In game development, C handles physics engines and graphics rendering, and JavaScript is responsible for game logic and user interface.

JavaScript is widely used in websites, mobile applications, desktop applications and server-side programming. 1) In website development, JavaScript operates DOM together with HTML and CSS to achieve dynamic effects and supports frameworks such as jQuery and React. 2) Through ReactNative and Ionic, JavaScript is used to develop cross-platform mobile applications. 3) The Electron framework enables JavaScript to build desktop applications. 4) Node.js allows JavaScript to run on the server side and supports high concurrent requests.

Python is more suitable for data science and automation, while JavaScript is more suitable for front-end and full-stack development. 1. Python performs well in data science and machine learning, using libraries such as NumPy and Pandas for data processing and modeling. 2. Python is concise and efficient in automation and scripting. 3. JavaScript is indispensable in front-end development and is used to build dynamic web pages and single-page applications. 4. JavaScript plays a role in back-end development through Node.js and supports full-stack development.

C and C play a vital role in the JavaScript engine, mainly used to implement interpreters and JIT compilers. 1) C is used to parse JavaScript source code and generate an abstract syntax tree. 2) C is responsible for generating and executing bytecode. 3) C implements the JIT compiler, optimizes and compiles hot-spot code at runtime, and significantly improves the execution efficiency of JavaScript.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
