IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Using lrelease

Qt Linguist Manual.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Using lrelease

The lrelease command line tool produces QM files out of TS files. The QM file format is a compact binary format that the localized application uses. It provides extremely fast lookup for translations.

When building with qmake, specify the files to process at the command line or in a .pro file.

When building with CMake, use CMake commands to add targets that create or update TS files and transform them into QM files. The lrelease tool is run with the options you pass to the commands when you build the target.

Run lrelease whenever you want to release the application, from the initial test version through to the final release version. The application does not need QM files to run, but if they are available, the application detects them and uses them automatically.

The lrelease tool only incorporates translations that you mark as finished. Otherwise, it uses the original text instead.

I. lrelease syntax

 
Sélectionnez
lrelease [options] -project project-file
lrelease [options] ts-files [-qm qm-file]

Where:

  • options means one or several lrelease options.

  • project-file is the project configuration file.

  • ts-files are the TS files to use as input for the QM files.

  • qm-file is the name of the QM file to generate.

Passing .pro files to lrelease is deprecated. Use the lrelease-pro tool or the lrelease.prf feature when using qmake.

To view the latest help, enter:

 
Sélectionnez
lrelease -help

I-1. lrelease options

Option

Action

-help

Display up-to-date help information and exit.

-idbased

Use IDs instead of source strings for message keying.

-compress

Compress the QM files.

-nounfinished

Do not include unfinished translations.

-removeidentical

If the translated text is the same as the source text, exclude the message.

-markuntranslated <prefix>

If a message has no real translation, use the source text prefixed with the given string instead.

-project <filename>

Name of a file containing the project's description in JSON format. You can use the lprodump tool to generate the file from a .pro file.

-silent

Do not explain what is being done.

-version

Display the version of lrelease and exit.

II. Examples

 

II-1. Using lrelease with CMake

When building with CMake, use CMake commands to add translations on targets to the CMakeLists.txt file, and then build the targets.

Select one of the following options:

Build a target (for example, app_lrelease) to update the .qm files for it. To update the .qm files for all targets, build the target release_translations.

II-2. Using lrelease with qmake

To run lrelease without specifying a project file:

 
Sélectionnez
lrelease.exe main_en.ts languages\main_fr.ts

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+