internazionalizza le tue applicazioni

Download Internazionalizza le tue applicazioni

If you can't read please download the document

Upload: qt-day

Post on 19-May-2015

354 views

Category:

Technology


0 download

DESCRIPTION

Qt offre degli strumenti molto avanzati per internazionalizzare al meglio le applicazioni in tutto il mondo

TRANSCRIPT

2. What is i18n about?Embracing a specific national environment:LanguageLine break behaviourWriting directionConventions...without hampering development 3. (True) Horror StoryWere in 2002, and a big Italian company wants to localize their CAD program in Spanish.If only it wasnt for... 4. (True) Horror StoryStrings were initially hardcoded in Italian, English was retrofitted at some point......with lots of if/else statementsFirst try: add another else branch for eachstring in code (...)Second try: tool to produce multiple codebases one for each language (...)AFAIK still unfinished two years later 5. All we need is a good workflowDevelopers produce i18n-ready codeWith no codebase pollutionTranslators translate stringsIteratively (code and strings can change!)No technical knowledge neededThe framework does the rest 6. Developers step 1QObject::tr()Parse-time: marks stringsRun-time: translates stringsNot everything is a QObject...QCoreApplication::translate()QT_TR_NOOP 6 7. Developers step 2Use QString for all user visible textQString are Unicode strings transparentprocessing of strings (reg exp, split etc)Programmer space strings can still beQByteArrays or char * 7 8. Developers step 3Use QString::arg() for dynamic textQString::arg() allows easy argumentreordering void FileCopier::showProgress(int done, int total, const QString &currentFile) {label.setText(tr("%1 of %2 files copied.nCopying: %3").arg(done).arg(total).arg(currentFile)); }8 9. Some glueAdd a TRANSLATIONS entry to .proRun lupdate to extract a .ts fileSend .ts file to translatorsRun lrelease to produce translated binaryfilesSet up a QTranslatorQCoreApplication::installTranslator()9 10. Translators (only) stepOpen .ts file with LinguistFill the missing translationsThere is no step 3Developer: ...hey thats not fair! 10 11. Some case studiesNearing the 2.0 release:Parse again with lupdateFill only the missing translationsWanting to add a languageAdd that language to TRANSLATIONSRun lupdate, translate the new .ts file, lreleaseThis time its a fairy tale!Update language on the flyinstallTranslator sends a changeEvent11 12. Workflow demo12 13. THANKS !Develer S.r.l. Via Mugellese 1/A 50013 Campi Bisenzio Firenze - ItalyContactsMail: [email protected]: +39-055-3984627Fax: +39 178 6003614http://www.develer.com 14. Gotchas::tr assumes latin-1What about Designer files? 14