CN106569793B - Js internationalization implementation method based on node - Google Patents

Js internationalization implementation method based on node Download PDF

Info

Publication number
CN106569793B
CN106569793B CN201610829968.4A CN201610829968A CN106569793B CN 106569793 B CN106569793 B CN 106569793B CN 201610829968 A CN201610829968 A CN 201610829968A CN 106569793 B CN106569793 B CN 106569793B
Authority
CN
China
Prior art keywords
resource
service data
internationalized
resource file
language
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.)
Active
Application number
CN201610829968.4A
Other languages
Chinese (zh)
Other versions
CN106569793A (en
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.)
Inspur General Software Co Ltd
Original Assignee
Tidal Group Co 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 Tidal Group Co Ltd filed Critical Tidal Group Co Ltd
Priority to CN201610829968.4A priority Critical patent/CN106569793B/en
Publication of CN106569793A publication Critical patent/CN106569793A/en
Application granted granted Critical
Publication of CN106569793B publication Critical patent/CN106569793B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • 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/451Execution arrangements for user interfaces
    • G06F9/454Multi-language systems; Localisation; Internationalisation

Abstract

The invention discloses a node.js-based internationalization implementation method, which belongs to the field of software internationalization and aims to solve the technical problem of how to meet the language requirements of different regions, and extract required languages and related culture elements from a system to form resource files for processing and returning the resource files to contents meeting the requirements of system users. The technical scheme is as follows: the realization method is that after the system language is confirmed according to the language setting of the system user, the internationalization is realized by adopting a static resource file mode for page characters and operation prompt information, the resource file is cached by adopting a mode of adding the resource file to the database index for the service data, and then the internationalization content is obtained according to the database index, so that the internationalization of the service data is realized.

Description

