CN108363703A - The multilingual solution of front end applications, storage medium - Google Patents

The multilingual solution of front end applications, storage medium Download PDF

Info

Publication number
CN108363703A
CN108363703A CN201810087216.4A CN201810087216A CN108363703A CN 108363703 A CN108363703 A CN 108363703A CN 201810087216 A CN201810087216 A CN 201810087216A CN 108363703 A CN108363703 A CN 108363703A
Authority
CN
China
Prior art keywords
multilingual
language
value
key
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810087216.4A
Other languages
Chinese (zh)
Inventor
刘德建
陈铭
陈红和
郭玉湖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian Tianquan Educational Technology Ltd
Original Assignee
Fujian Tianquan Educational Technology Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian Tianquan Educational Technology Ltd filed Critical Fujian Tianquan Educational Technology Ltd
Priority to CN201810087216.4A priority Critical patent/CN108363703A/en
Publication of CN108363703A publication Critical patent/CN108363703A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/40Processing or translation of natural language
    • G06F40/58Use of machine translation, e.g. for multi-lingual retrieval, for server-side translation for client devices or for real-time translation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Machine Translation (AREA)

Abstract

The present invention provides a kind of multilingual solution of front end applications, storage medium, and method includes:Code is converted in switching according to language environment, includes multilingual transfer function in transformed code;Wherein, in the multilingual transfer function comprising switching before language environment language pack file in value concrete syntax content.The concrete syntax content of value in language pack file comprising language environment before conversion in the multilingual transfer function that the present invention is write;It realizes that the front and back code of language environment conversion is consistent, ensures that the key message of code is not lost, so that code is more clear readable and easy to maintain.Further, it supports, according to specific business demand, flexibly to choose whether to provide key parameters, realize the tradeoff between development efficiency, cost and code conversion efficiency, improve practicability.

Description

