01-03-2013 09:15 PM
I'm using the tr() function to wrap the strings I need to localize. They are not being picked and added to to generated and updated ts files. Are there additional steps required when configuring the project to have the C++ files scanned in addition to the QML files. Everything else is working correctly.
01-04-2013 07:14 AM
Yes, the files are being created but they only contain the localized strings I've identified from the qml files. My strings identified in the c++ sources using tr() are not being merged in.
01-04-2013 07:23 AM
I just got it to work but I don't think my approach is quite right. I updated the config.pri file as follows (in bold):
# Auto-generated by IDE. All changes by user will be lost!
# Created at 1/4/13 6:53 AM
BASEDIR = $$_PRO_FILE_PWD_
INCLUDEPATH += \
SOURCES += \
HEADERS += \
CONFIG += precompile_header
PRECOMPILED_HEADER = $$BASEDIR/precompiled.h
SOURCES = \
TRANSLATIONS = \
I manually added the lupdate_inclusions to include my c++ sources so that they are relative to the translations folder from where the lupdate command gets executed. The changes will get lost the next time the IDE generates or updates the config.pri files. So, its an ugly hack at best. I think there is a bug here unless I'm missing something.
I'm posting in case someone else runs into this.
01-04-2013 07:44 AM
Yes, I did. I set up the languages I reuqired etc. The ts files only contained the qml identified strings. The ones marked by the use of qsTr. My cpp strings, those marked by tr() did not get picked up. Looks like the cpp files were not correctly being picked up. I fixed the issue as per my last post by updating the config.pri file. Its a hack because I will lose the changes once the IDE updates that file, so it is not an ideal solution. I think it is a bug.
01-04-2013 08:03 AM
I made a test and you're right, It doesn't get them.
It should be somethinng like this according to Localization:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.0" language="en_GB"> <context> <name>main</name> <message> <location filename="../assets/app.cpp" line="6"/> <source>My String</source> <comment>My Context</comment> <translation type="unfinished"></translation> </message> <message> <location filename="../assets/main.qml" line="12"/> <source>Hello world</source> <translation type="unfinished"></translation> </message> </context> </TS>
In my case location tag isn't there.