Virtual page language switching method and device, electronic equipment and storage medium

By switching the sub-view languages ​​of the virtual page in real time and sequentially, the problem of untimely language switching in the prior art is solved, the user experience is improved and resources are saved.

CN119201320BActive Publication Date: 2025-10-10CHENGDU CELIS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411341906.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-10-10
Estimated Expiration
2044-09-25

AI Technical Summary

Technical Problem

In the prior art, language switching of a virtual page requires rebuilding the entire page or restarting the application, resulting in untimely language switching and poor user experience, especially when multiple pages are open.

Method used

By traversing the subviews of the virtual page based on real-time order, the switching order is determined according to the page layer of the subview and the distance value from the page center, the text language of the subview is quickly converted, and the target switching language is used as the default language to avoid rebuilding the page.

Benefits of technology

It improves the user's sensory comfort, saves data processing resources, ensures that the language of the sub-views within the user's sight is quickly switched, and displays the user's desired language when creating a new page.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201320B_ABST
    Figure CN119201320B_ABST
Patent Text Reader

Abstract

The application relates to the field of page display, and discloses a language switching method and device for a virtual page, an electronic device and a storage medium, the method comprising the following steps: in response to a language switching instruction, sequentially traversing sub-views in a current virtual page in real time, and taking the traversed sub-views as target sub-views; wherein the language switching instruction specifies a target switching language, and the real-time sequence is determined according to the page layer where each sub-view is located and the distance value from the center of the current virtual page; if the text language in the target sub-views is different from the target switching language, the text language in the target sub-views is converted into the target switching language, and the target switching language is taken as a default language, so that the target switching language is displayed by default when a new virtual page is created. According to the application, the entire virtual page does not need to be reloaded, the sensory comfort of a user is improved, unnecessary switching processes between the same languages are avoided, and data processing resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of page display, and in particular to a method, device, electronic device and storage medium for switching the language of a virtual page. Background Art

[0002] With the increasing internationalization of various applications, the demand for diversified page display languages ​​has also increased. In particular, switching the text language within a virtual page requires rebuilding the entire virtual page or restarting the application to complete the text language switch. If multiple virtual pages are open, each virtual page must be rebuilt, resulting in delayed language switching and a poor user experience. Summary of the Invention

[0003] In view of the above problems, the present application provides a language switching method, device, electronic device and storage medium for a virtual page, which are used to quickly switch the text language in a virtual page without rebuilding the virtual page.

[0004] According to one aspect of the present application, a language switching method for a virtual page is provided, the language switching method comprising: responding to a language switching instruction, traversing the subviews in the current virtual page based on a real-time order, and using the traversed subviews as target subviews; wherein the language switching instruction specifies a target switching language, and the real-time order is an order determined based on the page layer in which each subview is located and the distance value from the center of the current virtual page; if the text language in the target subview is different from the target switching language, converting the text language in the target subview into the target switching language, and using the target switching language as the default language, so that the target switching language is displayed by default when a new virtual page is created.

[0005] In an optional manner, converting the text language in the target subview into the target switching language further includes: determining the resource code corresponding to the text resource of the text language in the target subview; determining the target text resource corresponding to the resource code in the text resource directory corresponding to the target switching language; wherein the language of the target text resource is the target switching language, and text resources with the same meaning represented by different languages ​​have the same resource code; replacing the text resource in the target subview with the target text resource to convert the text language in the target subview into the target switching language.

[0006] In an optional manner, before traversing the sub-views of the current virtual page based on the real-time order, the language switching method further includes: determining the page layer in which each sub-view is located, and the distance value between the center of each sub-view and the center of the current virtual page; multiplying the page layer in which each sub-view is located and the corresponding distance value by their respective corresponding preset weight coefficients to obtain two products corresponding to each sub-view; summing the two products corresponding to each sub-view to obtain the sum value corresponding to each sub-view, and determining the real-time order according to the size of the sum value corresponding to each sub-view.

[0007] In an optional manner, the language switching method further includes: constructing text resource directories corresponding to different text languages, and encoding the files in each of the text resource directories so that each file corresponds to a resource code; storing text resources with the same meaning in files in the text resource directories corresponding to different text languages, so that the resource codes corresponding to text resources with the same meaning in different text resource directories are the same.

[0008] In an optional manner, the language switching method further includes: detecting whether the text resource directory corresponding to the text language in the target subview is the same as the text resource directory corresponding to the target switching language; if they are the same, it indicates that the text language in the target subview is the same as the target switching language; if they are different, it indicates that the text language in the target subview is different from the target switching language.