The multilingual solution of front end applications, storage medium
Technical field
The present invention relates to the language pack process fields of front-end product, particularly relate to the multilingual solution party of front end applications Method, storage medium.
Background technology
At present in some international front-end products, for example, game, web, app etc., the international solution of language, It is to create a language pack file mostly, file content is key, and the list of value forms, wherein key are language tags, Value is specific language content, for example, the listings format of the language pack file of Chinese is as follows:
{
sc:You will delete in determination,
xdr:Order people when single under being defaulted as the version automatically,
xmxz:Need source items selection
}
The listings format of the language pack file of English is as follows:
{
sc:Are you sure delete date,
xdr:Default version accecpter,
xmxz:Please choice project
}
When practice, various countries' language is stored separately on different files.
Then in code, indicate that specific meaning, the code after original code and internationalization are as follows using key It is shown:
Code originally:
Wherein, i18n is multilingual transfer function, according to current language environment, by key:Sc is converted to the text of corresponding languages Word.As can be seen that after internationalization code " loss " key message of original code (code key message is meant here, Developer can intuitively understand the intention of the code by checking code) so that code becomes no longer complete clear, Wu Fazhi That sees finds out the thing to be done.Such as:" you will delete in determination for display in original code", developer is known that this at a glance A place is a removing module, it is therefore an objective to it is desirable that user reaffirms deletion.However after internationalizing, only stayed in code Next " sc " indicates, i.e. the value of key, what meaning this " sc " is, can not be understoodSuch way is big in being highly detrimental to The exploitation and debugging of sizable application and multi-person synergy application.
Invention content
The technical problem to be solved by the present invention is to:A kind of multilingual solution of front end applications, storage medium are provided, So that language environment conversion it is front and back code it is consistent, ensure that the key message of code is not lost, make code be more clear it is readable and It is easy to maintain.
In order to solve the above-mentioned technical problem, the technical solution adopted by the present invention is:
A kind of multilingual solution of front end applications, including:
Code is converted in switching according to language environment, includes multilingual transfer function in transformed code;Its In, the concrete syntax content of value in the language pack file comprising the language environment before switching in the multilingual transfer function.
Another technical solution provided by the invention is:
A kind of computer storage media, is stored thereon with computer program, which realizes above-mentioned when being executed by processor The step of multilingual solution of front end applications is included.
The beneficial effects of the present invention are:The present invention transformed code will be converted using multilingual transfer function Language content wraps up, and writes the concrete syntax of value in the language pack file of the preceding language environment of conversion exactly in transfer function Content.It is achieved in when according to language environment transcode, it can direct basis key:The correspondence of value is by above-mentioned tool Body language content is converted to the word of corresponding languages, and transformed code is made still to possess due information originally, i.e., Information before conversion, rather than the value of key this mark.The code that the present invention realizes before and after language environment conversion is consistent, protects Card code key message do not lose, so that code is more clear readable and easy to maintain, be relatively beneficial to middle large-scale application with it is more The exploitation and debugging of people's synergistic application.
Description of the drawings
Fig. 1 is the flow diagram of the embodiment of the present invention one.
Specific implementation mode
To explain the technical content, the achieved purpose and the effect of the present invention in detail, below in conjunction with embodiment and coordinate attached Figure is explained.
The design of most critical of the present invention is:Include the language pack file of language environment before conversion in multilingual transfer function The concrete syntax content of middle value;It realizes that the front and back code of language environment conversion is consistent, ensures that the key message of code is not lost It loses, so that code is more clear readable and easy to maintain.
Explanation of technical terms of the present invention:
Referring to Fig. 1, the present invention provides a kind of multilingual solution of front end applications, including:
Code is converted in switching according to language environment, includes multilingual transfer function in transformed code;Its In, the concrete syntax content of value in the language pack file comprising the language environment before switching in the multilingual transfer function.
As can be seen from the above description, the beneficial effects of the present invention are:By being protected before so that transformed code and state is converted It holds unanimously, ensures that the key message of code is not lost, so that code is more clear readable and easy to maintain.
Further, the multilingual transfer function also includes the value of the corresponding key of the value.
Further, if the key for including in the multilingual transfer function is not sky,
The multilingual transfer function when called, the value for the key that direct basis is included, from transformed language ring The concrete syntax content of the corresponding value of value of the key is obtained in the language pack file in border.
Seen from the above description, if being provided with key parameters, transfer function can be existed with the key parameters that direct basis provides The corresponding language content of quick obtaining in the language pack file of current language environment, and without scanning for determining, save removal search The loss that language pack is brought, is obviously improved transfer efficiency.
Further, if the key for including in the multilingual transfer function is sky, or the key is not included, then
The multilingual transfer function when called, in the concrete syntax for including according to multilingual transfer function Hold, the value of corresponding key is determined from the language pack file of the language environment before conversion, then from transformed language environment In language pack file, the value according to the key obtains corresponding concrete syntax content and returns.
Seen from the above description, if consumption less (such as the pc environment or 5 within 20,000 that search language band comes Mobile terminal environment within thousand), then the parameter can not be provided, to promote development efficiency, save development cost.
Further, the value of the corresponding key of the determination, specially:
By the value group numbers in the language pack file of the language environment before the traversal conversion, the specific language is obtained Say the value of the corresponding key of content.
Seen from the above description, described search efficiency is improved by traversing to search.
Further, further include:
The language pack file of language environment before load conversion;
Load the language pack file of transformed language environment.
Seen from the above description, the front and back language pack file of conversion can be loaded in advance, be convenient for fast search into line code Conversion.
Further, further include:Language pack file is that key is stored with the tabular form of corresponding value.
Seen from the above description, language pack file uses above-mentioned tabular form, convenient for true according to correspondence fast search Fixed required concrete syntax content, at the same it is easy to maintain.
Another technical solution provided by the invention is:
A kind of computer storage media, is stored thereon with computer program, which realizes above-mentioned when being executed by processor The step of multilingual solution of the front end applications is included.
As can be seen from the above description, the beneficial effects of the present invention are:It corresponds to one of ordinary skill in the art will appreciate that real All or part of flow in this technical solution of the existing multilingual solution of above-mentioned front end applications, is that can pass through computer Program instructs relevant hardware come what is realized, and the program can be stored in a computer-readable storage medium, should Program is when being executed, it may include such as the flow of above-mentioned each method.
Embodiment one
Fig. 1 is please referred to, the present embodiment provides a kind of multilingual solutions of front end applications, and it is in need can to apply to institute It carries out in international front-end product, includes the different language switching of game, web, app etc..The present embodiment is as shown in Figure 1, can To include the following steps:
S1:Create language pack file.
Specifically, corresponding language pack file is created according to the language environment supported, such as:Think to support simultaneously China and British, The switching of day three state's language, then need to create Chinese language APMB package, english language APMB package, Japanese language pack file simultaneously.
The language pack file created is according to key:The correspondence of value, is stored with tabular form.Wherein, key For language tag, value is corresponding concrete syntax content.Specific format is as follows:
{
sc:You will delete in determination,
xdr:Order people when single under being defaulted as the version automatically,
xmxz:Need source items selection
}
" sc " therein, " xdr " and " xmxz " is key;Corresponding concrete syntax content is as " you will delete in determination " it is the value for corresponding to " sc ".Above-mentioned code listing is the language pack file of Chinese;The code column of the language pack file of English Table is as follows:
{
sc:Are you sure delete date,
xdr:Default version accecpter,
xmxz:Please choice project
}
The language pack file of various countries is respectively stored on different files.
In the following, will be to be switched between Chinese and English language environment, current user language environment (the language ring after switching Border) be English for illustrate.
S2:Write multilingual transfer function.
The multilingual transfer functions of common i18n may be used to realize.Multilingual transfer function can be according to current language ring Border passes through key:Current character is converted to the word of corresponding languages (language environment after switching) by the correspondence of value.But It is it is emphasized that existing multilingual transfer function is as follows:
Code originally:
In transfer function therein, directly symbol " sc " is used to refer to the word content shown in original code, converted When function is called, it is replaced although " sc " corresponding content can be found from english language packet according to symbol " sc ", For present code, original important key message is lost, technical staff can not be intuitive by code Solve the intention of code.
And in the present embodiment, the multilingual transfer functions of i18n which is write are:Function i18n (value, Key=null).Since the present embodiment is illustrated so that Chinese is converted to English as an example, in multilingual transfer function, value:" you will delete the particular content of Chinese language in determination", correspond to the value in Chinese language packet;key:Specific language Say that the key values " sc " of language pack where content corresponds to, the parameter allow for sky.
As it can be seen that contained in the multilingual transfer function of the present embodiment switching before language environment language pack file in The concrete syntax content of value can also include parameter key (the key=null i.e. parameter is sky).The transfer function energy according to Input parameter returns to the corresponding spoken and written languages of current environment (transformed language environment), such as input is that hello, is currently English Literary environment, output is exactly hello.
About whether key parameters (i.e. whether key is null) are provided, can be determined according to actual scene by specific business Fixed, the purpose for providing key is that the language content that can find current language environment faster for i18n (does not have in english language The corresponding key values of particular content of value are found in packet), so if under existing hardware environment, what search language band came Consumption less (such as pc environment within 20,000 or mobile terminal environment within 5000), can not provide this completely Parameter saves development cost to promote development efficiency;If language pack very little, it can select not providing parameter key, be reduced out with this Cost is sent out, development efficiency is improved.
S3:Write internationalization code.
By specific business logic codes, using above-mentioned multilingual transfer function by the specific of the languages of being carried out conversion Language content wraps up, for example, corresponding " original code " among the above can carry respectively according to whether " key values " is provided For two different code forms:
The code 1 of internationalization (English):
function makeConfirm(){
((' can determine that be deleted i18n AlertPanel.show'))
}
And internationalization code 2:
function makeConfirm(){
((' can determine that be deleted i18n AlertPanel.show', ' sc '))
}
It is found that in transformed code, the language of the language environment before switching is write direct in its multilingual transfer function " you will delete the concrete syntax content of value in determination in speech APMB package", language environment is had switched even if just realizing in this way, But still maintain consistent before and after code conversion, the key message of code can't be lost, and ensure that the clear readability of code, It is again easy to maintain simultaneously.
S4:Obtain current language environment;
S5:Judge whether current language environment is Chinese, if so, directly invoking source code, directly returns to value's Concrete syntax content;If it is not, then executing S6;
S6:The language pack file (language pack file of the english language environment after switching) of current language environment is loaded, It is saved in variable cur-lan;
S7:The language pack file (language pack file of the Chinese language environment before switching) of Chinese language environment is loaded, It is saved in variable cu-lan;
S8:It calls and executes write internationalization code.
Specifically, including:
S81:Judge whether the parameter key of multilingual transfer function in write internationalization code is null, i.e., whether For sky, if so, executing S82;If it is not, then executing S84;
S82:The value group numbers in the language pack file of the language environment before conversion are traversed, include in acquisition transfer function Concrete syntax content (i.e. value in transfer function) corresponding to key value;Then S84 is executed;Specifically, i.e. by pair Than the particular content of value in Chinese language APMB package, " you will delete in determination for acquisition" corresponding key values are " sc ";
S83:From the language pack file of transformed language environment, the value according to the key obtains corresponding specific language Speech content simultaneously returns.Specifically, i.e. from english language packet, english language " the Are you sure that key values are " sc " are got delete data", and be back to front end and show.Continue to execute S9;
S82:The value for the key for including in the multilingual switching function of direct basis returns to cur-lan [key];
Specifically, obtaining the concrete syntax content of the corresponding value of value of the key from english language APMB package “Are you sure delete data", and be back to front end and show.Continue to execute S9;
S9:Front end shows:" the Are you sure delete data that multilingual switching function is returned" pass to AlertPanel.show is shown, is completed language pack and is replaced.
The present embodiment is searched by direction, realizes that the height of code under multi-language environment is readable.
Embodiment two
The present embodiment corresponding embodiment one provides a kind of computer storage media, is stored thereon with computer program, the journey Realized when sequence is executed by processor whole that the multilingual solution of the front end applications described in above-described embodiment one is included or Person's part steps.
In conclusion a kind of multilingual solution of front end applications provided by the invention, storage medium, that is write is more The concrete syntax content of value in language pack file comprising language environment before conversion in language conversion function;Realize language ring Conversion front and back code in border is consistent, ensures that the key message of code is not lost, so that code is more clear readable and easy to maintain.Into One step, it supports, according to specific business demand, flexibly to choose whether to provide key parameters, realize development efficiency, cost and generation Tradeoff between code transfer efficiency, improves practicability.
Example the above is only the implementation of the present invention is not intended to limit the scope of the invention, every to utilize this hair Equivalents made by bright specification and accompanying drawing content are applied directly or indirectly in relevant technical field, include similarly In the scope of patent protection of the present invention.

