Unsolved How to display text which are other than english ?
-
In my QML application i want to display text in local language ,how i can achive this.
example : suppose if i have to display "NEXT" in french ("suivant") what i have to do? please give me an example code?Button { height:50 width:50 text { anchor.centrein:parent; text:"NEXT"; } }
-
hi @divaindie
Qt has a couple of macros for that. in cpp you have tr("Your text goes in here") and in qml it is qsTr("Your text goes here")That way you can write your code in one language only, and once your finished, you extract those texts and create translations for them. Those can than be loaded at runtime later on.
For more information check the docu:
https://doc.qt.io/qt-5/internationalization.html -
@J.Hilk said in How to display text which are other than english ?:
That way you can write your code in one language only, and once your finished, you extract those texts and create translations for them. Those can than be loaded at runtime later on.
basically i want have multi language feature ? i read about internationalization but i didn't understand how it works.also somewhere people mentioned about " QTextCodec" ,iam not able to figure out which one is better.
also i want to know what are all the options available to achieve this? -
@divaindie
As @J-Hilk has pointed you to.
WrtQTextCodec
, that is just for dealing with text encodings, e.g. Western European languages use a different encoding from Asian ones. In itselfQTextCodec
has absolutely nothing to do with translating strings from one language to another, so it's not some kind of "alternative" to doing the translation work. For that you still needtr(literal-string)
macro or the https://doc.qt.io/qt-5/qtranslator.html class for dynamic look-up. -