[0009] In an optional manner, the language switching method is applied to the current interface of the Android application; before converting the text language in the target subview into the target switching language, the language switching method also includes: detecting whether the interface corresponding to the target subview is a preset interface; wherein the preset interface corresponds to a view that can load text resources; if yes, sending a switching message to a preset message event function, so that the preset message event function calls a language switching function to switch the text language in the target subview.

[0010] In an optional manner, the language switching method further includes: if it is detected that the text language of all sub-views in the current interface is converted to the target switching language, then the text language of all sub-views in the historical interface is converted to the target switching language; wherein the historical interface is the interface covered by the current interface.

[0011] According to another aspect of the present application, a language switching device for a virtual page is provided, the language switching device comprising: a response module configured to, in response to a language switching instruction specifying a target switching language, traverse sub-views in a current virtual page in a real-time order and take a traversed sub-view as a target sub-view, wherein the real-time order is determined according to a page layer in which each sub-view is located and a distance value from a center of the current virtual page; and a switching module configured to, if a text language in the target sub-view is different from the target switching language, convert the text language in the target sub-view into the target switching language and take the target switching language as a default language so as to display the target switching language by default when a new virtual page is created.

[0012] According to an aspect of the present application, an electronic device is provided, comprising: a controller; and a memory configured to store one or more programs, which, when executed by the controller, perform the language switching method described above.

[0013] According to an aspect of the present application, a computer readable storage medium having computer readable instructions stored thereon is also provided, which, when executed by a processor of a computer, causes the computer to perform the language switching method described above.

[0014] According to an aspect of the present application, a computer program product or computer program is also provided, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device performs the language switching method described above.

[0015] The present application does not need to reload the entire virtual page, but switches the text language in each sub-view of the virtual page based on a real-time order, because the real-time order is determined according to a page layer in which each sub-view is located and a distance value from a center of the current virtual page, which to some extent, gives priority to switching the text language of a sub-view in the user's visual field, thereby improving the user's sensory comfort. In addition, the present application can avoid unnecessary switching process between the same language, thereby saving data processing resources. Meanwhile, the target switching language is taken as a default language so as to display the target switching language by default when a new virtual page is created, so as to meet the user's expected language display requirement.

[0016] The above description is only a summary of the technical solutions of the embodiments of the present application, in order to more clearly understand the technical means of the present application, the embodiments of the present application can be implemented according to the content of the description, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the following specific embodiments of the present application are described. BRIEF DESCRIPTION OF DRAWINGS

[0017] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application. It is to be expressly understood, however, that the drawings are only for the purpose of illustration and are not intended as a definition of the limits of the application. In the drawings, the same reference number or letter can be used throughout different drawings to refer to a same or like element.

[0018] Figure 1 is a flowchart of a language switching method of a virtual page according to an example embodiment of the present application.

[0019] Figure 2 is a schematic diagram of an example virtual page.

[0020] Figure 3 is a flowchart of another language switching method of a virtual page according to an example embodiment of the present application. Figure 1 is a flowchart of another language switching method of a virtual page according to an example embodiment of the present application.

[0021] Figure 4 is a flowchart of another language switching method of a virtual page according to an example embodiment of the present application. Figure 1 is a flowchart of another language switching method of a virtual page according to an example embodiment of the present application.

[0022] Figure 5 is a schematic diagram of an interface lifecycle of an existing Android application.

[0023] Figure 6 is a flowchart of another language switching method of a virtual page according to an example embodiment of the present application. Figure 1 is a flowchart of another language switching method of a virtual page according to an example embodiment of the present application.

[0024] Figure 7 is a schematic diagram of a language switching apparatus of a virtual page according to an example embodiment of the present application.

[0025] Figure 8 is a schematic diagram of a computer system of an electronic device according to an example embodiment of the present application. DETAILED DESCRIPTION

[0026] The example embodiments will be described herein below with reference to a few drawings. The following description is, together with the drawings, meant to be a non-limiting example of the application. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The description is merely exemplary in nature and is not intended to limit the present application, as described, to the particular embodiments presented. It is to be understood that throughout the description and in the claims, relative terms are used to generally describe relationships between elements. In particular, the terms "front," "back," "left," "right," "rear," "top," "bottom," "side," "underside," "overhead," and the like, are not intended to be absolute terms of reference but are used for ease of description and are merely used for different positions and orientations of elements to each other. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein are to be understood as possibly having several modifications and many orientations.