Claims (8)

1. a kind of multilingual solution of front end applications, which is characterized in that including:
Code is converted in switching according to language environment, includes multilingual transfer function in transformed code;Wherein, institute State the concrete syntax content of value in the language pack file comprising the language environment before switching in multilingual transfer function.
2. the multilingual solution of front end applications as described in claim 1, which is characterized in that the multilingual transfer function Also include the value of the corresponding key of the value.
3. the multilingual solution of front end applications as claimed in claim 2, which is characterized in that if the multilingual conversion letter The key for including in number is not sky, then
The multilingual transfer function when called, the value for the key that direct basis is included, from transformed language environment The concrete syntax content of the corresponding value of value of the key is obtained in language pack file.
4. the multilingual solution of front end applications as claimed in claim 2, which is characterized in that if the multilingual conversion letter The key for including in number is sky, or does not include the key, then
The multilingual transfer function when called, according to the concrete syntax content that multilingual transfer function includes, from The value that corresponding key is determined in the language pack file of language environment before conversion, then from the language of transformed language environment In APMB package, the value according to the key obtains corresponding concrete syntax content and returns.
5. the multilingual solution of front end applications as claimed in claim 4, which is characterized in that the corresponding key of the determination Value, specially:
By the value group numbers in the language pack file of the language environment before the traversal conversion, obtain in the concrete syntax Hold the value of corresponding key.
6. the multilingual solution of front end applications as described in claim 1, which is characterized in that further include:
The language pack file of language environment before load conversion;
Load the language pack file of transformed language environment.
7. the multilingual solution of front end applications as described in claim 1, which is characterized in that language pack file be key with The tabular form of corresponding value is stored.
8. a kind of computer storage media, is stored thereon with computer program, which is characterized in that when the program is executed by processor Realize the step of multilingual solution of the front end applications described in the claims 1-7 any one is included.
CN201810087216.4A 2018-01-30 2018-01-30 The multilingual solution of front end applications, storage medium Pending CN108363703A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810087216.4A CN108363703A (en) 2018-01-30 2018-01-30 The multilingual solution of front end applications, storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810087216.4A CN108363703A (en) 2018-01-30 2018-01-30 The multilingual solution of front end applications, storage medium

