Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

Qt Linguist Manual: Release Manager

Two tools are provided for the release manager, lupdate and lrelease. These tools depend on qmake project files. You don't have to use qmake, though.

Qt Project Files

lupdate and lrelease depend on information in the application's .pro Qt project file. There must be an entry in the TRANSLATIONS section of the project file for each language that is additional to the native language. A typical entry looks like this:

 TRANSLATIONS = arrowpad_fr.ts \
                arrowpad_nl.ts

Using a locale within the translation file name is useful for determining which language to load at runtime. This is explained in the Programmers chapter.

An example of a complete .pro file with four translation source files:

 HEADERS         = main-dlg.h \
                   options-dlg.h
 SOURCES         = main-dlg.cpp \
                   options-dlg.cpp \
                   main.cpp
 FORMS           = search-dlg.ui
 TRANSLATIONS    = superapp_dk.ts \
                   superapp_fi.ts \
                   superapp_no.ts \
                   superapp_se.ts

QTextCodec::setCodecForTr() makes it possible to choose a 8-bit encoding for literal strings that appear within tr() calls. This is useful for applications whose source language is, for example, Chinese or Japanese. If no encoding is set, tr() uses Latin1.

If you do use the QTextCodec::codecForTr() mechanism in your application, Qt Linguist needs you to set the CODECFORTR entry in the .pro file as well. For example:

 CODECFORTR      = ISO-8859-5

Also, if your compiler uses a different encoding for its runtime system as for its source code and you want to use non-ASCII characters in string literals, you will need to set the CODECFORSRC. For example:

 CODECFORSRC     = UTF-8

Microsoft Visual Studio 2005 .NET appears to be the only compiler for which this is necessary. However, if you want to write portable code, we recommend that you avoid non-ASCII characters in your source files. You can still specify non-ASCII characters portably using escape sequences, for example:

 label->setText(tr("F\374r \310lise"));

lupdate

Usage: lupdate myproject.pro

This is a simple command line tool. lupdate reads a Qt .pro project file, finds the translatable strings in the specified source, header and Qt Designer interface files, and produces or updates the .ts translation files listed in the project file. The translation files are given to the translator who uses Qt Linguist to read the files and insert the translations.

Companies that have their own translators in-house may find it useful to run lupdate regularly, perhaps monthly, as the application develops. This will lead to a fairly low volume of translation work spread evenly over the life of the project and will allow the translators to support a number of projects simultaneously.

Companies that hire in translators as required may prefer to run lupdate only a few times in the application's life cycle, the first time might be just before the first test phase. This will provide the translator with a substantial single block of work and any bugs that the translator detects may easily be included with those found during the initial test phase. The second and any subsequent lupdate runs would probably take place during the final beta phase.

The .ts file format is a simple human-readable XML format that can be used with version control systems if required.

Qt Linguist is also able to import and export XML Localization Interchange File Format (XLIFF) files, making it possible to take advantage of tools and translation services that work with this format.

Pass the -help option to lupdate to obtain the list of supported options:

 Usage:
     lupdate [options] [project-file]
     lupdate [options] [source-file|path]... -ts ts-files
 Options:
     -help  Display this information and exit.
     -noobsolete
            Drop all obsolete strings.
     -extensions <ext>[,<ext>]...
            Process files with the given extensions only.
            The extension list must be separated with commas, not with whitespace.
            Default: 'ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx'.
     -silent
            Don't explain what is being done.
     -version
            Display the version of lupdate and exit.

lrelease

Usage: lrelease myproject.pro

This is another simple command line tool. It reads a Qt .pro project file and produces the .qm files used by the application, one for each .ts translation source file listed in the project file. The .qm file format is a compact binary format that provides extremely fast lookups for translations.

This tool is run whenever a release of the application is to be made, from initial test version through to final release version. If the .qm files are not created, e.g. because an alpha release is required before any translation has been undertaken, the application will run perfectly well using the text the programmers placed in the source files. Once the .qm files are available the application will detect them and use them automatically.

Note that lrelease will only incorporate translations that are marked as "done". If a translation is missing, or has failed validation, the original text will be used instead.

Pass the -help option to lrelease to obtain the list of supported options:

     Usage:
         lrelease [options] project-file
         lrelease [options] ts-files [-qm qm-file]
     Options:
         -help  Display this information and exit
         -compress
                Compress the .qm files
         -nounfinished
                Do not include unfinished translations
         -silent
                Don't explain what is being done
         -version
                Display the version of lrelease and exit

Missing Translations

Both lupdate and lrelease may be used with .ts translation source files which are incomplete. Missing translations will be replaced with the native language phrases at runtime.

[Previous: Qt Linguist Manual] [Contents] [Next: Qt Linguist Manual: Translators]

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Extension de Qt WebKit

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web