[0027] The block diagrams shown in the drawings are merely functional entities, and do not necessarily correspond to physically independent entities. That is, the functional entities can be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0028] The flowcharts shown in the drawings are merely exemplary illustrations, and do not necessarily include all contents and operations / steps, nor are they necessarily executed in the order described. For example, some operations / steps can be further decomposed, and some operations / steps can be combined or partially combined, so the actual execution order can be changed according to actual conditions.

[0029] In the present application, "multiple" refers to two or more. The association relationship of "and / or" describes the associated objects, which means that there can be three relationships, for example, A and / or B can represent the three cases of A alone, A and B together, and B alone. The character " / " generally represents an "or" relationship between the associated objects before and after it.

[0030] For switching the text language in a virtual page, the entire virtual page needs to be rebuilt or the application needs to be restarted to complete the text language switching. If multiple virtual pages are opened, each virtual page needs to be rebuilt, resulting in a delay in language switching and a poor user experience.

[0031] To this end, one aspect of the present application provides a language switching method for a virtual page. For details, please refer to Figure 1 , Figure 1 is a flowchart of a language switching method for a virtual page according to an exemplary embodiment of the present application. The language switching method includes at least S110 to S120, which are described in detail as follows:

[0032] S110: In response to a language switching instruction, iterates through the sub-views in the current virtual page based on a real-time order, and takes the iterated sub-views as target sub-views; wherein the language switching instruction specifies a target switching language, and the real-time order is determined according to the page layer where each sub-view is located and the distance value from the center of the current virtual page.

[0033] The language switching instruction is triggered by the user through inputting a voice or by touching a virtual button in the current virtual page, and carries the target switching language, i.e., the language that the user expects the current page to display.

[0034] The current virtual page is a window for realizing human-computer interaction, for example, a page displayed in the entire display screen. There are multiple sub-views in the virtual page, similar to different display areas, and the display content of each sub-view can be different. All the sub-views constitute a complete virtual page.

[0035] The embodiment considers the page layer and the center distance value of the sub-view in real-time sequence, to obtain the corresponding traversal sequence, to perform the language switching operation on the sub-view in the front sequence preferentially, to ensure that the text language in the sub-view in the front sequence is switched quickly. At the same time, the language switching of each sub-view can be ensured without omission through the traversal manner, to avoid omission processing.

[0036] In another embodiment, a corresponding preset weight coefficient is introduced to adjust the influence of two dimensions on the traversal sequence of the sub-view, that is, the influence of the real-time sequence. Exemplarily, the page layer where each sub-view is located and the distance value between the center of each sub-view and the center of the current virtual page are determined; the page layer where each sub-view is located and the corresponding distance value are multiplied by the corresponding preset weight coefficient respectively, to calculate two products corresponding to each sub-view; the two products corresponding to each sub-view are summed, to calculate the sum value corresponding to each sub-view, and the real-time sequence is determined according to the sum value corresponding to each sub-view. The number of page layers corresponds to the first preset weight coefficient, and the distance value corresponds to the second preset weight coefficient, and the application does not limit the specific size of the two coefficients. The corresponding real-time sequence can be determined by adjusting the numerical size of them, to adjust the traversal sequence of each sub-view.

[0037] Please refer to Figure 2 , Figure 2 is a schematic diagram of an exemplary virtual page. There are sub-views of different page layers, and the distance of each sub-view from the center point of the virtual page is also different. As shown in Figure 2 , there are 2 page layers in the virtual page, and the score values corresponding to each page layer are different, and the scores decrease from top to bottom. According to the geometric center point coordinates of each sub-view and the virtual page center point coordinates, the distance between the two coordinate points can be calculated as the distance of the corresponding sub-view from the virtual page center point.

[0038] Further, the first preset weight coefficient is 0.6, and the second preset weight coefficient is 0.4; the sub-views A, C, D are in the first page layer, and the corresponding page layer value is 70, and they are 70 away from the virtual page center point Figure 2The distance of the center of the sub-view A (or the center of the black dot) from the center of the virtual page is a, the distance of the center of the sub-view C (or the center of the black dot) from the center of the virtual page is c, and the distance of the center of the sub-view D (or the center of the black dot) from the center of the virtual page is d. The sum of the sub-view A is 0.6*70+0.4*a, the sum of the sub-view B is 0.6*30+0.4*b, the sum of the sub-view C is 0.6*70+0.4*c, and the sum of the sub-view D is 0.6*70+0.4*d. Then, the real-time sequence is determined according to the four sums. In particular, in most scenarios, the user generally defaults to stay on the first page, and if the same sum is calculated, the sequence of the sub-view on the page layer is arranged in front.

[0039] In S120, if the text language in the target sub-view is different from the target switching language, the text language in the target sub-view is converted into the target switching language, and the target switching language is used as the default language to display the target switching language by default when a new virtual page is created.

[0040] The embodiment does not need to reload the entire virtual page, but switches the text language in each sub-view of the virtual page based on the real-time sequence. The real-time sequence is determined according to the page layer where each sub-view is located and the distance value from the center of the current virtual page, which to some extent, preferentially ensures the switching of the text language of the sub-view in the user's visual line, thereby improving the sensory comfort of the user. In addition, the application can avoid unnecessary switching between the same languages, thereby saving data processing resources. Meanwhile, the target switching language is used as the default language to display the target switching language by default when a new virtual page is created, so as to meet the language display requirements expected by the user.

[0041] In another exemplary embodiment of the application, how to convert the text language in the target sub-view into the target switching language is described in detail, please refer to Figure 3 , Figure 3 is based on Figure 1 Another flowchart of a language switching method of a virtual page is shown in the exemplary embodiment. The language switching method further includes S310-S330 in S120 as shown in Figure 1 The details are as follows:

[0042] S310: Determine the resource code corresponding to the text resource of the text language in the target sub-view.

[0043] The text resource can be a noun, a verb, etc., that is, a resource with substantive text meaning. Different text resources correspond to different resource codes, for example, the text resource "hello" corresponds to the ID (resource code) "1".

[0044] S320: In the text resource directory corresponding to the target switching language, a target text resource corresponding to the resource code is determined; wherein the language of the target text resource is the target switching language, and the resource codes of the text resources representing the same meaning are the same.

[0045] Each language corresponds to a corresponding text resource directory, and the text resource directories corresponding to different languages are different. It is worth noting that, regardless of the language type, the resource codes of the text resources representing the same meaning are fixed, for example, the ID (resource code) of "hello" is "1", that is, the number of the corresponding text resource in the Chinese text resource directory is 1, and the number of "hello" in the English text resource directory is also 1, that is, the different switching languages can be quickly determined by the coding of the text resources.

[0046] S330: Replacing the text resources in the target sub-view with the target text resources to convert the text language in the target sub-view into the target switching language.

[0047] Exemplarily, the target switching language is English, and the text resource "hello" in the target sub-view is Chinese, and the target text resource "hello" can be quickly determined according to the number "1" of the text resource "hello", that is, the text resource "hello" in the target sub-view can be quickly switched to "hello".

[0048] The embodiment switches between different languages through the coding of text resources, sets different text resource directories for different types of languages, stores the text resources representing the same meaning in different text resource directories with one coding, and stores the text resources representing the same meaning in different text resource directories with one coding, so as to facilitate quick access to the text resources of the corresponding language and complete the text switching of the sub-view.

[0049] In another exemplary embodiment, how to build the text resource directories corresponding to different text languages is introduced. Specifically, the text resource directories corresponding to different text languages are built, and the files in each text resource directory are coded to make each file correspond to a resource code; the text resources representing the same meaning are stored in the files in the text resource directories corresponding to different text languages, so that the resource codes of the text resources representing the same meaning in different text resource directories are the same.

[0050] For example, the text resource directories include but are not limited to chinese- directory, english- directory, etc., and "hello" and "hello" are respectively stored in the No. 1 file in the chinese- directory and the english- directory, so that the resource codes of the text resources representing the same meaning in different text resource directories are the same.

[0051] In another exemplary embodiment of the present application, how to determine whether the languages are the same or not is introduced in detail, please refer to Figure 4 , Figure 4 is based on Figure 1 Fig. 6 is a flow diagram of another language switching method of a virtual page according to an exemplary embodiment shown in the figure. The language switching method is based on S110-S120 shown in Fig. 5, and further comprises S410-S430, which are described in detail as follows: Figure 1

[0052] S410: detecting whether the text resource directory corresponding to the text language in the target sub-view is the same as the text resource directory corresponding to the target switching language.

[0053] S420: if yes, it indicates that the text language in the target sub-view is the same as the target switching language.

[0054] S430: if no, it indicates that the text language in the target sub-view is different from the target switching language.

[0055] In this embodiment, whether the text language is the same can be determined by detecting whether the text resource directories corresponding to the text languages are the same. Different encoding can be performed on different text resource directories to quickly determine whether the text resource directories are the same according to the encoding, so as to determine whether the text language in the target sub-view is the same as the target switching language, thereby avoiding unnecessary language switching operation.

[0056] The existing language switching process of an Android application is shown in Fig. 7. Figure 5 Figure 5 Fig. 8 is an interface lifecycle diagram of an existing Android application. In the figure, Activity represents an interface, and each process is described as follows:

[0057] onCreate: the first method to start the activity, which initializes the setContentLayout() method (screen drawing).

[0058] onStart: after the onCreate() method is completed, the activity enters the onStart() method, and the current activity is in a visible state, but cannot be interacted, and some animation initialization operations are performed.

[0059] onResume: after the onStart() method, the activity enters the onResume method, and the current activity state is in a running state (Running), and the activity is visible and can be interacted.

[0060] ​​onPause: When the system calls this method, it is usually used to confirm data saving changes for persistence, stop animations, and any other content that might consume CPU, he must quickly perform the required operations, the next Activity can start to execute after this method is executed, the method should be executed after the onStop() method,

[0061] onStop: When the Activity is no longer visible to the user, it may be covered by another Activity or returned to the desktop, the system may be recycled when the system memory is tight. Call this method under the onStop method.

[0062] onDestory: Call this method before the Activity is destroyed, it is the last call the Activity receives, when the Activity ends or the system destroys the Activity instance, the method will be called.

[0063] onRestart: Call this method when the Activity is stopped and then started again, such as returning to the application from the desktop, then call the onStart method().

[0064] When the Activity reloads after switching languages, it will go through a complete life cycle process:

[0065] 1. Language switching detection:

[0066] When the application detects a change in the system language, it will update the language settings of the application and call the recreate() method to recreate the Activity.

[0067] 2.onPause(): The current Activity enters the pause state. The system calls onPause() to handle tasks such as saving data or stopping animations when the interface is paused.

[0068] 3.onStop(): The system calls onStop() when the Activity is completely invisible. At this time, you can release resources that are no longer needed.

[0069] 4.onDestroy(): The system calls onDestory() to destroy the current Activity instance in order to create a new instance. This is the end of the old Activity life cycle.

[0070] 5.onCreate(): The system creates a new Activity instance and calls onCreate(). Here, the application loads resources for the new language, such as layouts and strings.

[0071] 6. onStart(): When the activity becomes visible, the system calls onStart(). At this time, you can resume paused resources.

[0072] 7. onResume(): When the activity returns to the foreground and is ready to interact with the user, the system calls onResume(). At this stage, the interface has already used the new language resources.

[0073] Continue application execution: The Activity enters the active state, the application runs normally, and the updated interface is displayed.

[0074] Obviously, existing Android application language switching methods all require restarting the application or rebuilding the page to complete the text language switch. If there are many pages opened in the Android application, each page needs to be rebuilt, which is a cumbersome process and will reduce the user's visual experience.

[0075] To this end, any of the above-mentioned language switching methods of this application is applied to applications in the Android system, and through a custom interface and a quick notification interface refresh method, the language can be switched without rebuilding the interface, thereby saving rendering resources and improving the user experience. Figure 6 , Figure 6 is based on Figure 1 The exemplary embodiment shown is a flow chart of another method for switching the language of a virtual page. Figure 1 Before S120 shown, the method further includes S610 to S620; wherein, the language switching method is applied to the current interface of the Android application, which is described in detail as follows:

[0076] S610: Detect whether the interface corresponding to the target subview is a preset interface; wherein the preset interface corresponds to a view that can load text resources.

[0077] This application can switch the language of loadable text resources in the Android application interface. Specifically, through the interface detection of the sub-view, it can quickly determine whether the text language of the corresponding sub-view can be switched.

[0078] S620: If yes, send a switching message to a preset message event function, so that the preset message event function calls a language switching function to switch the text language in the target subview.

[0079] Exemplarily, a tool library EventBus is introduced in the Android application to implement the notification function, so as to facilitate the calling of the language switching function and quickly switch the text language in the target sub-view. Wherein, the EventBus is a set of Android / Java event subscription / publishing framework, which is used to deliver data or events to subscribers in the scenario of component / thread communication, and the characteristics of the EventBus are that the event subscriber and the publisher can be decoupled, and the thread switching is transparent.

[0080] The language switching of the Android application interface is exemplarily described below.

[0081] Step 1: define a multi-language switching interface IlanguageSwitch (i.e. the preset interface of the application)

[0082] The IlanguageSwitch interface includes the following methods:

[0083] public interface IlanguageSwitch{

[0084] void setTextById(@StringRes int id); / / set text by resource id

[0085] void setTextWithString(String text); / / directly set text

[0086] void reLoadLanguage(); / / mainly called when modifying the language

[0087] }