Publications (1)

Publication Number Publication Date
CN108363703A true CN108363703A (en) 2018-08-03

Family

ID=63007609

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810087216.4A Pending CN108363703A (en) 2018-01-30 2018-01-30 The multilingual solution of front end applications, storage medium

Country Status (1)

Country Link
CN (1) CN108363703A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408167A (en) * 2018-09-20 2019-03-01 摩尔元数(厦门)科技有限公司 A kind of multilingual processing method and computer equipment of B/S framework logging data
CN109542555A (en) * 2018-10-26 2019-03-29 深圳点猫科技有限公司 A kind of international programming implementation method of realization educational applications and device
CN112256365A (en) * 2020-09-27 2021-01-22 福建天泉教育科技有限公司 Method and terminal for automatically managing multi-language versions
CN115858985A (en) * 2023-01-29 2023-03-28 北京易思汇商务服务有限公司 Method for establishing multi-language environment and switching languages on same website

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150143413A1 (en) * 2012-07-09 2015-05-21 Cisco Technology, Inc. Method and system for automatically generating interstitial material related to video content
US20150149526A1 (en) * 2011-08-26 2015-05-28 Netflix, Inc. Internationalization with virtual staging and versioning
CN104714968A (en) * 2013-12-16 2015-06-17 中国银联股份有限公司 Method and device for internationalizing web page
CN105824794A (en) * 2016-03-11 2016-08-03 天脉聚源(北京)教育科技有限公司 Annotation adding method and device
CN105867920A (en) * 2016-03-29 2016-08-17 海尔优家智能科技(北京)有限公司 APP multi-language switching method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150149526A1 (en) * 2011-08-26 2015-05-28 Netflix, Inc. Internationalization with virtual staging and versioning
US20150143413A1 (en) * 2012-07-09 2015-05-21 Cisco Technology, Inc. Method and system for automatically generating interstitial material related to video content
CN104714968A (en) * 2013-12-16 2015-06-17 中国银联股份有限公司 Method and device for internationalizing web page
CN105824794A (en) * 2016-03-11 2016-08-03 天脉聚源(北京)教育科技有限公司 Annotation adding method and device
CN105867920A (en) * 2016-03-29 2016-08-17 海尔优家智能科技(北京)有限公司 APP multi-language switching method and system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408167A (en) * 2018-09-20 2019-03-01 摩尔元数(厦门)科技有限公司 A kind of multilingual processing method and computer equipment of B/S framework logging data
CN109542555A (en) * 2018-10-26 2019-03-29 深圳点猫科技有限公司 A kind of international programming implementation method of realization educational applications and device
CN112256365A (en) * 2020-09-27 2021-01-22 福建天泉教育科技有限公司 Method and terminal for automatically managing multi-language versions
CN112256365B (en) * 2020-09-27 2022-06-07 福建天泉教育科技有限公司 Method and terminal for automatically managing multi-language versions
CN115858985A (en) * 2023-01-29 2023-03-28 北京易思汇商务服务有限公司 Method for establishing multi-language environment and switching languages on same website

