Text internationalization method and device of iOS application, electronic equipment and storage medium

By creating a global label, GlobalizeLabel, and inheriting and overriding its properties and methods, text internationalization in iOS applications is achieved, solving the problems of code redundancy and management, and improving the maintainability and readability of the code.

CN116302286BActive Publication Date: 2026-02-24CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310317782.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-28
Publication Date
2026-02-24
Estimated Expiration
2043-03-28

AI Technical Summary

Technical Problem

The existing text internationalization methods in iOS applications result in cumbersome code calls, repetitive redundancy, large code volumes, and difficulty in unified management, increasing the cost of code refactoring and replacement.

Method used

By creating a global label, GlobalizeLabel, which inherits from the UILabel control used to display text in iOS, and defining a variable and optional computed property, globalizeText, and overriding the property assignment and return methods, internationalization is achieved, avoiding code duplication.

Benefits of technology

It simplifies the text internationalization process, reduces code redundancy, improves code maintainability and readability, facilitates unified management, and reduces the cost of code refactoring and replacement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116302286B_ABST
    Figure CN116302286B_ABST
Patent Text Reader

Abstract

The application provides a text internationalization method and device of an iOS application, an electronic device and a storage medium. The method comprises the following steps: creating a globalization label for displaying text, and the globalization label inherits a label control for displaying text in the iOS; defining a computed property for the globalization label, and the computed property is used for internationalization processing of an external parameter; when the computed property is assigned by using the external parameter, the external parameter is internationalized by using a preset property assignment calling method, the internationalized external parameter is assigned to an original text of an editor, and an internationalized original text is obtained; and after the computed property of the globalization label receives an external calling request, the internationalized original text is returned to an external caller. The implementation manner of the application is simple, there is no repeated redundant code, the user can uniformly manage the code, and the code reconstruction and replacement cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for text internationalization of iOS applications. Background Technology

[0002] Internationalization of iOS applications refers to modifying the application's code and resources to adapt the application to different languages ​​and cultures, allowing users to better understand and use the application.

[0003] Existing methods for text internationalization in iOS applications mainly include the following two approaches: The first approach is to declare a global function and pass in the corresponding parameters to achieve the internationalized display of the text; the second approach is to add an extension method to the String to achieve the internationalized display of the text. However, regardless of the approach taken, when the same words appear multiple times, the application needs to be called repeatedly, resulting in cumbersome application calling methods, a large amount of redundant and repetitive code, a large amount of code that is difficult to manage uniformly, and increased costs for code refactoring and replacement. Summary of the Invention

[0004] In view of this, embodiments of this application provide a method, apparatus, electronic device, and storage medium for text internationalization of iOS applications, in order to solve the problems of cumbersome application calling methods, large amounts of repetitive and redundant code, large code volume and difficulty in unified management, and increased costs of code refactoring and replacement in the prior art.

[0005] A first aspect of this application provides a text internationalization method for an iOS application, comprising: creating a global label for displaying text, the global label inheriting a label control for displaying text in iOS; defining a computed property for the global label, the computed property being used to internationalize external parameters; when assigning a value to the computed property using external parameters, using a preset property assignment call method to internationalize the external parameters, and assigning the internationalized external parameters to the original text of the editor to obtain the internationalized original text; and after the computed property of the global label receives an external call request, returning the internationalized original text to the external caller.

[0006] A second aspect of this application provides a text internationalization device for an iOS application, comprising: a creation module configured to create a global label for displaying text, the global label inheriting a label control for displaying text in iOS; a definition module configured to define a computed property for the global label, the computed property being used to internationalize external parameters; an assignment module configured to, when assigning a value to the computed property using external parameters, internationalize the external parameters using a preset property assignment call method, and assign the internationalized external parameters to the original text of the editor to obtain the internationalized original text; and a return module configured to, after the computed property of the global label receives an external call request, return the internationalized original text to the external caller.

[0007] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the above-described method.

[0008] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.

[0009] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects:

[0010] By creating a global label for displaying text, which inherits from the label control used for displaying text in iOS, and defining computed properties for the global label to handle the internationalization of external parameters, this approach achieves text internationalization. When assigning values ​​to the computed property using external parameters, a predefined property assignment method is used to internationalize the external parameters, and the internationalized external parameters are then assigned to the original text in the editor, resulting in the internationalized original text. Once the computed property of the global label receives an external call request, it returns the internationalized original text to the external caller. This application's text internationalization implementation is concise, requiring no additional method calls, and avoids redundant code, facilitating unified code management and allowing for easy code replacement and refactoring without affecting original functionality. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 This is a flowchart illustrating the text internationalization method for iOS applications provided in this application embodiment;

[0013] Figure 2 This is a schematic diagram of the structure of the text internationalization device for an iOS application provided in this application embodiment;

[0014] Figure 3 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0015] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0016] As described in the background section, internationalization of iOS applications refers to modifying the application's code and resources to adapt it to different languages ​​and cultures, allowing users to better understand and use the application. This process typically involves translating and adjusting elements such as text, images, sounds, dates, and currencies within the application to suit the language and cultural habits of different countries and regions. Through internationalization, developers can expand their application's audience, enhance user experience, and improve the application's usability and reliability.

[0017] The existing methods for text internationalization in iOS applications mainly include the following two implementations: The first implementation is to declare a global function (such as func globalize) and pass in the corresponding parameters to achieve the internationalized display of the corresponding text; the second implementation is a variation of the first implementation, the difference being that the second implementation adds an extension method (such as extension String{fun globalize()}) to the String to achieve the internationalized display of the text.

[0018] There are certain differences between the two implementation methods described above. The first method takes parameters, while the second does not, leading to different calling methods. For example, to internationalize a city term (such as "XX City"), the first method calls it as: `globalize("XX City")`, while the second method calls it as: `"XX City".globalize`. Because editors have code auto-completion features, the second method is simpler than the first.

[0019] As can be seen, existing iOS applications typically start with the text itself to be internationalized and perform internationalization operations accordingly. However, regardless of the implementation method, when the same words appear multiple times, the internationalization method needs to be called repeatedly. Since an application usually has tens of thousands of lines of code, the accumulated amount is staggering. This results in cumbersome calling methods, a large amount of redundant and repetitive code, and a large codebase that is difficult to manage uniformly. This increases the cost of code refactoring and replacement. Furthermore, because code changes require a complete re-release of the application, the cumbersome iOS application review process means that the increased cost of code refactoring and replacement indirectly impacts the overall development cost of the application.

[0020] In view of this, this application provides a text internationalization method for iOS applications to solve the above problems. This application creates a global tag that inherits from an existing class in iOS, giving the global tag the characteristics and functions of the existing class, avoiding repetitive code writing. This application defines a variable, optional computed property for the global tag, uses the computed property to internationalize external parameters, and internationalizes the external parameters by overriding the property assignment call method when assigning values ​​to the computed property using external parameters. By overriding the original assignment operation, internationalization can be achieved simultaneously with assignment, reducing code redundancy and improving code maintainability and reusability. This application also improves code readability and maintainability by overriding the return method of the computed property, automatically returning the internationalized text string to the external caller upon receiving an external call request.

[0021] This application focuses on the control that ultimately displays the internationalized text, rather than the text itself, offering the same functionality through a different approach and a method closer to the system's native implementation. The text internationalization implementation in this application is simple, requiring no additional method calls and containing no redundant code. This facilitates unified code management and allows for easy code replacement and refactoring without affecting original functionality.

[0022] The technical solution of this application will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0023] Figure 1 This is a flowchart illustrating the text internationalization method for iOS applications provided in this application embodiment. Figure 1 The text internationalization method for iOS applications can be performed by the iOS application itself. For example... Figure 1 As shown, the text internationalization method of this iOS application may specifically include:

[0024] S101, Create a global label for displaying text. The global label inherits the label control used to display text in iOS.

[0025] S102 defines computed properties for global tags. Computed properties are used to internationalize external parameters.

[0026] S103: When assigning values ​​to computed properties using external parameters, the preset property assignment call method is used to internationalize the external parameters, and the internationalized external parameters are assigned to the original text in the editor to obtain the internationalized original text.

[0027] S104: After the computed property of the global tag receives an external call request, it returns the original internationalized text to the external caller.

[0028] First, some technical terms involved in the embodiments of this application in practical application scenarios will be explained, which may include the following:

[0029] UILabel: A label, representing a control used to display text.

[0030] GlobalizeLabel: A custom label, also known as a global tag. The name of this custom label can be replaced according to actual needs.

[0031] class: A class identifier that indicates that the type structure of a class is declared after it.

[0032] String: A string is a type of text used to define text.

[0033] `set`: The method for assigning values ​​to computed properties in Swift.

[0034] get: A method for retrieving computed properties in Swift.

[0035] var: represents a variable.

[0036] let: indicates a constant.

[0037] self: Indicates the caller of the current method.

[0038] In some embodiments, a global label is created for displaying text. This global label inherits from the label control used for displaying text in iOS, including:

[0039] Create a new custom class that inherits the properties and methods of the label control. Use this custom class, which inherits the properties and methods of the label control, as the global label. The label control is a UI Label control.

[0040] Specifically, this application first defines a Label class, which inherits from the UILabel label control. The class name of the Label class is GlobalizeLabel (i.e., global label). In actual applications, the Label class can also use other names. The substitution of nouns does not constitute a limitation on the technical solution of this application.

[0041] It's important to note that creating a globalized label (GlobalizeLabel) is essentially defining a class definition statement in object-oriented programming. Defining a Label class means creating a class named Label to represent labels, such as the label control used in iOS development. Next, the Label class inheriting from the UILabel label control means that the newly defined Label class (i.e., the globalized label GlobalizeLabel) inherits from the existing UILabel class. In other words, this newly defined Label class will contain all the properties and methods of the UILabel class, and more functionality can be implemented by extending and modifying these properties and methods. This embodiment of the application, by inheriting from an existing class, allows the new class to possess the characteristics and functionality of the existing class, avoiding repetitive code writing. Since the globalized label GlobalizeLabel actually inherits the properties and methods of the UILabel label control, the usage of GlobalizeLabel is essentially the same as UILabel, except for the addition of internationalization functionality.

[0042] In some embodiments, computed properties are defined for global tags, including:

[0043] The computed property is initialized using the optional string type in the iOS programming language. A variable identifier is then added before the initialized computed property to obtain a computed property that represents a variable and optional string type.

[0044] Specifically, this application embodiment also defines a variable and optional computed property globalizeText for the newly defined Label class (i.e., the globalized label Globalize Label). The specific definition process may include the following:

[0045] Since the computed property `globalizeText` corresponds to the editor's original `text` property (i.e., the editor's original text, which is the assignment object of `GlobalizeLabel`, and this application will implement text internationalization in `GlobalizeLabel`), and this computed property can represent a `String` with a normal value or a `nil` with no value, iOS has a type specifically designed to represent types that possess both values: `String!` (optional string type). Therefore, the initialization definition of the computed property is achieved by adding an exclamation mark (or question mark) after `String`, so the computed property can be defined as `globalizeText: String!`. Furthermore, since the value of this computed property may change continuously during application runtime, its value cannot be a constant `let`, but should be a variable `var`. Therefore, the computed property needs further definition after initialization by adding a variable identifier `var` (i.e., variable identifier) ​​before it, i.e., `var globalizeText: String!`. Thus, the computed property `globalizeText` is fully defined, resulting in the complete definition of the computed property.

[0046] In other words, a mutable, optional computed property `globalizeText` is defined for the globalizeLabel. The primary function of this computed property is to represent the text content in the editor. The definition of this computed property uses the optional type `String!` from the Swift language. This optional type can represent an optional string, meaning the string can have a value or be `nil` to indicate no value. In Swift, a mutable variable can be defined by adding the `var` keyword before the variable name. Therefore, the complete definition of this computed property is `var globalizeText:String!`, representing a mutable, optional string type computed property. Because this computed property may change continuously during program execution, a mutable variable should be used to store its value, rather than a constant.

[0047] It's important to note that Swift is an open-source language designed to be compatible with Objective-C and borrows features from other modern programming languages ​​such as Rust, Kotlin, and Python. It utilizes best practices from modern programming languages ​​and incorporates many of their features, including type inference, generics, closures, and pattern matching. Swift boasts a concise, clear, and readable syntax, allowing developers to write code faster. Furthermore, Swift includes powerful built-in features such as ARC (Automatic Reference Counting), type inference, and error handling, helping developers avoid common programming mistakes. Swift also offers high performance and seamlessly interacts with Objective-C code. Swift has become one of the mainstream languages ​​for iOS and macOS development, with a growing number of developers using it to create mobile applications, desktop applications, server-side applications, and machine learning applications.

[0048] In some embodiments, before assigning values ​​to the computed property using external parameters, the assignment method of the computed property is processed to obtain a processed property assignment call method, including:

[0049] The original assignment operation in the assignment method of computed attributes is modified. The modified assignment operation includes first calling the internationalization method of the external parameter, using the internationalization method to internationalize the external parameter, and then assigning the value of the internationalized external parameter to the original text.

[0050] By overriding the original assignment operation in the assignment method of the computed property with the modified assignment operation, a processed property assignment call method is obtained, which enables the processed property assignment call method to have internationalization functionality.

[0051] Specifically, this application provides a method to override the `set` method (i.e., the assignment method of a computed property) of the `globalizeText` property, perform internationalization processing on it while assigning a value externally, and then assign it to the original `text` property (i.e., the original text). The following detailed explanation of the overriding principle of the `set` method and the internationalization processing method, in conjunction with specific embodiments, may include the following:

[0052] This embodiment first replaces the original assignment operation `text = newValue` with a modified assignment operation within the `set` method of the `globalizeText` property. The modified assignment operation first calls the internationalization method `newValue.globalize()` of `newValue` (i.e., the external parameter) to internationalize the value, and then assigns the internationalized value back to the original `text` property. This achieves internationalization simultaneously with the assignment, an effect achieved by overriding the original assignment operation with the modified one. It should be noted that the external parameter `newValue` is a system-provided parameter for each `set` method, representing an externally passed-in parameter that can be used unconditionally by the user.

[0053] In other words, by modifying the code implementation to adjust the original assignment operation, the modified assignment operation automatically internationalizes the value when assigning a value to one property (i.e., the `globalizeText` property), and then assigns the internationalized value to another property (i.e., the `text` property). Specifically, this is achieved by overriding the `set` method of the `globalizeText` property (the method called when assigning a value to the property), replacing the original assignment operation `text = newValue` with `newValue.globalize()`. This modifies the original assignment operation to first call an internationalization method, and then assign the internationalized value to the `text` property, thus achieving automatic internationalization. The external parameter `newValue` is a system-provided parameter for each `set` method, representing the value passed in from outside, which is the value to be assigned to the `globalizeText` property. This parameter can be used directly.

[0054] According to the technical solution provided in the embodiments of this application, by using an adjusted assignment operation to override the original assignment operation, the internationalization of external parameters can be achieved simultaneously with the assignment. This reduces code redundancy and improves code maintainability and reusability.

[0055] In some embodiments, an external parameter is internationalized using a preset attribute assignment method, and the internationalized external parameter is then assigned to the original text in the editor, including:

[0056] Obtain the external parameter used to assign a value to the computed property, perform internationalization processing on the external parameter using the modified assignment operation in the property assignment call method, and assign the internationalized value of the external parameter to the original text.

[0057] Specifically, when internationalizing the external parameter `newValue`, the external parameter `newValue` is first obtained. Then, based on the rewritten attribute assignment method provided in the aforementioned embodiment, the assignment and internationalization processes are performed to obtain the original internationalized text. The specific assignment and internationalization processes have been described in detail in the aforementioned embodiments and will not be repeated here.

[0058] In some embodiments, the method further includes: before the computed property of the globalized tag receives an external call request:

[0059] The return operation in the method for retrieving computed properties is modified. The modified return operation includes returning the string corresponding to the original internationalized text to the external caller after an external request for internationalized text is initiated.

[0060] Specifically, this application also provides an embodiment that overrides the get method of the globalizeText property (i.e., the return method of the computed property), so that when an external call is made to the original internationalized text, the value of the internationalized text property is returned. The following detailed explanation of the overriding principle and return operation method of the get method, in conjunction with specific embodiments, may include the following:

[0061] This embodiment of the application changes the original return operation `return globalizeText` in the `get` method to `return text`, that is, returning the truly internationalized string. This allows external systems to obtain the truly internationalized text at any time. In the specific code implementation of the `get` method, there is a computed property called `globalizeText`, whose `get` method returns an internationalized version of the text string. When an external system requests the value of the `globalizeText` property, it returns the corresponding internationalized version of the value.

[0062] To meet this requirement, this embodiment of the application rewrites the get method of the globalizeText property. Specifically, it changes the original return operation `return globalizeText` to `return text`. The effect of this is that when external code retrieves the value of the globalizeText property, it actually returns the internationalized version of the text property value—that is, it returns the internationalized text string, rather than the original text string.

[0063] The advantage of this approach is that external code can retrieve the internationalized text string at any time without needing to concern itself with the implementation details of internationalization. This improves code readability and maintainability, as internationalization implementations are often complex, and encapsulating them in properties makes the code more concise and clear. This implementation method enhances code readability and maintainability.

[0064] In some embodiments, the method further includes:

[0065] When an external caller initiates an external call request for uninterpreted raw text, the raw text is directly assigned a value, and the assigned raw text is returned to the external caller.

[0066] Specifically, in addition to returning the original internationalized text according to an external call request, this embodiment of the application also allows direct assignment of the `text` attribute to the external caller when the external caller requires the original, non-internationalized text (the `text` attribute), without using the `set` method of the overridden `globalizeText` attribute to internationalize the external parameter. For example, taking the word "XX City" as an example, the `globalizeText` attribute of the `GlobalizeLabel` created in this embodiment of the application is assigned the value "XX City". If the word "XX City" is not to be internationalized, it is only necessary to use its original `text` attribute and assign the word "XX City" back; that is, if internationalization is desired, the `globalizeText` attribute is assigned a value; if internationalization is not desired, the `text` attribute is directly assigned a value.

[0067] According to the technical solution provided in the embodiments of this application, all code is encapsulated internally and an assignment interface identical to that of the native UILabel is provided. This allows users to directly implement text internationalization in a familiar way without needing to learn any additional usage methods. Even if the internationalized text is used in multiple places, refactoring, modifying, or deleting it only requires operations within GlobalizeLabel. The original code remains unchanged, achieving the desired effect and greatly saving time and improving efficiency. Using this application to achieve the same functionality, only one line of code is needed to implement the internationalization of text in iOS applications. The code is concise and not redundant, facilitating unified management of this function by users. The global label GlobalizeLabel class of this application can be extended to any scenario with text display requirements, such as UITextField and UITextView, not just the GlobalizeLabel usage scenario, allowing users to flexibly extend it according to their own usage needs.

[0068] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.

[0069] Figure 2 This is a schematic diagram of the structure of the text internationalization device for an iOS application provided in this application embodiment. For example... Figure 2 As shown, the text internationalization features of this iOS application include:

[0070] Create module 201, which is configured to create a global label for displaying text. The global label inherits the label control used to display text in iOS.

[0071] Module 202 is defined and configured to define computed properties for global tags. Computed properties are used to internationalize external parameters.

[0072] The assignment module 203 is configured to internationalize the external parameters when assigning values ​​to the computed property using the external parameters, and then assign the internationalized external parameters to the original text of the editor to obtain the internationalized original text.

[0073] Return module 204 is configured to return the internationalized original text to the external caller after the computed property of the global tag receives an external call request.

[0074] In some embodiments, Figure 2 The creation module 201 creates a new custom class and makes the custom class inherit the properties and methods of the label control. The custom class that inherits the properties and methods of the label control is used as a global label. The label control is a UILabel control.

[0075] In some embodiments, Figure 2 The definition module 202 uses the optional string type in the iOS programming language to initialize the computed property. After initialization, a variable identifier is added before the computed property to obtain a computed property that represents a variable and optional string type.

[0076] In some embodiments, Figure 2 Before assigning values ​​to the computed property using external parameters, the assignment module 203 modifies the original assignment operation in the assignment method of the computed property. The modified assignment operation includes first calling the internationalization method of the external parameters, using the internationalization method to perform internationalization processing on the external parameters, and then assigning the value of the internationalized external parameters to the original text. The modified assignment operation is used to override the original assignment operation in the assignment method of the computed property to obtain the processed property assignment call method, so that the processed property assignment call method has internationalization function.

[0077] In some embodiments, Figure 2 The assignment module 203 obtains the external parameters used to assign values ​​to the computed properties, performs internationalization processing on the external parameters using the modified assignment operation in the property assignment call method, and assigns the internationalized values ​​of the external parameters to the original text.

[0078] In some embodiments, Figure 2 Before the computed property of the global tag receives an external call request, the return module 204 modifies the return operation in the method of obtaining the computed property. The modified return operation includes returning the string corresponding to the stored original internationalized text to the external caller after the external party initiates a call request for internationalized text.

[0079] In some embodiments, Figure 2 When an external caller initiates an external call request for uninterpreted raw text, the return module 204 directly assigns a value to the raw text and returns the assigned raw text to the external caller.

[0080] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0081] Figure 3 This is a schematic diagram of the structure of the electronic device 3 provided in an embodiment of this application. Figure 3 As shown, the electronic device 3 of this embodiment includes a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301. When the processor 301 executes the computer program 303, it implements the steps in the various method embodiments described above. Alternatively, when the processor 301 executes the computer program 303, it implements the functions of each module / unit in the various device embodiments described above.

[0082] For example, computer program 303 may be divided into one or more modules / units, which are stored in memory 302 and executed by processor 301 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 303 in electronic device 3.

[0083] Electronic device 3 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 3 may include, but is not limited to, processor 301 and memory 302. Those skilled in the art will understand that... Figure 3This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.

[0084] Processor 301 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. A general-purpose processor can be a microprocessor or any conventional processor.

[0085] The memory 302 can be an internal storage unit of the electronic device 3, such as a hard disk or RAM. The memory 302 can also be an external storage device of the electronic device 3, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 302 can include both internal and external storage units of the electronic device 3. The memory 302 is used to store computer programs and other programs and data required by the electronic device. The memory 302 can also be used to temporarily store data that has been output or will be output.

[0086] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0087] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0088] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0089] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0090] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0091] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0092] If an integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0093] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for text internationalization in iOS applications, characterized in that, include: Create a global label for displaying text, which inherits from the label control used to display text in iOS; Define computed properties for the globalized tag, which are used for internationalization of external parameters; The step of defining computed properties for the global tag includes: initializing the computed property using the optional string type in the iOS programming language, and adding a variable identifier before the computed property after initialization to obtain a computed property that represents a variable and optional string type. When assigning values ​​to the computed property using external parameters, the external parameters are internationalized using a preset property assignment call method, and the internationalized external parameters are assigned to the original text of the editor to obtain the internationalized original text. After the computed attribute of the globalized tag receives an external call request, it returns the original internationalized text to the external caller.

2. The method according to claim 1, characterized in that, The creation of a global label for displaying text, wherein the global label inherits from the label control for displaying text in iOS, includes: Create a new custom class and make the custom class inherit the properties and methods of the label control. Use the custom class that inherits the properties and methods of the label control as the global label. The label control is a UILabel control.

3. The method according to claim 1, characterized in that, Before assigning values ​​to the computed attribute using external parameters, the assignment method for the computed attribute is processed to obtain a processed attribute assignment call method, including: The original assignment operation in the assignment method of the calculated attribute is modified. The modified assignment operation includes first calling the internationalization method of the external parameter, using the internationalization method to perform internationalization processing on the external parameter, and then assigning the value of the internationalized external parameter to the original text. The modified assignment operation is used to override the original assignment operation in the assignment method of the computed attribute, resulting in a processed attribute assignment call method, which then has internationalization functionality.

4. The method according to claim 3, characterized in that, The step of internationalizing external parameters using a preset attribute assignment method and then assigning the internationalized external parameters to the original text in the editor includes: Obtain the external parameter used to assign a value to the computed attribute, perform internationalization processing on the external parameter using the modified assignment operation in the attribute assignment call method, and assign the value of the internationalized external parameter to the original text.

5. The method according to claim 1, characterized in that, Before the computed property of the globalized tag receives an external call request, the method further includes: The return operation in the method for obtaining the calculated attribute is modified. The modified return operation includes returning the string corresponding to the stored original internationalized text to the external caller after an external request for internationalized text is initiated.

6. The method according to claim 1, characterized in that, The method further includes: When an external caller initiates an external call request for uninterpreted raw text, the raw text is directly assigned a value, and the assigned raw text is returned to the external caller.

7. A text internationalization device for an iOS application, characterized in that, include: The module is configured to create a global label for displaying text, which inherits the label control used for displaying text in iOS. A definition module is configured to define computed properties for the globalized tag, the computed properties being used for internationalization of external parameters; The step of defining computed properties for the global tag includes: initializing the computed property using the optional string type in the iOS programming language, and adding a variable identifier before the computed property after initialization to obtain a computed property that represents a variable and optional string type. The assignment module is configured to, when assigning values ​​to the computed property using external parameters, use a preset property assignment call method to internationalize the external parameters, and then assign the internationalized external parameters to the original text of the editor to obtain the internationalized original text. The return module is configured to return the internationalized original text to the external caller after the computed attribute of the globalized tag receives an external call request.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Notification message processing method, electronic equipment and system

    CN114915607A