[0088] Step 2: define an AppTextView to implement the IlanguageSwitch interface, wherein the AppTextView refers to the View (i.e. the target sub-view) that needs to switch the language, and then implement the function logic of switching the language defined in the interface. The pseudo code for implementing the interface is as follows:

[0089] public class AppTextView extends TextView implements IlanguageSwitch{

[0090] private int textId; / / text resource id (i.e. the text resource code of the application)

[0091] private int textValue; / / text

[0092] public AppTextView(Context context){

[0093] super(context);

[0094] init(context,null);

[0095] }

[0096] / / Initialize and get the resource id of xml

[0097] private void init(Context context,AttributeSet attributeSet){

[0098] textValue=attributeSet.getAttributeValue(ANDROIDXML,"text");

[0099] / / This is where you record the text resource ID. When you switch languages ​​later, you can read the language of the corresponding country through this resource ID.

[0100]

[0101] Step 3: All views that display text in the application need to be implemented according to the method in step 2, so that the custom view can switch languages ​​at will without rebuilding.

[0102] Step 4: After completing the above three steps, a notification-triggered view refresh mechanism is required so that the custom view can be refreshed synchronously when switching languages. There are many ways to implement this notification refresh function. Here, you need to introduce the tool library EventBus into the application to implement the notification function.

[0103] After introducing EventBus, you need to register the same refresh event in each Activity using the registration method provided by EventBus: EventBus.getDefault().register(this); and implement the onMessageEvent function, which is used to process received messages. Here you can switch the language of the interface.

[0104] An Activity (interface) may contain a ViewGroup, and a ViewGroup may contain multiple subviews, so here is a function encapsulated to find all subviews and implement language switching for all views on the interface:

[0105]

[0106] The logic of this method is to pass in a view (usually the root view of the Activity) and check all the subviews. If it is a view that implements the IlanguageSwitch interface, the view's reLoadLanguage() function is called to update the language.

[0107] When switching languages, the onMessageEvent() function (i.e., the preset message event function of this application) will receive a message, and calling the above-encapsulated updateViewLanguage function (i.e., the language switching function of this application) can complete the language switching without rebuilding the interface.

[0108] public void onMessageEvent(MessageEvent event){

[0109] updateViewLanguage(view)

[0110] }

[0111] Now you can update the language by clicking a button. The Activity is not rebuilt, and the language of the previous Activity will also be switched.

[0112] In some embodiments, if it is detected that the text language of all subviews in the current interface is converted to the target switching language, the text language of all subviews in the historical interface is converted to the target switching language; wherein the historical interface is the interface covered by the current interface.

[0113] After completing the language switching of the current interface, this embodiment can switch the language of the overlaid interface, so that the user can open the overlaid interface, and the interface displays the text language that the user expects to display. There is no need to switch the text language after opening the overlaid interface, which avoids the waiting time for language switching and improves the user experience.

[0114] Another aspect of the present application also provides a language switching device for a virtual page, such as Figure 7 As shown, Figure 7is a structural schematic diagram of a language switching device of a virtual page according to an example embodiment of the present application. The language switching device 700 comprises: a response module 710, configured to traverse sub-views in a current virtual page in real-time sequence based on a language switching instruction, and take a traversed sub-view as a target sub-view, wherein the language switching instruction specifies a target switching language, and the real-time sequence is determined according to page layers where the sub-views are located and distance values from centers of the current virtual page; and a switching module 730, configured to convert a text language in the target sub-view into the target switching language and take the target switching language as a default language if the text language in the target sub-view is different from the target switching language, so that the target switching language is displayed by default when a new virtual page is created.

[0115] In another example embodiment, the switching module 730 further comprises: a resource code determining unit, configured to determine resource codes corresponding to character resources of the text language in the target sub-view; a target character resource determining unit, configured to determine target character resources corresponding to the resource codes in a character resource directory corresponding to the target switching language, wherein the target character resources are in the target switching language, and resource codes corresponding to character resources representing the same meaning are the same; and a switching unit, configured to replace the character resources in the target sub-view with the target character resources, so as to convert the text language in the target sub-view into the target switching language.

[0116] In another example embodiment, the language switching device 700 further comprises: a center distance determining unit, configured to determine page layers where the sub-views are located and distance values from centers of the current virtual page to centers of the sub-views; a first calculating unit, configured to multiply each page layer where a sub-view is located and a corresponding distance value by a corresponding preset weight coefficient respectively, to obtain two products corresponding to each sub-view; and a second calculating unit, configured to sum the two products corresponding to each sub-view, to obtain a sum value corresponding to each sub-view, and determine a real-time sequence according to the sum values corresponding to the sub-views.

[0117] In another example embodiment, the language switching device 700 further comprises: a constructing unit, configured to construct character resource directories corresponding to different text languages, and encode files in each character resource directory, so that each file corresponds to a resource code; and a storage unit, configured to store character resources representing the same meaning into files in the character resource directories corresponding to the different text languages, so that resource codes corresponding to the character resources representing the same meaning are the same in the different character resource directories.

[0118] In another example embodiment, the language switching device 700 further comprises a detection unit configured to detect whether a text language corresponding to the target sub-view is the same as a text language corresponding to the target switching language; and a same unit configured to, if the text language corresponding to the target sub-view is the same as the text language corresponding to the target switching language, represent that the text language corresponding to the target sub-view is the same as the text language corresponding to the target switching language; and a different unit configured to, if the text language corresponding to the target sub-view is different from the text language corresponding to the target switching language, represent that the text language corresponding to the target sub-view is different from the text language corresponding to the target switching language.

[0119] In another example embodiment, the language switching method is applied to a current interface of an Android application; and the language switching device 700 further comprises an interface detection unit configured to detect whether a target sub-view corresponds to a preset interface; wherein the preset interface corresponds to a view capable of loading text resources; and a sending unit configured to, if the target sub-view corresponds to the preset interface, send a switching message to a preset message event function, so as to enable the preset message event function to call a language switching function for switching a text language in the target sub-view.

[0120] In another example embodiment, the language switching device 700 further comprises an interface switching unit configured to, if it is detected that text languages of all sub-views in the current interface are converted to the target switching language, convert text languages of all sub-views in a history interface to the target switching language; wherein the history interface is an interface covered by the current interface.

[0121] The language switching device of the present application does not need to reload the entire virtual page, but switches text languages in each sub-view of the virtual page based on a real-time sequence. The real-time sequence is determined according to a page layer in which each sub-view is located and a distance value from the center of the current virtual page. To some extent, the switching of the text languages of the sub-views in the user's visual field is preferentially guaranteed, thereby improving the sensory comfort of the user. In addition, the present application can avoid unnecessary switching processes between the same languages, thereby saving data processing resources. Meanwhile, the target switching language is taken as a default language, so that the target switching language is displayed by default when a new virtual page is created, so as to meet the language display requirements expected by the user.

[0122] It should be noted that the language switching device provided in the above embodiments and the language switching method provided in the above embodiments belong to the same concept, and the specific manner in which each module and unit performs operations has been described in detail in the method embodiments, which will not be described here.

[0123] Another aspect of the present application further provides an electronic device, comprising: a controller; a memory configured to store one or more programs, when the one or more programs are executed by the controller, to execute the above language switching method.

[0124] Please refer to Figure 8 , Figure 8FIG. 8 is a structural diagram of a computer system of an electronic device according to an example embodiment of the present application, which shows a structural diagram of a computer system of an electronic device suitable for implementing the embodiments of the present application.

[0125] It should be noted that, Figure 8 The computer system 800 of the electronic device shown is only an example and should not impose any limitation on the functions and usage range of the embodiments of the present application.

[0126] As shown, Figure 8 The computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 802 or programs loaded from a storage section 808 into a random access memory (RAM) 803, such as performing the methods in the above-described embodiments. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0127] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; the storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as necessary. A removable recording medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 810 as necessary, so that a computer program read out therefrom is installed in the storage section 808 as necessary.

[0128] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from a removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the various functions defined in the system of the present application are executed.

[0129] It should be noted that the computer-readable medium shown in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable computer program. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0130] The flowcharts and block diagrams in the drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may be executed in the reverse order, depending on the functionality involved. It will also be noted that each block of the block diagrams or flowcharts, and combinations of blocks in the block diagrams or flowcharts, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.