Similar Documents

Publication Publication Date Title
CN108363703A (en) The multilingual solution of front end applications, storage medium
CN104281601B (en) Build method and device, character display method and the device of super large character library
US20140025684A1 (en) Indexing and searching a data collection
US20180239743A1 (en) Keyboard input corresponding to multiple languages
US20060033644A1 (en) System and method for filtering far east languages
JP2014160252A (en) Electronic equipment, character string display method and character string display program
US20210337059A1 (en) Initiating application execution with trigger characters
CN110704608A (en) Text theme generation method and device and computer equipment
CN107566090B (en) Fixed-length/variable-length text message processing method and device
CN105278961A (en) Method and system for generating database table structure document
CN106873971B (en) Multi-language display method and system for flash application
CN110309631A (en) A kind of programming language structure obscures processing method, intelligent terminal and storage medium
CN111142871B (en) Front-end page development system, method, equipment and medium
CN107329756B (en) Program file generation method and device, storage medium, processor and terminal
CN103428341A (en) Method and device for searching for mobile phone contacts
CN105425977A (en) Special symbol input method and input method system
US9405739B1 (en) Source code format for IDE code development with embedded objects
US10769372B2 (en) Synonymy tag obtaining method and apparatus, device and computer readable storage medium
CN102723067B (en) A kind of character display method and device
US11687735B2 (en) Method, apparatus, device and storage medium for outputting information
CN112711435A (en) Version updating method, version updating device, electronic equipment and storage medium
US10712912B2 (en) Generating contextual cues linking related browser tabs
CN101325758A (en) Mobile communication equipment capable of displaying multiple languages and method thereof
CN107479890B (en) Method and system for displaying command help information by using different characters based on Zebra
JP4740425B2 (en) Character code input support system, character code input support program

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination