Internationalization processing method, device, apparatus and storage medium
By generating prompts during internationalization to detect missing or incorrect mapping relationships, the problem of translation errors going undetected during internationalization is solved, improving development efficiency and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI IMILAB TECHNOLOGY CO LTD
- Filing Date
- 2022-12-01
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, internationalization errors cannot be detected at the code level, leading to translation errors and a degraded user experience. Furthermore, interface checks are easily overlooked during testing, reducing development efficiency.
By obtaining the mapping relationship between internationalization class attributes and translation fields in the target configuration file, a prompt message is generated to indicate that internationalization processing has failed, ensuring that missing or incorrect mapping relationships are detected during compilation.
It effectively solves the problem of translation errors that are imperceptible during code development in internationalization, improves development quality and accuracy, and enhances testing efficiency and user experience.
Smart Images

Figure CN116185535B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and specifically to an internationalization processing method and apparatus. Background Technology
[0002] Internationalization, also known as localization, refers to the process of automatically selecting the text content to be displayed internationally based on the user's current phone language when using an application (App). For example, if the user sets different phone system languages, the App will also adapt to different languages, allowing the user to use the various functions provided by the App without language barriers.
[0003] However, translation errors in existing internationalization processes are not perceptible at the code level. In other words, even if internationalization errors occur, the code can still function normally, thus reducing the user experience. Summary of the Invention
[0004] This disclosure provides an internationalization processing method, apparatus, device, and storage medium to solve or alleviate one or more technical problems in the prior art.
[0005] Firstly, this disclosure provides an internationalization processing method, including:
[0006] Obtain the target configuration file; the target configuration file includes the target mapping relationship between internationalization class attributes and translation fields; the internationalization class attributes contain multiple attribute values, the translation fields contain multiple translation values, and the attribute values correspond to the translation values;
[0007] If it is determined that there is no target attribute value corresponding to the object to be processed in the internationalization class attribute of the target mapping relationship, a prompt message is generated; wherein, the object to be processed includes at least the relevant characters to be translated in the target application; the prompt message is used to indicate that there is no target translation value corresponding to the object to be processed.
[0008] Secondly, this disclosure provides an internationalization processing apparatus, comprising:
[0009] An acquisition unit is used to acquire a target configuration file; the target configuration file includes a target mapping relationship between internationalization class attributes and translation fields; the internationalization class attributes contain multiple attribute values, the translation fields contain multiple translation values, and the attribute values correspond to the translation values;
[0010] A processing unit is configured to generate a prompt message if, in the case that there is no target attribute value corresponding to the object to be processed in the internationalization class attribute of the target mapping relationship, the object to be processed includes at least the relevant characters to be translated in the target application; the prompt message is used to indicate that there is no target translation value corresponding to the object to be processed.
[0011] Thirdly, an electronic device is provided, comprising:
[0012] At least one processor; and
[0013] The memory is communicatively connected to the at least one processor; wherein,
[0014] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods of any embodiment of the present disclosure.
[0015] Fourthly, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform a method according to any embodiment of the present disclosure.
[0016] Fifthly, a computer program product is provided, including a computer program that, when executed by a processor, implements the method according to any embodiment of the present disclosure.
[0017] Thus, this disclosed solution provides an internationalization processing method that can effectively detect internationalization processing failures and generate prompt messages when failures are detected. This effectively solves the problem of compilation continuing normally even when internationalization processing errors occur, laying the foundation for effectively improving the user experience.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0019] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments provided according to this disclosure and should not be construed as limiting the scope of this disclosure.
[0020] Figure 1 This is a flowchart illustrating the internationalization development process according to an embodiment of this application;
[0021] Figure 2This is a schematic flowchart of the internationalization processing method according to an embodiment of this application;
[0022] Figure 3 This is a schematic flowchart illustrating the process of obtaining the target configuration file in the internationalization processing method according to an embodiment of this application;
[0023] Figure 4 This is a schematic flowchart illustrating an internationalization processing method according to an embodiment of this application in a specific instance;
[0024] Figure 5 This is a schematic diagram of the structure of an internationalization processing apparatus according to an embodiment of this application;
[0025] Figure 6 This is a block diagram of an electronic device used to implement the internationalization processing method of the embodiments of this disclosure. Detailed Implementation
[0026] The present disclosure will now be described in further detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.
[0027] Furthermore, to better illustrate this disclosure, numerous specific details are set forth in the following detailed description. Those skilled in the art will understand that this disclosure can be practiced without certain specific details. In some instances, methods, means, components, and circuits well known to those skilled in the art have not been described in detail in order to highlight the main points of this disclosure.
[0028] With the development of the Internet, it has become increasingly common for applications (APPs) to go global. One of the most important functions of internationalization is the internationalization of apps.
[0029] Internationalization, also known as localization, refers to the conversion of relevant strings in a target application from its first language to a second language to adapt the application's functionality and code design to the needs of different countries (or regions) for operation. This process facilitates development and use and can be called internationalization processing. Furthermore, the conversion of relevant strings from the first language to the second language within internationalization processing can be called translation processing within internationalization processing; this disclosed solution refers to it as translation processing. Specifically, when using the app, the system automatically selects the text content requiring translation processing based on the user's current phone language and displays the translated text content according to the user's system language settings. This facilitates viewing for users of different languages, allowing them to use the various functions provided by the app without language barriers.
[0030] To complete internationalization processing, corresponding development work needs to be carried out first. Figure 1 is a schematic diagram of the development process for internationalization processing; as can be seen from Figure 1 it, the code development in internationalization processing and the mapping relationship processing flow required in translation processing are two relatively independent routes and do not directly affect each other. Therefore, the following problems will occur: relevant logic for internationalization processing has been written in code development. At this time, if the key required to run this relevant logic in the mapping relationship is missing or written incorrectly, it will lead to the failure of internationalization processing. However, this type of problem with the failure of internationalization processing cannot be perceived at the code level, and the translation processing flow still runs normally, resulting in translation errors and reducing the user experience; for example, in internationalization processing, "Hello" in English is translated from "你好" in Chinese. At this time, if the key corresponding to "你好" is missing in the mapping relationship, it will cause translation errors; since it cannot be perceived at the code level, the translation processing flow will run normally, so the situation of "你好" will appear in English. Obviously, the user experience is reduced.
[0031] Furthermore, some specific UI (User Interface) pages need to meet certain trigger conditions to appear in the App. For example, when the user clicks an operation and jumps from the first interface to the second interface. At this time, in the process of internationalization processing, if the developer does not perform a click operation on the first interface, they cannot see whether the internationalization processing of the second interface is correct; in actual applications, developers may miss it during the testing process, resulting in the inability to complete the inspection of all interfaces 100%, reducing the testing efficiency and at the same time reducing the user experience.
[0032] Based on this, the present disclosure provides an internationalization processing method to give an error prompt for the failure problem of internationalization processing in an application program.
[0033] Specifically, Figure 2 is a schematic flowchart of the internationalization processing method according to an embodiment of the present application. This method can optionally be applied to an electronic device, such as a personal computer, or a server, or a server cluster, etc. The present disclosure does not make specific limitations on this. This method includes at least part of the following content. As Figure 2 shown, it includes: [[ID=ID=18]]
[0034] Step S201: Obtain a target configuration file; the target configuration file includes a target mapping relationship between internationalization class attributes and translation fields; the internationalization class attributes contain multiple attribute values, the translation fields contain multiple translation values, and the attribute values correspond to the translation values.
[0035] In one example, attribute values correspond one-to-one with translation values, or multiple attribute values correspond to one translation value, etc. This disclosed solution does not impose any restrictions on this.
[0036] In one example, the attribute value corresponds to the first language; the translation value corresponds to the second language. For instance, in a scenario where the target application switches from English to Chinese, the attribute value could be specifically "age", and the corresponding translation value could be specifically "age".
[0037] Furthermore, in the target mapping relationship, the attribute value in the internationalization class attribute can be a string that is the same as or similar in meaning to the corresponding translation value. For example, if a translation value in the translation field is "age", then the attribute value corresponding to this translation value can be specifically "age" or "loc_age", thus laying the foundation for improving processing efficiency.
[0038] Step S202: If it is determined that there is no target attribute value corresponding to the object to be processed in the internationalization class attribute of the target mapping relationship, a prompt message is generated. The prompt message is used to indicate that there is no target translation value corresponding to the object to be processed.
[0039] In other words, if the target attribute value corresponding to the object to be processed cannot be found in the internationalization class attributes, and therefore the target translation value corresponding to the object to be processed cannot be found in the target mapping relationship, a prompt message will be generated to remind the developer that the internationalization processing of the object to be processed has failed.
[0040] In one example, the object to be processed includes at least the relevant characters in the target application that need to be translated, such as the relevant characters in the target application's display interface (e.g., UI). Further, the object to be processed can be a string to be translated, for example, "age". In this case, based on the object "age", the target attribute value corresponding to "age" is searched in the internationalization class attribute of the target mapping relationship, and then the translation value corresponding to the target attribute value is obtained to achieve the translation processing of "age".
[0041] It is understood that the display interface of the target application is the main interface of the target application, or any interface that the user jumps to from the main interface. This disclosure does not limit this; any interface that the user can browse can be used as the display interface of the solution described in this disclosure.
[0042] Furthermore, in one example, the object to be processed can be a preprocessed string with the same format as the attribute value in the internationalization class attribute; for example, if the string to be translated is "age" and the attribute value corresponding to "age" is "loc_age", then the object to be processed can be specifically "loc_age". In this way, during the search process of the internationalization class attribute, searching based on the object to be processed "loc_age" can effectively improve processing efficiency.
[0043] In one example, the prompt message described in this disclosure is generated during the compilation phase of internationalization processing or translation processing of internationalization, thus enabling the code level to effectively detect processing errors.
[0044] In this way, the proposed solution establishes an effective reminder mechanism. Specifically, it generates a prompt message when the internationalization class attribute of the target mapping relationship does not have a target attribute value corresponding to the object to be processed. This prompt message effectively solves the problem that the code development for internationalization processing cannot detect translation errors. This greatly improves the development quality and accuracy of internationalization processing, and at the same time lays the foundation for effectively improving the user experience.
[0045] Furthermore, since this disclosed solution can generate prompts in a timely manner when translation cannot be carried out effectively, all interfaces can be effectively tested without the need for developers to manually click during the testing process. Therefore, this disclosed solution can also effectively improve testing efficiency, thereby improving the development efficiency of internationalization processing.
[0046] Furthermore, this disclosed solution is applicable to any terminal operating system to which the target application is adapted, such as Android, iOS, and Windows systems on PCs to which the target application is adapted; therefore, this disclosed solution has greater scalability.
[0047] In a specific example of the disclosed solution, the target mapping relationship includes a first relationship and a second relationship; the first relationship represents the mapping relationship between internationalization class attributes and internationalization fields; the second relationship represents the mapping relationship between internationalization fields and translation fields; the internationalization class attributes contain multiple attribute values; the translation fields contain multiple translation values; the internationalization fields contain multiple field values; the attribute values correspond to the field values; and the field values correspond to the translation values.
[0048] In one example, attribute values correspond one-to-one with field values; in another example, field values correspond one-to-one with translation values, or multiple field values correspond to one translation value, etc. This disclosed solution does not impose any restrictions on this.
[0049] In one example, in the first relation, the attribute value in the internationalization class attribute corresponds to the first language; the field value in the internationalization field corresponds to the first language; for example, if English is the first language, the attribute value can be specifically "loc_age", and the field value corresponding to this attribute value can be specifically "age".
[0050] In another example, in the second relationship, the field value in the internationalization field corresponds to the first language; the translation value in the translation field corresponds to the second language; for example, with English as the first language and Chinese as the second language, the field value can be specifically "age", and in this case, the translation value corresponding to the field value is "age".
[0051] Furthermore, the field value can be a string that is the same as or similar in meaning to the translation value corresponding to the field value. For example, in a scenario where English is switched to Chinese in the target application, if a translation value in the translation field is "age", then the field value corresponding to the translation value can be a string related to the translation value, such as "age".
[0052] Specifically, step S202 in the internationalization processing method may include the following scenarios:
[0053] Scenario 1:
[0054] If it is determined that there is no target attribute value corresponding to the object to be processed in the first relationship, a prompt message is generated;
[0055] Here, the prompt information is used to indicate that there is no target translation value corresponding to the object to be processed in the second relationship.
[0056] In other words, if the target attribute value corresponding to the object to be processed does not exist in the first relation, it is impossible to continue searching in the second relation, which ultimately leads to the inability to find the target translation value. Therefore, a prompt message will be generated indicating that the internationalization process has failed.
[0057] Furthermore, in the first relationship included in the target mapping relationship, that is, in the mapping relationship between internationalization class attributes and internationalization fields, there is no target attribute value corresponding to the object to be processed. Therefore, it is impossible to search in the second relationship (that is, the mapping relationship between internationalization fields and translation fields), and thus internationalization processing cannot be effectively completed. At this time, a prompt message will be generated to inform the developer that the internationalization processing of the current object to be processed has failed.
[0058] For example, in a scenario where the target application switches from English to Chinese, "Hello" is the object to be processed. At this time, the target attribute value corresponding to "Hello" cannot be found in the internationalization class attribute of the first relationship. For example, "loc_Hello" cannot be found. Therefore, it is impossible to search in the second relationship, and a prompt message will be generated.
[0059] In this way, the disclosed solution generates an internationalization processing failure message when the target attribute value cannot be found in the first relation, and consequently, the target field value corresponding to the target attribute value cannot be found, and the target translation value corresponding to the target field value cannot be found. Thus, the message effectively solves the problem of code development being unaware of translation errors in internationalization processing. Furthermore, the use of the first relation allows developers to complete effective checks of all interfaces without manual clicking, greatly improving the development efficiency and accuracy of internationalization processing, thereby enhancing the user experience.
[0060] Scenario 2:
[0061] If a target attribute value corresponding to the object to be processed exists in the first relation, but a target field value corresponding to the target attribute value does not exist, a prompt message is generated; the prompt message is used to indicate that a target translation value corresponding to the object to be processed does not exist in the second relation.
[0062] In other words, in the first relationship included in the target mapping relationship, that is, in the mapping relationship between internationalization class attributes and internationalization fields, there exists a target attribute value corresponding to the object to be processed, but there is no target field value corresponding to the target attribute value. Therefore, it cannot be searched in the second relationship (that is, the mapping relationship between internationalization fields and translation fields), and internationalization processing cannot be completed. At this time, a prompt message will be generated to inform the developer that the internationalization processing of the current object to be processed has failed.
[0063] For example, in a scenario where the target application switches from English to Chinese, "Hello" is the object to be processed. At this time, the target attribute value corresponding to "Hello" is found in the internationalization class attribute of the first relation, such as "loc_Hello". However, the target field value corresponding to the target attribute value cannot be found in the first relation, such as "Hello". Therefore, it is impossible to search in the second relation, and a prompt message will be generated.
[0064] In this way, the disclosed solution finds the target attribute value corresponding to the object to be processed in the first relation. However, if the target field value corresponding to the target attribute value cannot be found in the first relation, and therefore the target translation value corresponding to the target field value cannot be found, an internationalization processing failure prompt message is generated. In this way, the prompt message effectively solves the problem that code development cannot perceive translation errors in internationalization processing. At the same time, the use of the first relation allows developers to complete the effective detection of all interfaces without manual clicking operations, which greatly improves the development efficiency of internationalization processing, as well as the accuracy of internationalization processing, thereby improving the user experience.
[0065] Scenario 3:
[0066] If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained;
[0067] If the target field value is determined not to exist in the second relationship, a prompt message is generated.
[0068] In other words, if there exists a target attribute value corresponding to the object to be processed and a target field value corresponding to the target attribute value in the first relationship included in the target mapping relationship, that is, the mapping relationship between internationalization class attributes and internationalization fields, then the target field value is checked in the second relationship included in the target mapping relationship, that is, the mapping relationship between internationalization fields and translation fields. If the target field value does not exist in the second relationship, a prompt message is generated to indicate to the developer that the internationalization processing of the current object to be processed has failed.
[0069] For example, in a scenario where the target application switches from English to Chinese, "Hello" is the object to be processed. In this case, the target attribute value corresponding to "Hello" is found in the internationalization class attribute of the first relation, such as "loc_Hello". The target field value corresponding to the target attribute value is also found in the first relation, such as "Hello". However, the target field value cannot be found in the second relation. Therefore, the target translation value corresponding to the target field value cannot be found in the second relation, and a prompt message will be generated.
[0070] In this way, the disclosed solution generates an internationalization processing failure message because the target attribute value corresponding to the object to be processed exists in the first relation, and the target field value corresponding to the target attribute value also exists, but the target field value does not exist in the second relation, and therefore the target translation value corresponding to the target field value cannot be found. In this case, the internationalization processing failure message is generated. In this way, the problem of code development not being able to perceive translation errors in internationalization processing is effectively solved by the message. At the same time, the use of the first relation allows developers to complete the effective detection of all interfaces without manual clicking operations, which greatly improves the development efficiency of internationalization processing, improves the accuracy of internationalization processing, and thus improves the user experience.
[0071] Scenario 4:
[0072] If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained;
[0073] If the target field value exists in the second relationship, but no target translation value corresponding to the target field value exists, a prompt message is generated.
[0074] In other words, in the first relationship included in the target mapping relationship, that is, in the mapping relationship between internationalization class attributes and internationalization fields, there exists a target attribute value corresponding to the object to be processed, and there exists a target field value corresponding to the target attribute value. At the same time, in the second relationship included in the target mapping relationship, that is, in the mapping relationship between internationalization fields and translation fields, it is also determined that the target field value exists. At this time, the second relationship is searched to see if there is a target translation value corresponding to the target field value. If it does not exist, a prompt message is generated to prompt the developer that the internationalization processing of the current object to be processed has failed.
[0075] For example, in a scenario where the target application switches from English to Chinese, "Hello" is the object to be processed. In this case, the target attribute value corresponding to "Hello" is found in the internationalization class attribute of the first relation, such as "loc_Hello". The target field value corresponding to the target attribute value is also found in the first relation, such as "Hello". Next, the target field value is found in the second relation. However, the target translation value corresponding to the target field value cannot be found. At this time, a prompt message will be generated.
[0076] In this way, the disclosed solution generates an internationalization processing failure message by ensuring that the target attribute value corresponding to the object to be processed exists in the first relation, and that the target field value corresponding to the target attribute value exists in the second relation contained in the target mapping relation, but that the target translation value corresponding to the target field value does not exist in the second relation. In this way, the problem of translation errors not being perceived by code developers in internationalization processing is effectively solved by the prompt message. At the same time, the use of the first relation allows developers to complete the effective detection of all interfaces without manual clicking operations, which greatly improves the development efficiency of internationalization processing, improves the accuracy of internationalization processing, and thus improves the user experience.
[0077] In a specific example of the disclosed solution, if a target attribute value corresponding to the object to be processed exists in the first relation, the target field value corresponding to the target attribute value is obtained; if the target field value exists in the second relation, and a target translation value corresponding to the target field value exists, the target translation value corresponding to the object to be processed is obtained. This improves the efficiency of internationalization development, effectively realizes internationalization processing, and thus enhances the user experience.
[0078] In a specific example of the scheme disclosed herein, the first relationship can be obtained in the following manner, specifically including:
[0079] Obtain the database file; the database file contains the second relation;
[0080] The values of multiple fields in the internationalization field of the database file are processed to obtain multiple attribute values in the internationalization class attribute;
[0081] The first relationship is obtained.
[0082] Here, the obtained database file can be one or more, so as to be applied to various aspects of internationalization processing in the target application, such as InfoPlist internationalization, UI internationalization, and internationalization replacement of third-party libraries; furthermore, the database file can be an Excel file, or other files such as Properties, XML, Json, binary, etc., and this disclosure does not limit it.
[0083] In one example, multiple field values in the internationalization field (key) of the database file are processed to obtain multiple attribute values in the internationalization class attribute (loc_key), thus obtaining the mapping relationship between the internationalization class attribute and the internationalization field, i.e., the first relationship. For example, if two field values in the internationalization field are "age" and "person", then the corresponding attribute values can be "loc_age" and "loc_person", that is, "loc_age" = "age" and "loc_person" = "person". Therefore, the first relationship expressed as "loc_key" = "key" can be obtained.
[0084] In one example, the second relationship is obtained based on the converted database file format. Specifically, in practical applications, the database file can be converted into a file format suitable for the system adapted by the target application. For example, if the database file is an Excel file and the system is an iOS system, the Excel file cannot be used on the iOS system adapted by the target application during the internationalization process. Therefore, the Excel file needs to be converted into a strings file that can be used on the iOS system, which is the file corresponding to the second relationship.
[0085] It should be noted that the mapping relationship in this disclosure is not unique. For example, the first relationship "loc_key" = "key" is only one example. It can also be {"loc_key":"key"}, "loc_key" → "key", etc. This disclosure does not limit this. In addition, the prefix "loc_" in the internationalized class attribute loc_key is also only one example. This disclosure does not limit this.
[0086] Thus, this disclosed solution checks whether internationalization can be effectively performed based on the first and second relations during the translation process of the object to be processed. While ensuring normal internationalization, it improves the accuracy of internationalization and thus enhances the user experience. Moreover, this disclosed solution can complete the effective testing of all interfaces without requiring developers to manually click, thereby effectively improving the development efficiency of internationalization.
[0087] In a specific example of the scheme disclosed herein, the first relationship is stored in a file other than the database file. It is understood that the first relationship is stored in a file different from the database file, such as a Swift file like IMILocalizableConst.swift, so that it can be used by developers.
[0088] In one example, the file storing the first and second relationships can be obtained via an internationalization script; wherein, the internationalization script includes a js file corresponding to the database file and a shell file for managing and running the js file; specifically, as shown... Figure 3 As shown, taking an Excel file as the database file and an iOS system adapted to the target application as an example, the Excel file is imported into the internationalization script. By running the shell file, a strings file (containing the second relation) suitable for the iOS system adapted to the target application is generated. At the same time as generating the strings file, a swift file (containing the first relation) is also generated.
[0089] It should be noted that in this example, "strings file" refers to a file with the .strings extension, and "swift file" refers to a file with the .swift extension.
[0090] In a specific example of the disclosed solution, an update to the database file is detected; upon completion of the database file update, the first relation is updated; it is understood that any update or change to the content of the database file requires updating the first relation or a file containing the first relation; furthermore, any update or change to the content of the database file also requires updating the second relation or a file containing the second relation; thus, the accuracy of internationalization processing is ensured.
[0091] Furthermore, updating or changing the database file can involve modifying or deleting translated values or field values, or adding new translated values and field values. This ensures the consistency of the database file with the target mapping relationship required for internationalization processing, effectively improving the efficiency of internationalization processing and thus laying the foundation for enhancing the user experience.
[0092] The following provides a more detailed explanation of this disclosure solution with specific examples. Specifically, taking the application of this disclosure solution on the iOS system as an example, English is used as the language to be internationalized (i.e., the first language), and Chinese is used as the translation language of English (i.e., the second language). At the same time, the integrated development tool Xcode is used to perform compilation checks during compilation. If Xcode compilation fails, error messages are directly displayed at the problem point to check for possible failures in the internationalization process of the App.
[0093] Specifically, such as Figure 4 As shown, the overall concept of this disclosed solution is as follows:
[0094] Step 1: Obtain the database file, such as an Excel file.
[0095] Here, the Excel file contains a second relationship between internationalization fields and translation fields; the internationalization fields include multiple field values; the translation fields include multiple translation values; and the field values correspond to the translation values.
[0096] Step 2: Based on the Excel file, generate a strings file (containing the second relationship) and a swift file (containing the first relationship).
[0097] It should be noted that the "strings" file refers to a file with the ".strings" extension, and the "swift" file refers to a file with the ".swift" extension.
[0098] Step 2.1: Use an internationalization script to convert the Excel file format to a file format suitable for the operating system that the target app is compatible with; for example, convert the Excel file to a strings file suitable for the iOS system that the target app is compatible with.
[0099] Here, the internationalization script includes a js file corresponding to the Excel file, which is used to convert the Excel file into a file (such as a strings file) required by the operating system (such as iOS).
[0100] Furthermore, the internationalization script includes a shell file for managing and running JS files; by running the shell file in the internationalization script, the JS files are run, thereby generating a strings file suitable for the iOS system adapted to the target App; the strings file contains a second relationship, the second relationship being: "internationalization field" = "translation field", for example, if the field value under the internationalization field is "age", and the translation value string under the translation field is "age", then their mapping relationship is "age" = "age".
[0101] Step 2.2: Generate a Swift file containing the first relation based on the internationalization script; specifically, generate the IMILocalizableConst.swift file based on the Excel file.
[0102] It is understandable that while using the shell file in the internationalized script to run the js file and generate the strings file, another different file, namely the swift file (such as the IMILocalizableConst.swift file), will also be generated.
[0103] Specifically, based on the internationalization script, multiple field values in the internationalization field are processed to obtain multiple attribute values in the internationalization class attribute, thus obtaining the Swift file representing the mapping relationship between the internationalization class attribute and the internationalization field. In other words, the multiple attribute values in the internationalization class attribute of the Swift file are obtained based on the multiple field values in the internationalization field.
[0104] For example, in the IMILocalizableConst.swift file, one of the field values (i.e., the key value) in the internationalization field is "age". According to the first relationship "loc_key" = "key", we can get the attribute value "loc_age" corresponding to the field value "age", which is the loc_key value corresponding to the key value.
[0105] It is understood that the representation of all mapping relationships in this disclosure is not unique. For example, the first relationship "loc_key" = "key" is only a specific example, and it can also be {"loc_key":"key"}, "loc_key" → "key", etc. This disclosure does not limit this. In addition, the "loc_" in the internationalization class attribute loc_key is also only a specific example, and this disclosure does not limit this.
[0106] In practical applications, after the database file is updated, the Swift file (such as the IMILoccalizableConst.swift file) is also updated. In other words, any update or change to the content in the database file requires updating the first relation or the Swift file containing the first relation; furthermore, any update or change to the content in the database file also requires updating the second relation or the strings file containing the second relation. This ensures the consistency between the database file and the target mapping relationship required for internationalization, effectively improving the efficiency of internationalization processing and laying the foundation for improving the user experience.
[0107] Step 3: Preprocess the strings to be translated in the target app to obtain the object to be processed. Specifically, according to the first relationship in the Swift file, use a replacement method (e.g., regular expressions) to replace all the strings to be translated in the target app with strings that have the same format as the attribute values in the internationalization class properties, thus obtaining the object to be processed.
[0108] Understandably, the first relationship in the Swift file, "loc_key" = "key", uses a replacement method to replace all the string "key" values to be translated in the target app with the value "loc_key". For example, a regular expression is used to replace all strings such as "age" and "person" to be translated in the target app with "loc_age" and "loc_person".
[0109] Step 4: Obtain the internationalization code, which is the Swift file, Strings file, and other business code files used in the target application.
[0110] It is understood that the internationalization code refers to the files used by the internationalization script-converted strings file and Swift file (such as the IMILocalizableConst.swift file) in the target App, along with other business code files.
[0111] Step 5: Translate the internationalization code in the target app.
[0112] Specifically, the object to be processed is checked against the first relation in the Swift file to see if the target attribute value corresponding to the object to be processed exists. If the target attribute value corresponding to the object to be processed cannot be found, the object to be processed cannot be internationalized, resulting in compilation failure and generating a prompt message.
[0113] If the target attribute value corresponding to the object to be processed can be found, then search in the first relation whether the target field value corresponding to the target attribute value exists; if the target field value cannot be found, the compilation fails and a prompt message is generated.
[0114] If the target field value can be found in the first relation, then the target field value in the second relation in the strings file is searched; if the target field value cannot be found, the compilation fails and an error message is generated.
[0115] If the target field value can be found in the second relation, then check if a target translation value corresponding to the target field value exists in the second relation. If it does not exist, the compilation fails and a prompt message is generated; if it exists, the compilation succeeds and the target translation value is output.
[0116] In this way, the disclosed solution establishes a connection between code development and internationalization processing through the first and second relationships. This allows for the generation of error messages during the compilation phase to address internationalization failures caused by missing or incorrectly written internationalized keys. Furthermore, developers can complete the internationalization checks for all functions without triggering all interfaces (such as specific UI pages). This significantly improves the efficiency of internationalization development and the accuracy of internationalization processing in the target app, thereby further enhancing the user experience.
[0117] This disclosure also provides an internationalized processing and inspection device, such as... Figure 5 As shown, it includes:
[0118] The acquisition unit 501 is used to acquire a target configuration file; the target configuration file includes a target mapping relationship between internationalization class attributes and translation fields; the internationalization class attributes contain multiple attribute values, the translation fields contain multiple translation values, and the attribute values correspond to the translation values;
[0119] The processing unit 502 is configured to generate a prompt message when it is determined that there is no target attribute value corresponding to the object to be processed in the internationalization class attribute of the target mapping relationship; wherein the object to be processed includes at least the relevant characters to be translated in the target application; the prompt message is used to indicate that there is no target translation value corresponding to the object to be processed.
[0120] In a specific example of the disclosed solution, the target mapping relationship includes a first relationship and a second relationship; the first relationship represents the mapping relationship between internationalization class attributes and internationalization fields; the second relationship represents the mapping relationship between internationalization fields and translation fields; the internationalization field contains multiple field values; the attribute value corresponds to the field value; the field value corresponds to the translation value;
[0121] The processing unit 502 is specifically used for:
[0122] If it is determined that no target attribute value corresponding to the object to be processed exists in the first relation, a prompt message is generated; the prompt message is used to indicate that no target translation value corresponding to the object to be processed exists in the second relation; or,
[0123] If a target attribute value corresponding to the object to be processed exists in the first relation, but a target field value corresponding to the target attribute value does not exist, a prompt message is generated; the prompt message is used to indicate that a target translation value corresponding to the object to be processed does not exist in the second relation.
[0124] In a specific example of the disclosed solution, the target mapping relationship includes a first relationship and a second relationship; the first relationship represents the mapping relationship between internationalization class attributes and internationalization fields; the second relationship represents the mapping relationship between internationalization fields and translation fields; the internationalization field contains multiple field values; the attribute value corresponds to the field value; the field value corresponds to the translation value;
[0125] The processing unit 502 is specifically used for:
[0126] If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained;
[0127] If the target field value does not exist in the second relationship, a prompt message is generated.
[0128] In a specific example of the disclosed solution, the target mapping relationship includes a first relationship and a second relationship; the first relationship represents the mapping relationship between internationalization class attributes and internationalization fields; the second relationship represents the mapping relationship between internationalization fields and translation fields; the internationalization field contains multiple field values; the attribute value corresponds to the field value; the field value corresponds to the translation value;
[0129] The processing unit 502 is specifically used for:
[0130] If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained;
[0131] If the target field value exists in the second relationship, but no target translation value corresponding to the target field value exists, a prompt message is generated.
[0132] In a specific example of the scheme disclosed herein, the processing unit 502 is further configured to:
[0133] If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained;
[0134] It is determined that the target field value exists in the second relationship, and that there is a target translation value corresponding to the target field value, thereby obtaining the target translation value corresponding to the object to be processed.
[0135] In a specific example of the present disclosure, the acquisition unit 501 is further configured to acquire a database file; the database file contains the second relationship;
[0136] The processing unit 502 is further configured to process multiple field values in the internationalization field of the database file to obtain multiple attribute values in the internationalization class attribute; and obtain the first relationship.
[0137] In a specific example of the scheme disclosed herein, the first relationship is stored in a file other than the database file.
[0138] In a specific example of the scheme disclosed herein, the processing unit 502 is further configured to:
[0139] The database file update was detected;
[0140] Once the database file update is complete, update the first relationship.
[0141] The specific functions and examples of each module and submodule of the apparatus in this disclosure can be found in the relevant descriptions of the corresponding steps in the above method embodiments, and will not be repeated here.
[0142] The acquisition, storage, and application of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0143] Figure 6 This is a structural block diagram of an electronic device according to an embodiment of the present disclosure. Figure 6 As shown, the electronic device includes a memory 610 and a processor 620. The memory 610 stores a computer program that can run on the processor 620. There can be one or more memories 610 and processors 620. The memory 610 can store one or more computer programs, which, when executed by the electronic device, cause the electronic device to perform the methods provided in the above-described method embodiments. The electronic device may also include a communication interface 630 for communicating with external devices and performing data exchange and transmission.
[0144] If the memory 610, processor 620, and communication interface 630 are implemented independently, they can be interconnected via a bus to communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0145] Optionally, in a specific implementation, if the memory 610, processor 620, and communication interface 630 are integrated on a single chip, then the memory 610, processor 620, and communication interface 630 can communicate with each other through an internal interface.
[0146] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting Advanced Reduced Instruction Set Machines (ARM) architecture.
[0147] Further, optionally, the aforementioned memory may include read-only memory and random access memory, and may also include non-volatile random access memory. The memory may be volatile or non-volatile, or may include both. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. Many forms of RAM are available by way of example, but not limitation. Examples include Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate Synchronous DRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct RAMBUS RAM (DR RAM).
[0148] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this disclosure are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line, DSL) or wireless (e.g., infrared, Bluetooth, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer, or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)). It is worth noting that the computer-readable storage media mentioned in this disclosure can be non-volatile storage media; in other words, it can be non-transient storage media.
[0149] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0150] In the description of the embodiments of this disclosure, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this disclosure. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.
[0151] In the description of the embodiments disclosed herein, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.
[0152] In the description of embodiments of this disclosure, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of embodiments of this disclosure, unless otherwise stated, "a plurality of" means two or more.
[0153] The above description is merely an exemplary embodiment of this disclosure and is not intended to limit this disclosure. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the protection scope of this disclosure.
Claims
1. An internationalization processing method, comprising: Obtain the target configuration file; The target configuration file includes the target mapping relationship between internationalization class attributes and translation fields; The internationalization class attribute contains multiple attribute values, the translation field contains multiple translation values, and the target mapping relationship includes a first relationship and a second relationship. The first relationship represents the mapping relationship between internationalization attributes and internationalization fields; the second relationship represents the mapping relationship between internationalization fields and translation fields; the internationalization field contains multiple field values; the attribute value corresponds to the field value; the field value corresponds to the translation value; If it is determined that there is no target attribute value corresponding to the object to be processed in the internationalization class attribute of the target mapping relationship, a prompt message is generated; wherein, the object to be processed includes at least the relevant characters in the target application to be translated; the prompt message is used to indicate that there is no target translation value corresponding to the object to be processed. Wherein, generating a prompt message when it is determined that there is no target attribute value corresponding to the object to be processed in the internationalization class attribute of the target mapping relationship includes: If it is determined that no target attribute value corresponding to the object to be processed exists in the first relation, a prompt message is generated; the prompt message is used to indicate that no target translation value corresponding to the object to be processed exists in the second relation; or, If a target attribute value corresponding to the object to be processed exists in the first relation, but a target field value corresponding to the target attribute value does not exist, a prompt message is generated; the prompt message is used to indicate that a target translation value corresponding to the object to be processed does not exist in the second relation.
2. The method according to claim 1, further comprising: If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained; If the target field value is determined not to exist in the second relationship, a prompt message is generated.
3. The method according to claim 1, further comprising: If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained; If the target field value exists in the second relationship, but no target translation value corresponding to the target field value exists, a prompt message is generated.
4. The method according to any one of claims 1-3, further comprising: If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained; It is determined that the target field value exists in the second relationship, and that there is a target translation value corresponding to the target field value, thereby obtaining the target translation value corresponding to the object to be processed.
5. The method according to claim 4, further comprising: Get the database file; The database file contains the second relationship; The values of multiple fields in the internationalization field of the database file are processed to obtain multiple attribute values in the internationalization class attribute; The first relationship is obtained.
6. The method according to claim 5, wherein, The first relationship is stored in a file other than the database file.
7. The method according to claim 5, further comprising: The database file update was detected; Once the database file update is complete, update the first relationship.
8. An internationalization processing device, comprising: The acquisition unit is used to acquire the target configuration file; The target configuration file includes the target mapping relationship between internationalization class attributes and translation fields; The internationalization class attribute contains multiple attribute values, and the translation field contains multiple translation values; A processing unit is configured to generate a prompt message when it determines that no target attribute value corresponding to the object to be processed exists in the internationalization class attribute of the target mapping relationship; wherein the object to be processed includes at least the relevant characters to be translated in the target application; the prompt message is used to indicate that no target translation value corresponds to the object to be processed. The target mapping relationship includes a first relationship and a second relationship; the first relationship represents the mapping relationship between internationalization attributes and internationalization fields; the second relationship represents the mapping relationship between internationalization fields and translation fields; the internationalization field contains multiple field values; the attribute value corresponds to the field value; the field value corresponds to the translation value. Specifically, the processing unit is used for: If it is determined that no target attribute value corresponding to the object to be processed exists in the first relation, a prompt message is generated; the prompt message is used to indicate that no target translation value corresponding to the object to be processed exists in the second relation; or, If a target attribute value corresponding to the object to be processed exists in the first relation, but a target field value corresponding to the target attribute value does not exist, a prompt message is generated; the prompt message is used to indicate that a target translation value corresponding to the object to be processed does not exist in the second relation.
9. The apparatus according to claim 8, wherein, The processing unit is further configured to: If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained; If the target field value does not exist in the second relationship, a prompt message is generated.
10. The apparatus according to claim 8, wherein, The processing unit is further configured to: If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained; If the target field value exists in the second relationship, but no target translation value corresponding to the target field value exists, a prompt message is generated.
11. The apparatus according to any one of claims 8-10, wherein, The processing unit is further configured to: If it is determined that a target attribute value corresponding to the object to be processed exists in the first relationship, the target field value corresponding to the target attribute value is obtained; It is determined that the target field value exists in the second relationship, and that there is a target translation value corresponding to the target field value, thereby obtaining the target translation value corresponding to the object to be processed.
12. The apparatus according to claim 11, wherein, The acquisition unit is further configured to acquire a database file; the database file contains the second relationship; The processing unit is further configured to process multiple field values in the internationalization field of the database file to obtain multiple attribute values in the internationalization class attribute; and obtain the first relationship.
13. The apparatus according to claim 12, wherein, The first relationship is stored in a file other than the database file.
14. The apparatus according to claim 12, wherein, The processing unit is further configured to: The database file update was detected; Once the database file update is complete, update the first relationship.
15. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.
17. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-7.
Citation Information
Patent Citations
Software system internationalization methods and apparatus
CN102279847A