[0131] The units described in the embodiments of the present application can be implemented by software, or by hardware, or by a combination of software and hardware. The units described can also be located in a single processor. In some cases, the names of the units do not constitute a limitation on the units themselves.

[0132] Another aspect of the present application provides a computer readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the language switching method as described above. The computer readable storage medium can be included in the electronic device as described in the embodiments above, or can exist separately from the electronic device.

[0133] Another aspect of the present application provides a computer program product or computer program, which comprises computer instructions. The computer instructions are stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the language switching method provided in the embodiments above.

[0134] According to an aspect of an embodiment of the present application, a computer system is also provided, which includes a central processing unit (CPU) that can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage section into a random access memory (RAM), such as performing the method in the above-described embodiments. In the RAM, various programs and data required for system operation are also stored. The CPU, the ROM, and the RAM are connected to each other through a bus. An input / output (I / O) interface is also connected to the bus.

[0135] Connected to the I / O interface are an input section including a keyboard, a mouse, etc.; an output section including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section including a hard disk, etc.; and a communication section including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as necessary. A removable recording medium, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is attached to the drive as necessary, so that a computer program read out therefrom is installed into the storage section as necessary.

[0136] The above-described content is merely a preferred exemplary embodiment of the present application, and is not intended to limit the implementation of the present application. Those skilled in the art can easily make corresponding modifications or variations according to the main idea and spirit of the present application, and the protection scope of the present application should be subject to the protection scope required by the claims.

