Browser language configuration methods, devices, storage media, and program products
By receiving access instructions in the browser and detecting language configuration information in priority order, the difficulty of manually switching languages on different sites is solved, achieving seamless language switching and improving the user experience.
Patent Information
- Application Number
- CN202210676424.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-15
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-06-15
AI Technical Summary
Existing browsers require manual language switching when accessing different websites, which is inconvenient and results in a poor user experience. This is especially true when the language switching entry point is hidden on the website's front end, further impacting the user experience.
By receiving access operation instructions, the system detects language configuration information from the browser environment configuration information according to a preset priority order, determines the target language, and renders the page according to the target language. It supports multiple detection methods such as cookies, URL query fields, network storage data, browser information, and HTML tags, enabling seamless language switching.
It simplifies user operations, enables quick and seamless language switching when accessing different sites, and improves the user experience.
Smart Images

Figure CN117271923B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer and network communication technology, and in particular to a browser language configuration method, device, storage medium, and program product. Background Technology
[0002] Internationalization of software refers to the design of software to support or easily adapt to the needs of users who use different languages and have different cultural backgrounds, and to enable them to communicate globally.
[0003] Some web browsers and multimedia browsers can browse content from different websites. Each website usually has its own internationalization method, which means that users need to manually switch their preferred language when browsing different websites so that the website page is displayed in the language selected by the user; or a default language can be preset so that the default language is used when the user browses different websites.
[0004] Manually switching languages requires user intervention, which is inconvenient and time-consuming. Furthermore, the language switching entry point is often hidden on the front end of some websites, making it even more difficult for users to operate and affecting the user experience. On the other hand, using the default language is not suitable for all scenarios, and in some cases, users still need to manually switch languages. Summary of the Invention
[0005] This disclosure provides a browser language configuration method, device, storage medium, and program product to unify the internationalization of the browser, simplify user operations, and enable quick language switching.
[0006] In a first aspect, embodiments of this disclosure provide a browser language configuration method, including:
[0007] Receive instructions to access the target page;
[0008] Language configuration information is detected from different browser environment configuration information according to a preset priority order, and the target language is determined based on the language configuration information;
[0009] The target page is rendered according to the target language so that the target page is displayed in the target language.
[0010] Secondly, embodiments of this disclosure provide a browser language configuration device, including:
[0011] The input unit is used to receive access operation instructions for the target page;
[0012] The language determination unit is used to detect language configuration information from different browser environment configuration information according to a preset priority order, and determine the target language based on the language configuration information.
[0013] The display unit is used to render the target page according to the target language so that the target page is displayed in the target language.
[0014] Thirdly, embodiments of this disclosure provide an electronic device, including: at least one processor and a memory;
[0015] The memory stores computer-executed instructions;
[0016] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the browser language configuration method as described in the first aspect and various possible designs of the first aspect.
[0017] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the browser language configuration method described in the first aspect and various possible designs of the first aspect.
[0018] Fifthly, embodiments of this disclosure provide a computer program product, including computer execution instructions, which, when executed by a processor, implement the browser language configuration method described in the first aspect and various possible designs of the first aspect.
[0019] The browser language configuration method, device, storage medium, and program product provided in this disclosure receive an access command for a target page; detect language configuration information from different browser environment configuration information according to a preset priority order; determine the target language based on the language configuration information; and render the target page according to the target language so that the target page is displayed in the target language. This disclosure supports multiple different methods for detecting language configuration information, unifying the internationalization method when a browser accesses different sites. It can detect language configuration information from different browser environment configuration information in a preset priority order, more reasonably determining the target language of the target page. Users do not need to manually switch languages, simplifying user operations and enabling quick and seamless language switching when accessing different target pages, thus improving the user experience. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A scenario example diagram illustrating a browser language configuration method provided in an embodiment of this disclosure;
[0022] Figure 2 This is a schematic flowchart of a browser language configuration method provided in an embodiment of the present disclosure;
[0023] Figure 3 This is a schematic flowchart of a browser language configuration method provided in another embodiment of the present disclosure;
[0024] Figure 4 This is a schematic flowchart of a browser language configuration method provided in another embodiment of the present disclosure;
[0025] Figure 5 A structural block diagram of a browser language configuration device provided in an embodiment of this disclosure;
[0026] Figure 6 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0028] Some web browsers and multimedia browsers can browse content from different websites. Each website usually has its own internationalization method, which means that users need to manually switch their preferred language when browsing different websites so that the website page is displayed in the language selected by the user; or a default language can be preset so that the default language is used when the user browses different websites.
[0029] Manually switching languages requires user intervention, which is inconvenient and time-consuming. Furthermore, the language switching entry point is often hidden on the front end of some websites, making it even more difficult for users to operate and affecting the user experience. On the other hand, using the default language is not suitable for all scenarios, and in some cases, users still need to manually switch languages.
[0030] To address the aforementioned technical issues, this disclosure provides a browser language configuration method that unifies the internationalization process when a browser accesses different websites, simplifies user operations, enables rapid and seamless language switching, and improves user experience. Specifically, it receives an access command for a target page; detects language configuration information from different browser environment configuration information according to a preset priority order; determines the target language based on the language configuration information; and renders the target page according to the target language so that the target page is displayed in the target language. This disclosure supports multiple different methods for detecting language configuration information, unifies the internationalization process when a browser accesses different websites, and allows for the preset priority order for detecting language configuration information from different browser environment configuration information, more rationally determining the target language of the target page. This eliminates the need for users to manually switch languages, simplifies user operations, and enables rapid and seamless language switching when accessing different target pages, thus improving user experience.
[0031] The browser language configuration method provided in this disclosure is applicable to browsers such as... Figure 1 In the application scenario shown, when a user requests access to a target page on a terminal, the terminal can detect language configuration information from different browser environment configuration information according to a preset priority order, determine the target language based on the language configuration information, and then render the target page according to the target language so that the target page is displayed in the target language.
[0032] The browser language configuration method of this disclosure will be described in detail below with reference to specific embodiments.
[0033] refer to Figure 2 , Figure 2 This is a schematic flowchart illustrating a browser language configuration method provided in an embodiment of this disclosure. The method of this embodiment can be applied to electronic devices such as terminal devices or servers. The browser language configuration method includes:
[0034] S201, Receive the access operation instruction for the target page.
[0035] In this embodiment, when a user needs to browse a website, the browser triggers an access command to the target page of the website. It should be noted that the browser is not limited to a web browser, but may also include video browsers, image browsers, or other media content browsers.
[0036] S202. Detect language configuration information from different browser environment configuration information according to a preset priority order, and determine the target language based on the language configuration information.
[0037] In this embodiment, considering that language configuration information may exist in different browser environment configuration information, in order to perform unified processing and select the optimal and most suitable target language, language configuration information can be detected from different browser environment configuration information according to a preset priority order, and the target language can be determined based on the language configuration information.
[0038] In this embodiment, the optional browser environment configuration information may include one or more of the following: cookies (text files that store information required for visitors to access URLs), query fields in URLs (Uniform Resource Locators), web storage data (JavaScript storage objects), browser information (embedded objects such as Navigator objects that store browser information), HTML (Hypertext Markup Language) tags, and preset language configuration information.
[0039] Cookies are text files that store information needed for a visitor to access a website. They can store user language preference configuration information, for example, using a key / value pair. The key represents the user's language preference configuration, and its naming can highlight the user's personal preference and language. For example, "pref-lang" represents personal preference-language, which is the most detailed and intuitive description; "prefs" represents personal preference, which is highly scalable and can be extended if more resources need to be unified across sites in the future. In addition, naming conventions such as "i18n-prefs", "LANG", "locale", and "django language" can also be used. The value represents the specific language. The value can be a standard international language code, such as cn (Chinese), en (English), or zh-CN, en-US, etc. Optionally, a JSON string can also be used, where locale can represent the key value.
[0040] Cookies can be planted by various second-level domain businesses under the top-level domain: xxx.com (where xxx represents the prefix of the top-level domain) to achieve caching and resource sharing. When loading, each second-level domain business first checks the cookie status. If the cookie already exists, the specified language is used. The user's language preference configuration information in the cookie can be modified and cached. If the user actively changes the language in the business, in addition to the cookie of its own business domain, the cookie of the top-level domain can also be updated, so that the user's language preference configuration information can be shared in the cookies of various domains under the top-level domain. In addition, cookies can be sent by attaching them to HTTP (Hypertext Transfer Protocol) requests to achieve sharing.
[0041] The query field in the URL can also include the language code, for example, / ?lng=zh-CN (the part after the forward slash and question mark " / ?" in the URL is the query field), or the static path method for MPA (Multi-page Application) / zh / abc. The language code in the query field of the URL cannot be shared across sites, but it is objectively set. Optionally, a key / value format can also be used. When using a unified query, it is necessary to ensure that the query key does not conflict with the existing logic of the business logic.
[0042] Web Storage is a JavaScript storage object that can also include language configuration information, such as storing language configuration information in the local storage window.localStorage object, which can persistently cache language code.
[0043] The Navigator object is based on object-oriented principles and supports browser information for various browsers. It can also contain language properties. Most mainstream browsers currently support the Navigator object. The properties contained in the Navigator object describe the information of the browser being used. The current browser language can be obtained through the navigator.language property of the Navigator object, and the current browser language can be used as the page language.
[0044] The HTML tag also contains a language attribute. The language attribute lang field can be obtained from the project's HTML code. Using the language written in the HTML tag by the business side can be a way to determine the language and can serve as a fallback measure.
[0045] Preset language configuration information can also serve as a fallback measure. It is a default fallback language that is used when the language configuration information cannot be detected through the various browser environment configuration information provided earlier.
[0046] This embodiment supports multiple different ways of configuring detection language, unifying the internationalization method when the browser accesses different sites. When accessing target pages of different sites, the appropriate target language can be determined based on a certain browser environment configuration information, realizing seamless language switching, simplifying user operations, and improving user experience.
[0047] Since language configuration information can be detected from all the browser environment configuration information mentioned above, a priority is set in advance. Language configuration information is detected from different browser environment configuration information according to the preset priority order. The target language is determined based on the language configuration information. For example, the user's language preference configuration is used first, then the browser's current language is used, and finally the fallback language is used to ensure that the optimal and most suitable target language can be determined.
[0048] Optionally, after detecting language configuration information from browser environment configuration information of any priority and determining the target language based on the language configuration information, it checks whether the target page supports the target language; if the target page supports the target language, it stops detecting language configuration information from browser environment configuration information of the next priority; if the target page does not support the target language, it continues to detect language configuration information from browser environment configuration information of the next priority.
[0049] In this embodiment, the internationalization of the target page may not support all languages, for example, only a few languages. Therefore, after determining the target language, it is possible to check whether the browser's target page supports the target language. If the target language is supported, the following steps for rendering the target page will continue in the target language. If the target language is not supported, the language configuration information can be checked from the browser environment configuration information of the next priority to determine a target language. Then, the target page will be checked again to see if it supports the target language, until a target language supported by the target page is finally determined. This can effectively determine a suitable target language that the target page supports.
[0050] Optionally, detecting whether the target page supports the target language may also include:
[0051] If the target page does not support the target language, then an approximate language is determined based on the target language; if the target page supports the approximate language of the target language, then the approximate language of the target language is determined as the final target language.
[0052] In this embodiment, some languages may have similar languages, or the same language may have different representations. These different representations can also be regarded as similar languages. For example, zh-CN, zh-Hans, and zh all mean Simplified Chinese. This can be easily achieved by "de-regionalization", that is, removing the short line in the middle and treating zh-CN and zh-Hans as zh.
[0053] In other words, the approximate language of zh-CN and zh-Hans is zh. If the target language is determined to be zh-CN or zh-Hans, and the target page does not support zh-CN or zh-Hans (zh exists in the target page's supported language list, but zh-CN and zh-Hans do not exist), we can check whether the target page supports zh. If it does, then zh is determined as the final target language, thus broadening the range of target languages. Optionally, regular expressions or other methods can be used to determine the final language. For example, the regular expression / zh / .test(lang) can be used to check whether the final detected language contains zh. If it does, then Chinese is used.
[0054] S203. Render the target page according to the target language so that the target page is displayed in the target language.
[0055] In this embodiment, after determining the target language, the terminal device can load data corresponding to the target language from the server, or the server can send data corresponding to the target language to the terminal device, and then the terminal device can render the target page so that the target page is displayed in the target language. The specific rendering process is not limited here, as long as it enables the target page to be displayed in the target language.
[0056] Optionally, you can use documentation tools to build the site (such as VuePress, Gatsby, etc.), using different paths to point to different HTML pages. In the case of paths like / zh-CN / homePage and en_US / homePage, after determining the target language, you can modify the href (Hypertext Reference) or use a 302 redirect to jump to the path matching the language. The core of using paths is to use a directory tree approach to distinguish articles in different languages. There are two common methods: categorized by language and categorized by module. Categorized by language means different modules for each language are in the same folder; categorized by module means all corresponding languages for each module are in the same folder.
[0057] This embodiment of the browser language configuration method involves receiving an access command for a target page; detecting language configuration information from different browser environment configuration information according to a preset priority order; determining the target language based on the language configuration information; and rendering the target page according to the target language so that the target page is displayed in the target language. This embodiment supports multiple different methods for detecting language configuration information, unifying the internationalization method when the browser accesses different sites. It can detect language configuration information from different browser environment configuration information in a preset priority order, more reasonably determining the target language of the target page. Users do not need to manually switch languages, simplifying user operations and enabling quick and seamless language switching when accessing different target pages, thus improving the user experience.
[0058] Based on any of the above embodiments, when detecting language configuration information from a text file storing information required for a visitor's access URL, and determining the target language based on the language configuration information, the following may be included:
[0059] Check if user language preference configuration information exists in the text file that stores the information required for the visitor's access URL; if it exists, determine the target language based on the user language preference configuration information.
[0060] In this embodiment, the text file cookie storing the information required for a visitor to access a website can store user language preference configuration information. For example, it can use key / value pairs, where the key represents the user's language preference configuration. Its naming can highlight the user's personal preference and language characteristics; for example, "pref-lang" represents personal preference-language, providing the most detailed and intuitive description. Another example is "prefs," which represents personal preference and has high scalability, allowing for expansion if more resources need to be unified across sites later. Other naming conventions include "i18n-prefs," "LANG," "locale," and "django language." The value represents the specific language, which can be a standard international language code, such as cn (Chinese), en (English), or zh-CN, en-US, etc. The key / value pairs are detected from the cookie. If a key / value pair is detected, the value is identified and determined to be the target language.
[0061] Based on any of the above embodiments, when detecting language configuration information from the query field in the URL and determining the target language based on the language configuration information, the following may be included:
[0062] Obtain the Query field from the URL, parse the Query field, and check if there is a language code in the Query field; if so, determine the target language based on the language code.
[0063] In this embodiment, the window.location.search method in JavaScript is used to extract the string after "?" in the current URL, which is the Query field included in the URL. Regular expressions are used to parse whether there is a language code in the Query string. If there is, the language code is extracted from the Query using regular expressions, and the target language is determined based on the language code.
[0064] Based on any of the above embodiments, when detecting language configuration information from network stored data and determining the target language based on the language configuration information, the process may include:
[0065] Retrieve local storage objects from network storage data;
[0066] Detect whether language configuration information exists in the local storage object; if it exists, determine the target language based on the language configuration information.
[0067] In this embodiment, the local storage window.localStorage object can be obtained first, and the presence of language configuration information in the window.localStorage object can be detected. If language configuration information is detected, the target language can be determined based on the language configuration information.
[0068] Based on any of the above embodiments, when detecting language configuration information from browser information and determining the target language based on the language configuration information, the process may include:
[0069] Determine if the browser supports embedded objects that store browser information; if the browser supports embedded objects that store browser information, determine if the embedded object has a language attribute, which is the browser's current language; if it does, determine the target language based on the language attribute.
[0070] In this embodiment, since not all browsers support the embedded Navigator object that stores browser information, it is necessary to first determine whether the browser supports the Navigator object. This can be done by checking whether the window.navigator variable is not null or undefined. If it is not null or undefined, it indicates whether the browser supports the Navigator object. Furthermore, it is checked whether window.navigator has a language property, i.e., whether window.navigator.language is not null or undefined. If it is not null or undefined, the language code is retrieved from window.navigator.language. This language is the browser's current language, and this language is determined as the target language.
[0071] Based on any of the above embodiments, when detecting language configuration information from HTML tags and determining the target language based on the language configuration information, the process may include:
[0072] Determine if an HTML tag has a language attribute; if it does, determine the target language based on the language attribute.
[0073] In this embodiment, the JavaScript code document.documentElement.getAttribute('lang') can be used to determine whether the HTML tag has a language attribute (lang attribute). If it exists, the target language is determined based on the language attribute.
[0074] Based on any of the above embodiments, the preset priority order from high to low is as follows: Cookie, Query field in URL, JavaScript storage object, Navigator object, HTML tag, and preset language configuration information.
[0075] In this embodiment, cookies can be shared and sent by embedding them in HTTP requests. Storing only string language codes is more advantageous than storing them in a JavaScript storage object (window.localStorage object). Furthermore, when a user changes their language, the language code will be subjectively set in the cookie. Queries, on the other hand, cannot be shared across sites, but they are objectively set. If the Query is placed first, its automatic adjustment feature will be lost. The Navigator object, as the first fallback, directly obtains the user's browser language, and its weight should be lower than the user's subjective preference. As the second fallback, the final display language is determined by HTML tags only when the Navigator object is unavailable, and its weight should be lower than the Navigator object. Finally, preset language configuration information can be used as a final fallback to avoid data dumping.
[0076] That is, such as Figure 3 As shown, the system first checks whether user language preference configuration information exists in the cookie; if it does, the target language is determined based on the user language preference configuration information.
[0077] If the user's language preference configuration information is not found in the cookie, then the Query field in the URL is checked for the presence of a language code; if it exists, the target language is determined based on the language code.
[0078] If the Query field in the URL does not contain a language code, then the window.localStorage object is checked for language configuration information; if it exists, the target language is determined based on the language configuration information.
[0079] If the window.localStorage object does not contain language configuration information, then check if the Navigator object has a language property; if it does, determine the target language based on the language property.
[0080] If the Navigator object does not have a language attribute, check if the HTML tag has a language attribute; if it does, determine the target language based on the language attribute.
[0081] If it is determined that the HTML tag does not have a language attribute, the target language is determined using the preset language configuration information.
[0082] In the above process, after determining the target language, it can be checked whether the target page supports the target language. If the target page supports the target language, the process ends; if the target page does not support the target language, the language configuration information is checked from the browser environment configuration information of the next priority.
[0083] For example, if a user is using the site for the first time and has no cookies or queries, the site language will be determined based on Navigator.language (the browser's current language).
[0084] If a user is not satisfied with the current language, they will actively change it to their preferred language. When the user opens another website, a cookie will already be available, and the site will be rendered in the user's preferred language.
[0085] If the user is satisfied with the current language, assuming the current language is derived from Navigator.language, then without cookies or queries, the user will always get the language of their own browser, that is, the language that the user is satisfied with.
[0086] For example, if user A sends a URL with a query to user B, and user B has never visited the site (no cookie), then the language of the site opened by user B will be determined by the query.
[0087] If user B is satisfied with the language in the query, they will not actively modify it; conversely, if user B is not satisfied, it will prompt them to actively modify it, that is, the user prefers a certain language. When user B opens another website, there is already a cookie, and the website will be rendered in the user's preferred language.
[0088] Based on any of the above embodiments, such as Figure 4 As shown, after the target page is displayed using the target language, it also includes:
[0089] S401. Receive a user's language switching instruction, wherein the language switching instruction includes the switched second language;
[0090] S402. Re-render the target page according to the second language so that the target page is displayed using the second language;
[0091] S403. Update the second language to the user language preference configuration information in the cookie of the current domain and / or top-level domain.
[0092] In this embodiment, after the target page is displayed in the target language, if the user needs to switch languages, the user can reselect a second language, and the target page will be displayed in the second language. At the same time, since the second language is actively selected by the user and is a user language preference, the second language can be updated in the user language preference configuration information in the cookie of the current domain and / or the top-level domain to achieve caching and sharing. This makes it convenient to use the user language preference configuration information in the cookie to determine the target language when visiting any page under the current domain or the top-level domain again.
[0093] Corresponding to the browser language configuration method in the above embodiments, Figure 5 This is a structural block diagram of a browser language configuration device provided for embodiments of this disclosure. For ease of explanation, only the parts relevant to embodiments of this disclosure are shown. (Refer to...) Figure 5 The browser language configuration device 500 includes: an input unit 501, a language determination unit 502, and a display unit 503.
[0094] The input unit 501 is used to receive access operation instructions for the target page.
[0095] The language determination unit 502 is used to detect language configuration information from different browser environment configuration information according to a preset priority order, and determine the target language based on the language configuration information.
[0096] Display unit 503 is used to render the target page according to the target language so that the target page is displayed in the target language.
[0097] In one or more embodiments of this disclosure, the different browser environment configuration information includes one or more of the following:
[0098] The text file that stores the information required for visitors to access the website, the query fields in the Uniform Resource Locator, network storage data, browser information, Hypertext Markup Language tags, and preset language configuration information.
[0099] In one or more embodiments of this disclosure, when the language determination unit 502 detects language configuration information from different browser environment configuration information according to a preset priority order and determines the target language based on the language configuration information, it is configured to:
[0100] After detecting language configuration information from browser environment configuration information of any priority and determining the target language based on the language configuration information, it is then detected whether the target page supports the target language.
[0101] If the target page supports the target language, then stop detecting language configuration information from the browser environment configuration information of the next priority.
[0102] If the target page does not support the target language, then the language configuration information is checked from the browser environment configuration information of the next priority.
[0103] In one or more embodiments of this disclosure, when the language determination unit 502 detects language configuration information from a text file storing information required for a visitor to access a URL, and determines the target language based on the language configuration information, it is configured to:
[0104] Check if user language preference configuration information exists in the text file that stores the information required for the URL visited by the visitor.
[0105] If it exists, the target language is determined based on the user's language preference configuration information.
[0106] In one or more embodiments of this disclosure, when the language determination unit 502 detects language configuration information from a query field in a Uniform Resource Locator and determines a target language based on the language configuration information, it is configured to:
[0107] Retrieve the query fields from the Uniform Resource Locator, parse the query fields, and check if language codes exist in the query fields;
[0108] If it exists, determine the target language based on the language code.
[0109] In one or more embodiments of this disclosure, when the language determination unit 502 detects language configuration information from network stored data and determines the target language based on the language configuration information, it is configured to:
[0110] Retrieve local storage objects from network storage data;
[0111] Check if language configuration information exists in the local storage object;
[0112] If it exists, the target language is determined based on the language configuration information.
[0113] In one or more embodiments of this disclosure, when the language determination unit 502 detects language configuration information from a browser information object and determines the target language based on the language configuration information, it is configured to:
[0114] Determine if the browser supports embedded objects that store browser information;
[0115] If it is determined that the browser supports embedded objects that store browser information, then it is determined whether the embedded object storing browser information has a language attribute, which is the current language of the browser.
[0116] If it exists, the target language is determined based on the language attributes.
[0117] In one or more embodiments of this disclosure, when the language determination unit 502 detects language configuration information from hypertext markup language tags and determines the target language based on the language configuration information, it includes:
[0118] Determine if a hypertext markup language tag has a language attribute;
[0119] If it exists, the target language is determined based on the language attributes.
[0120] In one or more embodiments of this disclosure, the language determination unit 502, when detecting whether the target page supports the target language, is further configured to:
[0121] If the target page is found to not support the target language, then an approximate language is determined based on the target language.
[0122] Detect whether the target page supports a language similar to the target language. If it does, determine the language similar to the target language as the final target language.
[0123] In one or more embodiments of this disclosure, the preset priority order from high to low is as follows: a text file storing information required by the visitor to access the URL, a query field in a Uniform Resource Locator, network storage data, browser information, Hypertext Markup Language tags, and preset language configuration information.
[0124] In one or more embodiments of this disclosure, after the language determination unit 502 displays the target page using the target language, it further includes:
[0125] The input unit 501 is also configured to receive a user's language switching instruction, the language switching instruction including the switched second language;
[0126] The display unit 503 is further configured to re-render the target page according to the second language, so that the target page is displayed in the second language;
[0127] The language determination unit 502 is also used to update the second language to the user language preference configuration information in the text file that stores the information required for the visitor's access URL corresponding to the current domain name and / or top-level domain name.
[0128] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0129] refer to Figure 6The diagram illustrates a structural schematic of an electronic device 600 suitable for implementing embodiments of the present disclosure. The electronic device 600 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, personal digital assistants (PDAs), portable Android devices (PADs), portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0130] like Figure 6 As shown, electronic device 600 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. The processing unit 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0131] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0132] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of embodiments of this disclosure.
[0133] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0134] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0135] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.
[0136] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0137] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0138] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0139] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0140] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0141] In a first aspect, according to one or more embodiments of this disclosure, a browser language configuration method is provided, comprising:
[0142] Receive instructions to access the target page;
[0143] Language configuration information is detected from different browser environment configuration information according to a preset priority order, and the target language is determined based on the language configuration information;
[0144] The target page is rendered according to the target language so that the target page is displayed in the target language.
[0145] According to one or more embodiments of this disclosure, the different browser environment configuration information includes one or more of the following:
[0146] The text file that stores the information required for visitors to access the website, the query fields in the Uniform Resource Locator, network storage data, browser information, Hypertext Markup Language tags, and preset language configuration information.
[0147] According to one or more embodiments of this disclosure, the step of detecting language configuration information from different browser environment configuration information according to a preset priority order, and determining the target language based on the language configuration information, includes:
[0148] After detecting language configuration information from browser environment configuration information of any priority and determining the target language based on the language configuration information, it is then detected whether the target page supports the target language.
[0149] If the target page supports the target language, then stop detecting language configuration information from the browser environment configuration information of the next priority.
[0150] If the target page does not support the target language, then the language configuration information is checked from the browser environment configuration information of the next priority.
[0151] According to one or more embodiments of this disclosure, detecting language configuration information from a text file storing information required for a visitor to access a URL, and determining a target language based on the language configuration information, includes:
[0152] The system checks whether user language preference configuration information exists in the text file containing the information required for the visitor's access URL.
[0153] If it exists, the target language is determined based on the user's language preference configuration information.
[0154] According to one or more embodiments of this disclosure, detecting language configuration information from a query field in a Uniform Resource Locator (URL), and determining a target language based on the language configuration information, includes:
[0155] Retrieve the query fields from the Uniform Resource Locator, parse the query fields, and check if language codes exist in the query fields;
[0156] If it exists, determine the target language based on the language code.
[0157] According to one or more embodiments of this disclosure, detecting language configuration information from network stored data and determining a target language based on the language configuration information includes:
[0158] Retrieve local storage objects from network storage data;
[0159] Check if language configuration information exists in the local storage object;
[0160] If it exists, the target language is determined based on the language configuration information.
[0161] According to one or more embodiments of this disclosure, detecting language configuration information from browser information and determining a target language based on the language configuration information includes:
[0162] Determine if the browser supports embedded objects that store browser information;
[0163] If it is determined that the browser supports the embedded object that stores browser information, then it is determined whether the embedded object that stores browser information has a language attribute, which is the current language of the browser;
[0164] If it exists, the target language is determined based on the language attributes.
[0165] According to one or more embodiments of this disclosure, detecting language configuration information from Hypertext Markup Language tags and determining a target language based on the language configuration information includes:
[0166] Determine if a hypertext markup language tag has a language attribute;
[0167] If it exists, the target language is determined based on the language attributes.
[0168] According to one or more embodiments of this disclosure, when detecting whether the target page supports the target language, the method further includes:
[0169] If the target page is found to not support the target language, then an approximate language is determined based on the target language.
[0170] Detect whether the target page supports a language similar to the target language. If it does, determine the language similar to the target language as the final target language.
[0171] According to one or more embodiments of this disclosure, the preset priority order from high to low is as follows: a text file storing information required by the visitor to access the URL, a query field in a Uniform Resource Locator, network storage data, browser information, Hypertext Markup Language tags, and preset language configuration information.
[0172] According to one or more embodiments of this disclosure, after the target page is displayed in the target language, the method further includes:
[0173] Receives a user's language switching instruction, the language switching instruction including the switched second language;
[0174] The target page is re-rendered according to the second language so that the target page is displayed in the second language;
[0175] Update the second language to the user language preference configuration information in the text file that stores the information required for the visitor's access URL corresponding to the current domain name and / or top-level domain.
[0176] Secondly, according to one or more embodiments of this disclosure, a browser language configuration device is provided, comprising:
[0177] The input unit is used to receive access operation instructions for the target page;
[0178] The language determination unit is used to detect language configuration information from different browser environment configuration information according to a preset priority order, and determine the target language based on the language configuration information.
[0179] The display unit is used to render the target page according to the target language so that the target page is displayed in the target language.
[0180] According to one or more embodiments of this disclosure, the different browser environment configuration information includes one or more of the following:
[0181] The text file that stores the information required for visitors to access the website, the query fields in the Uniform Resource Locator, network storage data, browser information, Hypertext Markup Language tags, and preset language configuration information.
[0182] According to one or more embodiments of this disclosure, when the language determination unit detects language configuration information from different browser environment configuration information according to a preset priority order, and determines the target language based on the language configuration information, it is configured to:
[0183] After detecting language configuration information from browser environment configuration information of any priority and determining the target language based on the language configuration information, it is then detected whether the target page supports the target language.
[0184] If the target page supports the target language, then stop detecting language configuration information from the browser environment configuration information of the next priority.
[0185] If the target page does not support the target language, then the language configuration information is checked from the browser environment configuration information of the next priority.
[0186] According to one or more embodiments of this disclosure, when the language determination unit detects language configuration information from a text file storing information required for a visitor to access a URL, and determines the target language based on the language configuration information, it is configured to:
[0187] The system checks whether user language preference configuration information exists in the text file containing the information required for the visitor's access URL.
[0188] If it exists, the target language is determined based on the user's language preference configuration information.
[0189] According to one or more embodiments of this disclosure, when the language determination unit detects language configuration information from a query field in a Uniform Resource Locator and determines a target language based on the language configuration information, it is configured to:
[0190] Retrieve the query fields from the Uniform Resource Locator, parse the query fields, and check if language codes exist in the query fields;
[0191] If it exists, determine the target language based on the language code.
[0192] According to one or more embodiments of this disclosure, when the language determination unit detects language configuration information from network stored data and determines the target language based on the language configuration information, it is configured to:
[0193] Retrieve local storage objects from network storage data;
[0194] Check if language configuration information exists in the local storage object;
[0195] If it exists, the target language is determined based on the language configuration information.
[0196] According to one or more embodiments of this disclosure, when the language determination unit detects language configuration information from browser information and determines the target language based on the language configuration information, it is configured to:
[0197] Determine if the browser supports embedded objects that store browser information;
[0198] If it is determined that the browser supports the embedded object that stores browser information, then it is determined whether the embedded object that stores browser information has a language attribute, which is the current language of the browser;
[0199] If it exists, the target language is determined based on the language attributes.
[0200] According to one or more embodiments of this disclosure, when the language determination unit detects language configuration information from Hypertext Markup Language tags and determines a target language based on the language configuration information, it includes:
[0201] Determine if a hypertext markup language tag has a language attribute;
[0202] If it exists, the target language is determined based on the language attributes.
[0203] According to one or more embodiments of this disclosure, when detecting whether the target page supports the target language, the language determination unit is further configured to:
[0204] If the target page is found to not support the target language, then an approximate language is determined based on the target language.
[0205] Detect whether the target page supports a language similar to the target language. If it does, determine the language similar to the target language as the final target language.
[0206] According to one or more embodiments of this disclosure, the preset priority order from high to low is as follows: a text file storing information required by the visitor to access the URL, a query field in a Uniform Resource Locator, network storage data, browser information, Hypertext Markup Language tags, and preset language configuration information.
[0207] According to one or more embodiments of this disclosure, after the language determination unit displays the target page in the target language, it further includes:
[0208] The input unit is also used to receive a user's language switching instruction, the language switching instruction including the switched second language;
[0209] The display unit is further configured to re-render the target page according to the second language, so that the target page is displayed using the second language;
[0210] The language determination unit is also used to update the second language to the user language preference configuration information in the text file that stores the information required for the visitor's access URL corresponding to the current domain name and / or top-level domain name.
[0211] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory;
[0212] The memory stores computer-executed instructions;
[0213] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the browser language configuration method as described in the first aspect and various possible designs of the first aspect.
[0214] Fourthly, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, and when a processor executes the computer-executable instructions, the browser language configuration method described in the first aspect and various possible designs of the first aspect is implemented.
[0215] Fifthly, according to one or more embodiments of this disclosure, a computer program product is provided, including computer execution instructions that, when executed by a processor, implement the browser language configuration method described in the first aspect and various possible designs of the first aspect.
[0216] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0217] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0218] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A browser language configuration method, characterized in that, The method comprises the following steps: receiving an access operation instruction of a target page; detecting language configuration information from different browser environment configuration information according to a preset priority order, and determining a target language according to the language configuration information; after detecting the language configuration information from the browser environment configuration information of any priority and determining the target language according to the language configuration information, detecting whether the target page supports the target language; if the target page supports the target language, stopping detecting language configuration information from the browser environment configuration information of the next priority; if the target page does not support the target language, continuing to detect language configuration information from the browser environment configuration information of the next priority; or, if it is detected that the target page does not support the target language, determining an approximate language of the target language according to the target language; detecting whether the target page supports the approximate language of the target language, and if so, determining the approximate language of the target language as a final target language; performing page rendering on the target page according to the target language, so that the target page is displayed in the target language.
2. The method of claim 1, wherein, The different browser environment configuration information comprises one or more of the following: a text file storing information required by a visitor to access a website, a query field in a uniform resource locator, network storage data, browser information, a hypertext markup language tag, and preset language configuration information.
3. The method of claim 2, wherein, The method for detecting language configuration information from the text file storing information required by the visitor to access the website and determining a target language according to the language configuration information comprises the following steps: detecting whether user language preference configuration information exists in the text file storing information required by the visitor to access the website; if so, determining the target language according to the user language preference configuration information.
4. The method of claim 2, wherein, The method for detecting language configuration information from the query field in the uniform resource locator and determining a target language according to the language configuration information comprises the following steps: obtaining the query field from the uniform resource locator and parsing the query field, and detecting whether a language code exists in the query field; if so, determining the target language according to the language code.
5. The method of claim 2, wherein, The method for detecting language configuration information from network storage data and determining a target language according to the language configuration information comprises the following steps: obtaining a local storage object in the network storage data; detecting whether language configuration information exists in the local storage object; if so, determining the target language according to the language configuration information.
6. The method of claim 2, wherein, The method for detecting language configuration information from browser information and determining a target language according to the language configuration information comprises the following steps: judging whether the browser supports an embedded object for storing browser information; if it is determined that the browser supports the embedded object for storing browser information, judging whether the embedded object for storing browser information has a language attribute, which is the current language of the browser; if so, determining the target language according to the language attribute.
7. The method of claim 2, wherein, The method for detecting language configuration information from a hypertext markup language tag and determining a target language according to the language configuration information comprises the following steps: judging whether the hypertext markup language tag has a language attribute; if so, determining the target language according to the language attribute.
8. The method according to any one of claims 2 to 7, characterized in that, The preset priority order from high to low is: a text file storing information required by a visitor to access a website, a query field in a uniform resource locator, network storage data, browser information, a hypertext markup language tag, and preset language configuration information.
9. The method according to any one of claims 2-7, characterized in that, After the target page is displayed in the target language, the method further includes: receiving a language switching instruction of the user, the language switching instruction including a second language after switching; re-performing page rendering on the target page according to the second language, so that the target page is displayed in the second language; updating the second language to user language preference configuration information in a text file storing information required by a visitor to access a website corresponding to a current domain name and / or a top-level domain name.
10. A browser language configuration device characterized by comprising: The method includes: an input unit configured to receive an access operation instruction of a target page; a language determination unit configured to detect language configuration information from different browser environment configuration information according to a preset priority order, and determine a target language according to the language configuration information; after detecting the language configuration information from the browser environment configuration information of any priority and determining the target language according to the language configuration information, detecting whether the target page supports the target language; if the target page supports the target language, stopping detecting language configuration information from the browser environment configuration information of a next priority; if the target page does not support the target language, continuing to detect language configuration information from the browser environment configuration information of the next priority; or, if it is detected that the target page does not support the target language, determining an approximate language of the target language according to the target language; detecting whether the target page supports the approximate language of the target language, and if so, determining the approximate language of the target language as a final target language; a display unit configured to perform page rendering on the target page according to the target language, so that the target page is displayed in the target language.
11. An electronic device, comprising: The method includes: at least one processor and a memory; the memory stores computer-executable instructions; the at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method of any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method of any one of claims 1-9 is implemented.
13. A computer program product, characterised in that, The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method of any one of claims 1-9 is implemented.
Citation Information
Patent Citations
Front-end multi-language loading adaptation method and device, computer equipment and storage medium
CN111381913A