How Translation Files Work in xTuple

 

Qt allows you to load language translation files into an application at run-time. The result is that application text (i.e., screen titles, field labels, help files, etc.) will be displayed in the language of the translation file. Qt handles this internally by using a tr() function. This function wraps any literal text found in an application and allows for dictionary lookup and replacements to be performed at run time. These tr()'s are also used to identify text needed to build the translation files.

There are two files used for the translation process:

  1. the first is a .ts file
  2. the second is a .qm file.

The .ts file is the translation source files. This file is an XML based file which can be updated and edited using the lupdate and Qt Linguist tools. Every instance of text in an application that is translated has its own context, source, and translation field. The context changes usually from screen-to-screen and allows you to have two identical texts translated differently in different contexts. The translation field includes the text you want to show in place of the source text for a given context.

The .qm file is created from the .ts file using the lrelease tool and is a more compact and efficient file used by the application at run-time. Once the .qm file is generated, the OpenMFG application can be made to use it simply by using the system's Locale configuration. In practice, when a user logs into OpenMFG using a specified Locale, the language (i.e., translation) corresponding to that Locale will be displayed. In addition, the application supports the placement of a translation file called default.qm in the same directory as the executable. If a system is set up this way, OpenMFG will use that default file and no additional configuration will be required. When do I use “Override Warnings”? If you receive a warning when you submit a translation, you may have missed a required character, such as ampersand or ellipsis. Check to make sure you have included these characters if they are required. There may be cases where the warnings are incorrect for the specific language you are translating, in which case you should check the Override Warnings box and submit the translation again.