APPARATUSES, METHODS, AND COMPUTER PROGRAM PRODUCTS FOR AUTOMATIC INTERNATIONALIZATION OF GRAMMATICAL OUTPUT
Apparatuses, methods, and computer program products are provided for automatically internationalizing grammatical output for presentation to a user of a program based on the user's locale. In particular, AST transformations are described that cause a compiler to generate a programming method during compilation of a portion of source code containing a predefined token, where the programming method is incorporated (by the compiler) into a file produced by the compiler and serves to call an instance of a message bundle file that provides translation of grammatical output without requiring the programmer/developer to manually incorporate individual message bundles into each portion of source code to be internationalized.
In computer programming, internationalization (also known as National Language Support, Native Language Support, NLS, or i18n) is a term used to describe the adaptation of computer software to accommodate different languages and regional differences. The process of internationalization during software application design allows the software application to potentially be adapted to various languages and regions without necessarily requiring engineering changes.
At its most basic level, internationalization involves the translation of words and phrases—the grammatical output of a software application that is presented to the user on a display of an electronic device running the software application. Internationalization can involve more than just translation, however, as there can be various other differences in grammatical output from one locale to the next. Such differences can include differences in dialect or word choice (e.g., considering French spoken in France versus French spoken in Canada); formatting of numbers (punctuation, date formatting, etc.); visual presentation of text considering writing direction (left to right versus right to left); capitalization, punctuation, and/or pluralization rules; units of measurement; and so on.
Considering the amount of grammatical output that is generated for certain software applications, there is a need for a more efficient, less time consuming, and more easily manageable mechanism for internationalizing grammatical output, such as for software applications used in the healthcare industry.
BRIEF SUMMARYAccordingly, improved apparatuses, methods, and computer program products for automatically internationalizing grammatical output are provided. In particular, Abstract Syntax Tree (AST) transformations are described that cause a compiler to generate a programming method during compilation of a portion of source code containing a predefined token, where the programming method is incorporated (by the compiler) into a file produced by the compiler and serves to call an instance of a message bundle file that provides translation of grammatical output without requiring the computer programmer/software developer to manually write, incorporate, and execute such programming methods for each portion of source code to be internationalized.
Accordingly, in some embodiments, an apparatus for automatically internationalizing grammatical output for presentation to a user of a program based on the user's locale is provided, where the apparatus comprises at least one processor and at least one memory including computer program code. The at least one memory and the computer program code may be configured to, with the processor, cause the apparatus to at least modify an Abstract Syntax Tree (AST) in response to compilation by a compiler of a predefined AST transformation and compile a portion of source code for generating grammatical output to a user of a program following compilation of the predefined AST transformation, wherein the portion of source code comprises a predefined token. A modified node of the AST may be referenced during compilation of the portion of source code in response to compiling the predefined token, and a programming method may be generated in response to referencing the modified node of the AST during compilation of the portion of source code. The programming method may be incorporated into a file produced by the compiler, where the programming method is configured to call an instance of a message bundle file, and where the message bundle file is configured to define an entry key value in a natural language based on a locale of the user.
In some embodiments, the at least one memory and the computer program code may be further configured to, with the processor, cause the apparatus to compile a second portion of source code for generating a grammatical output to a user of a different program following the compilation of the predefined AST transformation. Additionally or alternatively, the at least one memory and the computer program code may be further configured to, with the processor, cause the apparatus to further modify the AST in response to compilation by the compiler of a second predefined AST transformation.
In some cases, the AST transformation may be a Groovy AST transformation. The compiler may be a Groovy compiler, and the file into which the programming method is incorporated may be a class file. In some embodiments, the message bundle file may be configured to define an entry key value in any one of at least three natural languages comprising at least one of English, French, or Spanish. Moreover, the entry key value may be presented to a user as part of a user interface of a healthcare application.
In other embodiments, a method and a computer program product for automatically internationalizing grammatical output for presentation to a user of a program based on the user's locale are provided. The method and/or computer program product may include modifying an Abstract Syntax Tree (AST) in response to compilation by a compiler of a predefined AST transformation and compiling a portion of source code for generating grammatical output to a user of a program following compilation of the predefined AST transformation, wherein the portion of source code comprises a predefined token. The method and/or computer program product may further include referencing a modified node of the AST during compilation of the portion of source code in response to compiling the predefined token; generating a programming method in response to referencing the modified node of the AST during compilation of the portion of source code; and incorporating a programming method into a file produced by the compiler, where the programming method is configured to call an instance of a message bundle file, and where the message bundle file is configured to define an entry key value in a natural language based on a locale of the user.
In some embodiments, the method and/or computer program product may include compiling a second portion of source code for generating a grammatical output to a user of a different program following the compilation of the predefined AST transformation. Additionally or alternatively, the method and/or computer program product may further modify the AST in response to compilation by the compiler of a second predefined AST transformation.
In some cases, the AST transformation may be a Groovy AST transformation. The compiler may be a Groovy compiler, and the file into which the programming method is incorporated may be a class file. In some embodiments, the message bundle file may be configured to define an entry key value in any one of at least three natural languages comprising at least one of English, French, or Spanish. Moreover, the entry key value may be presented to a user as part of a user interface of a healthcare application.
Having thus described the invention in general terms, reference will now be made to the accompanying drawings, which are not necessarily drawn to scale, and wherein:
Embodiments of the present invention now will be described more fully hereinafter with reference to the accompanying drawings, in which some, but not all embodiments of the invention are shown. Indeed, embodiments of this invention may be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will satisfy applicable legal requirements. Like reference numerals refer to like elements throughout.
Although the description that follows may include examples in which embodiments of the invention are used in the context of healthcare organizations, such as hospitals and pharmacies, it is understood that embodiments of the invention may be applied to software applications used in numerous settings, including in other types of healthcare organizations and in organizations outside the field of healthcare. Moreover, embodiments of the invention may be used for the internationalization of software applications used by individual users outside the context of an organization, such as for personal or residential use.
In general, a software application is a software program (e.g., executable software consisting of compiled code that can run directly from a computer's operating system) that provides a specific group of functions to the user. For example, a word processing application is a software program that is designed with functionality that allows a user to create a written document. As another example, an email application is a software program that is designed with functionality that allows a user to receive, read, and store emails, reply to received emails, and draft and send new emails. In the context of an organization, such as a healthcare organization (e.g., a hospital, pharmacy, clinic, etc.), an educational institution (e.g., a university), or a business (e.g., a corporation), applications may be used to enable or facilitate the daily work activities of members of the organization. In a hospital setting, for example, an application may be used by the medical staff (doctors, nurses, technicians, pharmacists, etc.) to access patient medical histories, enter orders for medications to be administered to the patients, record the time, dosage, etc. of medication administered to a patient, schedule appointments, record insurance and billing information, enter notes, etc.
To enable user interaction and provide data to the user, most software applications produce grammatical output, such as in the form of audible output (e.g., via speakers of an electronic device) or textual output (e.g., via a display presenting a graphical user interface, or GUI). For example, a screen 100 may be presented on a display 102 of an electronic device, such as on a computer monitor or a laptop display, that provides a prompt to the user to enter a patient's last name 104 and provide the patient's date of birth 106, as shown in
Depending on the user's locale where the software application is used, the information provided on the display 102 may be presented in different natural (e.g., human-readable) languages. For example, the user of the system shown in
In conventional computer programming, internationalization to allow grammatical output, such as the prompts 104, 106 of
For example, a message bundle for providing the first prompt 104 of
Typically, a message bundle must be manually written by a software program developer for each statement or sentence that is to be presented on the display. For software applications with large amounts of data to present, numerous message bundles must be created and included in the source code to allow the appropriate statements (in the correct natural language) to be presented based on the user's locale. In other words, each screen of the user interface of the software application will have source code that includes one or more message bundles for enabling locale-specific statements to be presented to the user.
In addition to the tedious nature of writing each message bundle to represent multiple translations of a statement for each occurrence of that statement in the presentation of the software application, any changes to a part of the software application (e.g., an update to a particular screen or set of screens provided by the application) would require corresponding changes to the message bundles involved with presentation of those screens. Thus, along with the laborious and time-intensive nature of creating and maintaining the various message bundles comes the risk that one or more of the message bundles may be missed during the update and/or that inconsistent translations, spellings, etc. may be used in message bundles in different portions of the source code.
Accordingly, embodiments of an apparatus, method, and computer program product are described herein that provide for the automatic internationalization of grammatical output for presentation using AST transformations that cause a compiler to generate a programming method (e.g., a procedure associated with an object class of the source code that represents behavior of the object) for calling a message bundle file. The automatic generation and insertion of the programming method by the compiler eliminates the need for a program developer to manually include message bundles in the source code corresponding to every statement that needs to be internationalized for presentation on a user interface by automatically directing the access of the appropriate message bundle to return the particular translation based on the user's locale.
With reference now to
In some embodiments, the apparatus 200 may comprise at least one processor 220, which may be embodied in a number of different ways. For example, the processor 220 may be a coprocessor, a microprocessor, a controller, or various other processing circuitry including integrated circuits. In some embodiments, the processor 220 may include one or more processing cores configured to perform independently. Additionally or alternatively, the processor 220 may include one or more processors configured in tandem via a bus to enable independent execution of instructions, pipelining and/or multithreading. Accordingly, although illustrated in
The apparatus 200 may further comprise at least one memory 230, and the processor 220 may be configured to execute instructions stored in the memory 230 or that are otherwise accessible to the processor. In embodiments in which the processor is embodied as an executor of software instructions, the instructions may specifically configure the processor to perform the algorithms and/or operations described herein when the instructions are executed. The memory 230, which may include volatile memory, such as volatile Random Access Memory (RAM) and/or non-volatile memory, may store any of a number of pieces of information and data, including software programs, libraries, databases, applications, repositories of data, files, etc. that are used by the apparatus 200 to implement the functions described herein. Although illustrated in
With continued reference to
Referring to
As an example, in the case of a Java compiler (e.g., a compiler for the Java programming language), the output may be a Java class file. In the case of a Groovy compiler (e.g., a compiler for the Groovy programming language that can be used as a scripting language for the Java platform), the output may be Java Virtual Machine (JVM) bytecode.
The output may then be used to create an executable program, such as a software application for a healthcare provider or other organization. That executable program may be accessed from the server 300 by a user via a user device 330 at a client site (e.g., a pharmacy technician at a hospital), and the software application may run on the user device 330 or may otherwise generate a user interface that is presented on the user device such that the user is able to view and interact with data presented at the user device. In this regard, the user device 330 may be a computer, such as a laptop or a desktop computer, a tablet computer, or any other computing device that a user can interact with to access, view, and manipulate data provided by the software application. For example, the user may, in some cases, access the software application through communication between the user device and the server 300 over the Internet or an intranet, such as via a webpage interface. Accordingly, as described herein, depending on the locale of the user (e.g., where the client site is located), embodiments of the invention allow the information presented to the user via the user device 330 to be provided in the correct language, format, etc.
In particular, in some embodiments, the apparatus 200 for automatically internationalizing grammatical output comprises at least one processor 220 and at least one memory 230 including computer program code, as shown in
A schematic representation of an AST 400 is provided in
As noted above, the at least one memory and the computer program code may be configured to, with the processor, cause the apparatus to at least modify an AST in response to compilation by a compiler of a predefined AST transformation. In this regard, the AST transformation may be a portion of code (e.g., written in the Groovy programming language) that is configured to customize the AST before the compiler references the AST to compile the source code for the software program. The AST transformation may be predefined in that it is written or otherwise created or obtained by the developer prior to compilation of the source code for the software program. After the AST transformation is compiled, it may be added to the class path of the compiler. As a result, the AST representing the software program source code being compiled may be modified, such as by modifying a node 410 of the AST. For example, the AST transformation may result in Node D of the AST being modified (represented in
Following compilation of the predefined AST transformation (e.g., after the AST has been modified), a portion of source code for generating grammatical output to a user of a program may be compiled. That portion of source code may include a predefined token, or annotation in some cases, and compilation of the predefined token may result in the modified node of the AST being referenced during compilation of the portion of source code including that predefined token. For example, an annotation called @MsgBundle may be included in the source code (e.g., at the top of a class), and each time the compiler comes across this annotation in the portion of source being compiled, the compiler may reference the modified node 410 of the AST 400 (e.g., Node D).
In some embodiments, that modified node 410 (e.g., Node D) may (as a result of the modification) now include instructions for a programming method to be generated and incorporated into the file produced by the compiler. In other words, a programming method may be generated in response to referencing the modified node of the AST during compilation of the portion of source code that included the token, and that programming method may be incorporated into a file produced by the compiler. In the case of a Java compiler, for example, the programming method may be written into the bytecode forming the output of the Java compiler, such as in a particular class file. This programming method may be configured to call an instance of a message bundle file from anywhere inside the class in which the programming method has been inserted, and the message bundle file may be configured to define an entry key value in a natural language based on a locale of the user. The entry key value may thus be presented to a user (in the appropriate language and/or format) as part of a software application's user interface, such as the user interface of a healthcare application, as described above and shown in
In essence, the AST transformation ends up causing the compiler to autonomously (e.g., without the direct intervention of the developer) write the tedious source code that obtains the message bundle instance and interacts with it to effect the appropriate internationalization of the portion of source code involved. Accordingly, when a message bundle key (e.g., “misc.patient name” in the example above) is fed to the programming method that has been automatically incorporated into the class (by the compiler), the programming method will return the appropriate translation for “misc.patient name” based on the user's locale using the appropriate message bundle. In some embodiments, for example, the message bundle file may be configured to define an entry key value in any one of at least three natural languages, including English, French, and/or Spanish.
In some embodiments, the at least one memory and the computer program code may be further configured to, with the processor, cause the apparatus to compile a second portion of source code for generating a grammatical output to a user of a different program following the compilation of the predefined AST transformation. For example, if the software program the user will be accessing and interacting with needs to be changed (e.g., updated to a new version or otherwise modified to add or change features of the program), the source code corresponding to the new (e.g., updated) program may be compiled, and the modified node of the AST (due to the original, previously compiled AST transformation) may again be referenced during compilation of this second portion of source code to effect automatic internationalization of the program as needed.
Similarly, in some cases, the at least one memory and the computer program code may be further configured to, with the processor, cause the apparatus to further modify the AST in response to compilation by the compiler of a second predefined AST transformation. For example, if the developer wishes to incorporate new programming methods, e.g., calling on additional message bundles or implementing other processes, a second predefined AST transformation may be compiled, resulting in a further modification of the AST. Thus, an additional or different node of the AST may be modified, or further modifications may be made to the previously modified node, as a result of compilation of the second predefined AST transformation.
Referring now to
In some embodiments, a second portion of source code for generating a grammatical output to a user of a different program may be compiled following the compilation of the predefined AST transformation. Additionally or alternatively, the AST may be further modified in response to compilation by the compiler of a second predefined AST transformation.
Example embodiments of the present invention have been described above with reference to block diagrams and flowchart illustrations of methods, apparatuses, and computer program products. In some embodiments, certain ones of the operations above may be modified or further amplified as described below. Furthermore, in some embodiments, additional optional operations may be included. Modifications, additions, or amplifications to the operations above may be performed in any order and in any combination.
It will be understood that each operation, action, step and/or other types of functions shown in the diagram (
For example, program code instructions associated with
The program code instructions stored on the programmable apparatus may also be stored in a non-transitory computer-readable storage medium that can direct a computer, a processor (such as processor 220) and/or other programmable apparatus to function in a particular manner to thereby generate a particular article of manufacture. The article of manufacture becomes a means for implementing the functions of the actions discussed in connection with, e.g.,
Many modifications and other embodiments of the inventions set forth herein will come to mind to one skilled in the art to which these inventions pertain having the benefit of the teachings presented in the foregoing descriptions and the associated drawings. Therefore, it is to be understood that the inventions are not to be limited to the specific embodiments disclosed and that modifications and other embodiments are intended to be included within the scope of the appended claims. Although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation.
Claims
1. An apparatus for automatically internationalizing grammatical output for presentation to a user of a program based on the user's locale, the apparatus comprising at least one processor and at least one memory including computer program code, the at least one memory and the computer program code configured to, with the at least one processor, cause the apparatus to at least:
- modify an Abstract Syntax Tree (AST) in response to compilation by a compiler of a predefined AST transformation;
- compile a portion of source code, wherein the portion of source code is configured for generating grammatical output to the user of a program following compilation of the predefined AST transformation, wherein the portion of source code comprises a predefined token;
- reference a modified node of the AST during compilation of the portion of source code in response to compiling the predefined token;
- generate a programming method in response to referencing the modified node of the AST during compilation of the portion of source code;
- incorporate the programming method into a file produced by the compiler,
- wherein the programming method is configured to call an instance of a message bundle file, and
- wherein the message bundle file is configured to define an entry key value in a natural language, wherein the natural language is based on a locale of the user.
2. The apparatus of claim 1, wherein the at least one memory and the computer program code are further configured to, with the at least one processor, cause the apparatus to compile a second portion of source code for generating a grammatical output to a user of a different program following the compilation of the predefined AST transformation.
3. The apparatus of claim 1, wherein the at least one memory and the computer program code are further configured to, with the at least one processor, cause the apparatus to further modify the AST in response to compilation by the compiler of a second predefined AST transformation.
4. The apparatus of claim 1, wherein the AST transformation is a written using Groovy programming language.
5. The apparatus of claim 1, wherein the file into which the programming method is incorporated is a class file.
6. The apparatus of claim 1, wherein the compiler is a compiler for Groovy programming language.
7. The apparatus of claim 1, wherein the message bundle file is configured to define an entry key value in any one of at least three natural languages comprising at least one of English, French, or Spanish.
8. The apparatus of claim 1, wherein the entry key value is presented to the user as part of a user interface of a healthcare application.
9. A method for automatically internationalizing grammatical output for presentation to a user of a program based on the user's locale, the method comprising:
- modifying an Abstract Syntax Tree (AST) in response to compilation by a compiler of a predefined AST transformation;
- compiling a portion of source code, wherein the portion of source code is configured for generating grammatical output to the user of a program following compilation of the predefined AST transformation, wherein the portion of source code comprises a predefined token;
- referencing a modified node of the AST during compilation of the portion of source code in response to compiling the predefined token;
- generating a programming method in response to referencing the modified node of the AST during compilation of the portion of source code;
- incorporating the programming method into a file produced by the compiler,
- wherein the programming method is configured to call an instance of a message bundle file, and
- wherein the message bundle file is configured to define an entry key value in a natural language, wherein the natural language is based on a locale of the user.
10. The method of claim 9 further comprising compiling a second portion of source code for generating a grammatical output to a user of a different program following the compilation of the predefined AST transformation.
11. The method of claim 9 further comprising further modifying the AST in response to compilation by the compiler of a second predefined AST transformation.
12. The method of claim 9, wherein the AST transformation is written using Groovy programming language.
13. The method of claim 9, wherein the file into which the programming method is incorporated is a class file.
14. The method of claim 9, wherein the entry key value is presented to the user as part of a user interface of a healthcare application.
15. A computer program product comprising at least one non-transitory computer-readable storage medium having computer-executable program code portions stored therein, the computer-executable program code portions comprising program code instructions for:
- modifying an Abstract Syntax Tree (AST) in response to compilation by a compiler of a predefined AST transformation;
- compiling a portion of source code, wherein the portion of source code is configured for generating grammatical output to a user of a program following compilation of the predefined AST transformation, wherein the portion of source code comprises a predefined token;
- referencing a modified node of the AST during compilation of the portion of source code in response to compiling the predefined token;
- generating a programming method in response to referencing the modified node of the AST during compilation of the portion of source code;
- incorporating the programming method into a file produced by the compiler,
- wherein the programming method is configured to call an instance of a message bundle file, and
- wherein the message bundle file is configured to define an entry key value in a natural language, wherein the natural language is based on a locale of the user.
16. The computer program product of claim 15 further comprising program code portions for compiling a second portion of source code for generating a grammatical output to a user of a different program following the compilation of the predefined AST transformation.
17. The computer program product of claim 15 further comprising program code portions for further modifying the AST in response to compilation by the compiler of a second predefined AST transformation.
18. The computer program product of claim 15, wherein the AST transformation is written using Groovy programming language.
19. The computer program product of claim 15, wherein the file into which the programming method is incorporated is a class file.
20. The computer program product of claim 15, wherein the entry key value is presented to the user as part of a user interface of a healthcare application.
Type: Application
Filed: Aug 26, 2015
Publication Date: Mar 2, 2017
Inventors: Bryan Self (Birmingham, AL), Preston Prewett (Sylvan Springs, AL), Josh Turner (Hueytown, AL)
Application Number: 14/836,481