[JEECG technology blog] JEECG International Introduction
1. Why internationalization?
A framework without internationalization is an incomplete framework. In particular, in today's global informatization, internationalization is no longer a weakness, but a primary factor for testing when selecting a development platform, in particular, whether or not some companies' platforms are internationalized has a one-vote veto factor. Therefore, we need to internationalize the platform, rather than simply being a simple high-performance platform.
2. Principle of Internationalization
Internationalization sounds simple, but it is difficult to loosely couple the framework to achieve seamless connection with the framework. Some systems sometimes do not need to be internationalized. If they are internationalized, they can quickly find out which fields are not internationalized. These problems are all issues that developers need to solve during the development process, we have helped you think of all this.
On the logon page, select a language and click "Log On". The following code is displayed in the checkuser method in LoginControler. java. The current language is put into the session.
if (req.getParameter("langCode")!=null) {req.getSession().setAttribute("lang", req.getParameter("langCode"));}MutiLangServiceImpl. java has three methods:
1) initAllMutiLang () -- TOMCAT is automatically loaded when it is started, and the international table content is loaded into the memory, so that it can be called quickly in the future, load all records in the t_s_muti_lang table and put them in the Cache.
2) getLang (String lang_key) -- input the Lang Key that needs to be internationalized to automatically obtain the value after internationalization based on the user's current language. For example, if you call it somewhere: string value = getLang ("common. status). If the current language is Chinese, the value is Status, and the English language is status.
3) refleshMutiLangCach () -- refresh the Cache. When maintaining the language, for example, adding a language can automatically add the newly added language to the Cache to ensure real-time effectiveness.
3. Examples of international applications
Take the international maintenance page as an example.
List and Tag Internationalization
LangKey can input multiple parameters, for example:
Lang. congratulation. edit. success: Congratulations, {0} modified {1 }.
The langArg parameter style that can be passed in on the page is:
LangArg = "lang. function. name, common. success"
Lang. function. name will replace {0}, and common. success will replace {1}
Internationalization of client label
Java background Internationalization
Internationalization of the background tree
If you want to internationalize the tree, you only need to replace the tree name with the lang_key value in the table and add the code MutiLangUtil In the last step returned by the tree. setMutiTree (treeGrids, mutiLangService:
Js Internationalization
Because the Js file cannot use international tags, you can only add us in the src \ main \ webapp \ plug-in \ mutiLang directory. js and zh-cn.js, this file has been first introduced in BaseTag by default.
4. Language Maintenance
In the system management menu, you can maintain and manage the language. Do not add existing language content. If duplicate content exists, the system will automatically prompt you when adding the content.
5. lang_key naming rules
1) if the system has already been internationalized, you do not need to add it again, for example, common. status, corresponding status. If there is a status, you just need it. Do not add the same name and different lang_key.
2) If the international table does not exist, you need to add it yourself.
Lang_key must be named in the t_s_mutilang table in the format of xxx. xxx (or more points)
3) if it is not commonly used, for example, if a module has a label called "student", it can be named lang. student.
4) if the name is public, it starts with "common". For example, "operation" may be used everywhere in the system. The name can be "common. operation ".
5) You don't need a word to name it as lang_key, such as student.
6) if it is a sentence lang_key, write down this sentence. Words are separated by vertices, such as common. please. select. one. record. to. edit corresponds to Please select one record to edit
7) if the first letter of a sentence lang_context needs to be capitalized and the other lowercase letters need to be spelled in normal English sentences, for example:
Please select one record to edit, instead of Please Select One Record To Edit.
8) if it is not a sentence, as shown on the header, lang_context can be capitalized, for example, User Name and Role Name.
9) The names should be consistent. For example, some people in the department prefer to use the abbreviation "depart", which should be abbreviated as "depart". Do not see the depart in a while, but the department may be uncoordinated in a moment. Do not see desc in a moment, or description in a moment.
10) do not make spelling mistakes.
11) Make the translation accurate and avoid irrelevant content. For example, if the title of a webpage contains Chinese characters: students, you can use lang. student. add, some people find that this is a title and may be written as lang. title. student. add, title: this is the location where this occurs. Do not add such location information.
12) add and modify all List pages (except for special cases) in the following style. The langArg value of the corresponding module is modified.
The module name + input (edit) is translated, for example, language input and user input. Do not just put "input" to ensure that all pages are consistent.
6. I am only working on projects in China. Do not want to see lang_key?
Of course you can, you can still write the code as originally, for example:
Then, set the lang_context value corresponding to common. notfind. langkey from? Leave it empty.
7. Why do I have an extra question mark after I use internationalization?
It reminds you that the lang_key has not been internationalized. You only need to add it to language maintenance. The question mark aims to be a reminder that you can see at a glance what is not internationalized. If you hate to see the question mark, the lang_context corresponding to common. notfind. langkey will also be set? Empty!