Js internationalization implementation method based on node
Technical Field
The invention relates to the field of software internationalization, in particular to a node.js-based internationalization implementation method.
Background
Js is a Javascript runtime environment (runtime). It is actually encapsulating the Google V8 engine. The V8 engine executes Javascript very fast and has very good performance. Js optimizes some special cases and provides alternative APIs, so that V8 performs better in a non-browser environment.
Js is a platform established based on Chrome JavaScript operation and is used for conveniently establishing network application with high response speed and easy expansion. Js uses an event-driven, non-blocking I/O model to be lightweight and efficient, and is well suited to running data-intensive real-time applications on distributed devices.
When software is developed, the software can simultaneously deal with accesses of different regions and countries of the world and provide corresponding pages or data which accord with the reading habits of visitors aiming at the accesses of different regions and countries. In a traditional software system, interface characters are processed in an internationalized mode mostly in a resource file mode, business data stored in a database are in a database resource table mode, different language forms of the business data needing internationalization are stored in the resource table, and when web requests are associated for query, great pressure is formed on the database, so that the query becomes complicated and cumbersome, and maintenance is not facilitated.
How to meet the language requirements of different regions is a technical problem in the prior art at present, which is to extract the required language and related cultural elements from the system to form resource files to process and return the resource files to the content meeting the requirements of the system user.
Disclosure of Invention
Aiming at the defects, the technical task of the invention is to provide a node.js-based internationalization implementation method to solve the problem of how to meet the language requirements of different regions, extract the required language and related culture elements from the system to form a resource file, process the resource file and return the resource file to the content meeting the requirements of the system user.
The technical scheme adopted by the invention for solving the technical problems is as follows: js is an internationalization realizing method based on node, which realizes internationalization of service data by adopting a mode of static resource files for page characters and operation prompt information after confirming system language according to language setting of system users, caching the resource files by adopting a mode of database index and resource files for the service data, and then obtaining internationalized content according to the database index.
Preferably, the specific steps of the implementation method are as follows:
(1) extracting international resource files of different language versions in a system development stage, wherein the international resource files comprise page characters of a system client, operation prompt information and elements of different language texts of system server service data; the internationalized resource files comprise static resource files and service data resource files;
(2) adding an index column during the structural design of a database table, storing an internationalized resource key value corresponding to the business data by using a database index by the system, and forming association with the content of an internationalized resource file;
(3) when the system is started, loading the service data resource file, and putting the service data resource file into a cache server to form an internationalized resource cache pool;
(4) when the system receives the page request, firstly confirming the language selected by the system user, then reading the corresponding international resource file from the cache server according to the language requested by the system client and the index stored in the database, and returning the content meeting the requirement to the system user;
(5) when the service is processed, the system inquires a service table and retrieves an internationalized resource key value corresponding to the service data;
(6) through service inquiry, the system obtains service data and corresponding internationalized resource key values, obtains internationalized contents corresponding to the service data according to the language set by a system user and the corresponding internationalized resource key values in an internationalized resource cache pool, and returns the internationalized contents to the system client to realize internationalization of the service data;
(7) after the service processing of the system server is finished, when the browser loads a page, loading a static resource file corresponding to a language set by a system user, and replacing page characters and operation prompt information to realize the internationalization of the page characters and the operation prompt information;
(8) and when the service data changes, synchronously updating the static resource file, the service data resource file and the database index, updating the record in the cache server, and smoothly replacing the international content to be updated.
Preferably, the system user in step (4) includes the following situations:
①, if the system user is logged in, extracting the language setting of the system user;
②, if the system user is not logged in, reading the last language setting of the system user stored in the cookie;
③, if there is no corresponding setting in the cookie, using the default language of the browser setting;
④, if none of the above information exists, the default language of the system is used as the language setting for the system user.
Preferably, when the system server stores the service data in step (7), the system server stores an index of a resource file corresponding to the service data.
Compared with the prior art, the node.js-based internationalization implementation method has the following beneficial effects:
1. after the system language is confirmed according to the language setting of the user, internationalization is realized by adopting a static resource file mode for page characters and operation prompt information, internationalization is realized for service data, a database index and resource file mode is adopted, the resource file is cached, internationalized content is obtained according to the index, internationalized service data is realized, the requirement of the user internationalization is met in an all-round manner, and the user experience of the system is improved;
2. the invention aims to meet the language requirements of different regions, extracts required languages and related culture elements from a system to form resource files, processes the resource files and returns the resource files to contents meeting the user requirements, and solves the problem that in a traditional software system, a form of a database resource table is generally adopted, all character texts needing internationalization are put into the resource table, and the resource table is associated when the contents of different languages need to be returned, so that the query becomes complicated.
Therefore, the invention has the characteristics of reasonable design, convenient use, multiple purposes and the like, thereby having good popularization and use values.
Drawings
The invention is further described below with reference to the accompanying drawings.
Fig. 1 is a flow chart of an internationalized implementation method based on node.
Detailed Description
The invention is further described with reference to the following figures and specific examples.
Example 1
The invention relates to a node.js-based internationalization implementation method, which is characterized in that after system language is confirmed according to language setting of a system user, internationalization is implemented by adopting a static resource file mode for page characters and operation prompt information, a resource file is cached for service data in a mode of adding a database index and the resource file, and internationalization content is acquired according to the database index, so that internationalization of the service data is implemented.
As shown in fig. 1, the specific steps of the implementation method are as follows:
(1) extracting international resource files of different language versions in a system development stage, wherein the international resource files comprise page characters of a system client, operation prompt information and elements of different language texts of system server service data; the internationalized resource files comprise static resource files and service data resource files;
(2) adding an index column during the structural design of a database table, storing an internationalized resource key value corresponding to the business data by using a database index by the system, and forming association with the content of an internationalized resource file;
(3) when the system is started, loading the service data resource file, and putting the service data resource file into a cache server to form an internationalized resource cache pool;
(4) when the system receives the page request, firstly confirming the language selected by the system user, then reading the corresponding international resource file from the cache server according to the language requested by the system client and the index stored in the database, and returning the content meeting the requirement to the system user;
the system user includes the following situations:
①, if the system user is logged in, extracting the language setting of the system user;
②, if the system user is not logged in, reading the last language setting of the system user stored in the cookie;
③, if there is no corresponding setting in the cookie, using the default language of the browser setting;
④, if none of the above information exists, using the default language of the system as the language setting for the system user;
(5) when the service is processed, the system inquires a service table and retrieves an internationalized resource key value corresponding to the service data;
(6) through service inquiry, the system obtains service data and corresponding internationalized resource key values, obtains internationalized contents corresponding to the service data according to the language set by a system user and the corresponding internationalized resource key values in an internationalized resource cache pool, and returns the internationalized contents to the system client to realize internationalization of the service data;
(7) after the service processing of the system server is finished, when the browser loads a page, loading a static resource file corresponding to a language set by a system user, and replacing page characters and operation prompt information to realize the internationalization of the page characters and the operation prompt information; when the system server side stores the service data, the system server side stores the index of the resource file corresponding to the service data;
(8) and when the service data changes, synchronously updating the static resource file, the service data resource file and the database index, updating the record in the cache server, and smoothly replacing the international content to be updated.
Example 2
Js, the page characters, operation prompt information and service data, the internationalization of the page characters and the operation prompt information is realized by a method of static resource files, and the internationalization of the service data is realized by a method of resource files and database indexes. The specific implementation steps are as follows:
(1) defining a resource file, extracting page characters, operation prompt information and contents of service data, and providing versions of different languages;
the resource file uses javascrpit or json and other forms to externally output objects in the json form;
the following is an example of a resource file in Chinese:
exports.i 18n={
"login" of "
}
English resource file:
exports.i 18n={
”login”:”login”
};
(2) establishing association between the business data and the resource files, adding resource index columns and storing resource key values when a database table structure is designed;
(3) and when the system is started, loading the resource file, caching the resource file to a cache server, and forming a resource pool.
(4) When the client requests a page from the server, the server queries the corresponding index during service query, and acquires the corresponding international content from the cache server;
(5) and finally displaying the character strings meeting the requirements on the Web page.
The present invention can be easily implemented by those skilled in the art from the above detailed description. It should be understood, however, that the intention is not to limit the invention to the particular embodiments described. On the basis of the disclosed embodiments, a person skilled in the art can combine different technical features at will, thereby implementing different technical solutions.
In addition to the technical features described in the specification, the technology is known to those skilled in the art.