Claims

1. A method for switching the language of a virtual page, characterized in that: The language switching method comprises: In response to the language switching instruction, the page layer of each subview and the distance between the center of each subview and the center of the current virtual page are determined; the page layer of each subview and the corresponding distance value are multiplied by their respective preset weight coefficients to obtain two products corresponding to each subview; the two products corresponding to each subview are summed to obtain a sum value corresponding to each subview, and a real-time order is determined based on the sum value corresponding to each subview; the subviews in the current virtual page are traversed based on the real-time order, and the traversed subview is used as a target subview; wherein the language switching instruction specifies a target switching language; If the text language in the target subview is different from the target switching language, the text language in the target subview is converted to the target switching language, and the target switching language is used as the default language so that the target switching language is displayed by default when a new virtual page is created.

2. The language switching method according to claim 1, wherein: The converting the text language in the target subview into the target switching language further includes: Determine the resource code corresponding to the text resource of the text language in the target subview; Determine the target text resource corresponding to the resource code in the text resource directory corresponding to the target switching language; wherein the language of the target text resource is the target switching language, and text resources with the same meaning in different languages ​​have the same resource code; The text resource in the target subview is replaced with the target text resource, so as to convert the text language in the target subview into the target switching language.

3. The language switching method according to claim 1, wherein: The language switching method further includes: Construct text resource directories corresponding to different text languages, and encode the files in each text resource directory so that each file corresponds to a resource code; The text resources with the same meaning are stored in files in the text resource directories corresponding to different text languages, so that the resource encodings corresponding to the text resources with the same meaning in different text resource directories are the same.

4. The language switching method according to claim 1, wherein: The language switching method further includes: Detecting whether the text resource directory corresponding to the text language in the target subview is the same as the text resource directory corresponding to the target switching language; If they are the same, it indicates that the text language in the target subview is the same as the target switching language; If they are different, it indicates that the text language in the target sub-view is different from the target switching language.

5. The language switching method according to any one of claims 1 to 4, characterized in that: The language switching method is applied to the current interface of the Android application; Before converting the text language in the target subview into the target switching language, the language switching method further includes: Detecting whether the interface corresponding to the target subview is a preset interface; wherein the preset interface corresponds to a view that can load text resources; If yes, a switching message is sent to a preset message event function, so that the preset message event function calls a language switching function for switching the text language in the target subview.

6. The language switching method according to claim 5, wherein: The language switching method further includes: If it is detected that the text language of all subviews in the current interface is converted to the target switching language, the text language of all subviews in the historical interface is converted to the target switching language; wherein the historical interface is the interface covered by the current interface.

7. A language switching device for a virtual page, characterized in that: The switching device comprises: a response module, configured to, in response to a language switching instruction, determine the page layer in which each subview is located and the distance between the center of each subview and the center of the current virtual page; perform a product operation on the page layer in which each subview is located and the corresponding distance value with the respective corresponding preset weight coefficients to obtain two products corresponding to each subview; perform a sum operation on the two products corresponding to each subview to obtain a sum value corresponding to each subview, and determine a real-time order based on the size of the sum value corresponding to each subview; traverse the subviews in the current virtual page based on the real-time order, and use the traversed subview as a target subview; wherein the language switching instruction specifies a target switching language; The switching module is used to convert the text language in the target subview into the target switching language if the text language in the target subview is different from the target switching language, and use the target switching language as the default language so that the target switching language is displayed by default when a new virtual page is created.

8. An electronic device, characterized in that: include: Controller; The memory is used to store one or more programs, and when the one or more programs are executed by the controller, the controller implements the language switching method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the language switching method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Multi-language switching method and device, electronic equipment, storage medium and program product

    CN117056001A

  • Interface style editing method and device, medium and equipment

    CN117289918A