Claims (4)

1. Js, the method is to adopt the mode of static resource file to page character and operation prompt information to realize internationalization, adopt the way of database index plus resource file to cache the resource file to the service data, then obtain the internationalized content according to the database index to realize internationalization of the service data;
the specific implementation steps are as follows:
s1, defining resource files, extracting page characters, operation prompt information and contents of service data, and providing versions of different languages;
the resource file uses a javascrpit or json form, and a json form object is output outwards;
s2, establishing the association between the business data and the resource file, adding a resource index column and storing a resource key value when designing the database table structure;
s3, when the system is started, loading the resource file, caching the resource file to a cache server, and forming a resource pool;
s4, when the client requests the server for the page, the server inquires the corresponding index during service inquiry, and obtains the corresponding international content from the cache server;
and S5, finally displaying the character string meeting the requirement on the Web page.
2. A node.js-based internationalized implementation method as defined in claim 1, wherein the implementation method comprises the following specific steps:
(1) extracting international resource files of different language versions including page characters of a system client, operation prompt information and elements of different language texts of service data of a system server in a system development stage before defining resources in step S1; the internationalized resource files comprise static resource files and service data resource files;
(2) in step S2, an index column is added while the database table structure is designed, and the system stores an internationalized resource key value corresponding to the service data using the database index, and forms an association with the content of the internationalized resource file;
(3) loading the service data resource file while starting the system in the step S3, and putting the service data resource file into a cache server to form an internationalized resource cache pool;
(4) after the client requests the server for the page in step S4, the system receives the page request, firstly confirms the language selected by the system user, then reads the corresponding internationalized resource file from the cache server according to the language requested by the system client and the index stored in the database, and returns the content meeting the requirements to the system user;
(5) after the character string meeting the requirements is displayed on the Web page in the step S5, performing service processing, simultaneously performing service table query by the system, and retrieving the internationalized resource key value corresponding to the service data;
(6) through service inquiry, the system obtains service data and corresponding internationalized resource key values, obtains internationalized contents corresponding to the service data according to the language set by a system user and the corresponding internationalized resource key values in an internationalized resource cache pool, and returns the internationalized contents to the system client to realize internationalization of the service data;
(7) after the service processing of the system server is finished, when the browser loads a page, loading a static resource file corresponding to a language set by a system user, and replacing page characters and operation prompt information to realize the internationalization of the page characters and the operation prompt information;
(8) and when the service data changes, synchronously updating the static resource file, the service data resource file and the database index, updating the record in the cache server, and smoothly replacing the international content to be updated.
3. A node.js-based international realization method according to claim 2, wherein said system user in step (4) includes the following cases:
①, if the system user is logged in, extracting the language setting of the system user;
②, if the system user is not logged in, reading the last language setting of the system user stored in the cookie;
③, if there is no corresponding setting in the cookie, using the default language of the browser setting;
④, if none of the above information exists, the default language of the system is used as the language setting for the system user.
4. The internationalized implementation method based on node. js as claimed in claim 2, wherein in the step (7), when the system server saves the service data, the system server saves an index of a resource file corresponding to the service data.
CN201610829968.4A 2016-09-19 2016-09-19 Js internationalization implementation method based on node Active CN106569793B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610829968.4A CN106569793B (en) 2016-09-19 2016-09-19 Js internationalization implementation method based on node

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610829968.4A CN106569793B (en) 2016-09-19 2016-09-19 Js internationalization implementation method based on node

Publications (2)

Publication Number Publication Date
CN106569793A CN106569793A (en) 2017-04-19
CN106569793B true CN106569793B (en) 2020-02-14

Family

ID=58531852

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610829968.4A Active CN106569793B (en) 2016-09-19 2016-09-19 Js internationalization implementation method based on node

Country Status (1)

Country Link
CN (1) CN106569793B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019071406A1 (en) * 2017-10-10 2019-04-18 深圳中兴力维技术有限公司 Front-end page internationalization processing method, application server and computer readable storage medium
CN109683998B (en) * 2017-10-19 2022-04-26 北京京东尚科信息技术有限公司 Internationalization realization method, device and system
CN109976840B (en) * 2017-12-27 2022-03-04 航天信息股份有限公司 Method and system for realizing multi-language automatic adaptation based on foreground and background separation platform
CN108287880A (en) * 2018-01-05 2018-07-17 广东睿江云计算股份有限公司 A kind of international method and device of homepages language
CN109582414A (en) * 2018-11-06 2019-04-05 福建天泉教育科技有限公司 Using international method, storage medium
CN111488339B (en) * 2019-01-25 2023-10-27 上海哔哩哔哩科技有限公司 NoSQL database based on node.JS, establishing and processing method
CN110673915A (en) * 2019-09-24 2020-01-10 四川天邑康和通信股份有限公司 Web management page language switching method for ONU
CN113157354B (en) * 2020-01-07 2023-11-03 北京京东振世信息技术有限公司 Method, apparatus, device and computer readable medium for processing data
CN114491359A (en) * 2021-12-28 2022-05-13 北京航天智造科技发展有限公司 Webpage internationalization processing method and device
CN115618887B (en) * 2022-10-17 2023-07-25 北京志凌海纳科技有限公司 Dynamic long text internationalization method, device, equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8412510B2 (en) * 2010-04-21 2013-04-02 Fisher-Rosemount Systems, Inc. Methods and apparatus to display localized resources in process control applications
CN101894025A (en) * 2010-07-26 2010-11-24 沈阳酷洲软件开发有限公司 Dynamic electronic information internationalizing method
CN104375808B (en) * 2013-07-11 2018-07-20 上海携程商务有限公司 interface display method and device
CN103544306A (en) * 2013-11-01 2014-01-29 广东威创视讯科技股份有限公司 Multi-language display supporting method and device of website
CN104714968A (en) * 2013-12-16 2015-06-17 中国银联股份有限公司 Method and device for internationalizing web page

Also Published As

Publication number Publication date
CN106569793A (en) 2017-04-19

Similar Documents

Publication Publication Date Title
CN106569793B (en) Js internationalization implementation method based on node
EP3113043B1 (en) Method, device and host for updating metadata stored in columns in distributed file system
JP6761112B2 (en) Methods and systems for server-side rendering of native content for presentation
US8560562B2 (en) Predictive query suggestion caching
CN100541495C (en) A kind of searching method of individual searching engine
CN103383687B (en) A kind of page processing method and device
US9342626B1 (en) Query suggestions based on entity collections of one or more past queries
US20140331124A1 (en) Method for maintaining common data across multiple platforms
JP2017157192A (en) Method of matching between image and content item based on key word
CN105550206B (en) The edition control method and device of structured query sentence
US20140236941A1 (en) Discovery engine
CN104679898A (en) Big data access method
CN107092639A (en) A kind of search engine system
CN108446313B (en) Data format conversion method and device
CN105302876A (en) Regular expression based URL filtering method
CN101425086A (en) Dictionary enquiry method and dictionary enquiry system based on network
CN105204806A (en) Individual display method and device for mobile terminal webpage
CN110955855B (en) Information interception method, device and terminal
CN108763279B (en) Webpage data distributed template acquisition method and system
US11321329B1 (en) Systems, apparatuses, and methods for document querying
CN103914479A (en) Resource request matching method and device
WO2019000897A1 (en) Data acquisition method and device
US20190245925A1 (en) Information processing device, information processing method, program, and storage medium
US9208233B1 (en) Using synthetic descriptive text to rank search results
US9208232B1 (en) Generating synthetic descriptive text

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200109

Address after: 250100 Ji'nan high tech Zone, Shandong, No. 1036 wave road

Applicant after: Tidal Group Co., Ltd.

Address before: 250100, Shandong, Ji'nan Province town of Sun Ke Road, No. 2877 R & D building on the first floor

Applicant before: Ji'nan wave high and New Technology Investment Development Co., Ltd.

GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20200902

Address after: 250100 Ji'nan high tech Zone, Shandong, No. 1036 wave road

Patentee after: INSPUR GENERAL SOFTWARE Co.,Ltd.

Address before: 250100 Ji'nan high tech Zone, Shandong, No. 1036 wave road

Patentee before: INSPUR GROUP Co.,Ltd.