← Back to team overview

ubuntu-phone team mailing list archive

Testing Translations

 

Hi all,

I recently added translations to my QML app, and I'm trying to test them now. But I'm having trouble getting even a basic case to work. Can someone say what I'm doing wrong?

I've attached a sample program that demonstrates my confusion. It reports the selected language, sets a bogus domain, and translates the string "Done" twice, once with tr() and once with dtr() and the "apt" domain. Then it sets i18n.domain = "apt" and does both translations again. Here's what I get:

$ LANGUAGE=es qmlscene i18n.qml
Language: en_US.UTF-8
Dummy domain set
  tr: Done
  dtr: Listo
Correct domain set
  tr: Done
  dtr: Done

Note that the language is not detected, but the first call of dtr() gets the translation correct. (The first call of tr() should, and does, fail.) However, when the domain is set, neither translation works.

I can also do:

$ LANG=es qmlscene i18n.qml

(process:26027): Gtk-WARNING **: Locale not supported by C library.
	Using the fallback 'C' locale.
Language:
Dummy domain set
  tr: Done
  dtr: Done
Correct domain set
  tr: Done
  dtr: Done

The same thing happens when setting LC_ALL or LC_MESSAGES. FWIW, a simple Python script [1] works with no problems.

Can someone point out what I'm doing wrong? I'm using 14.04 with the SDK team PPA, if that matters.

Robert

[1] Namely,
import gettext
gettext.textdomain("apt")
print gettext.gettext("Done"), gettext.dgettext("apt", "Done")


import QtQuick 2.0
import Ubuntu.Components 0.1

Item {
    Component.onCompleted: {
        console.log("Language:", i18n.language);
        i18n.domain = "blah";
        console.log("Dummy domain set");
        console.log("  tr:", i18n.tr("Done"))
        console.log("  dtr:", i18n.dtr("apt", "Done"));
        i18n.domain = "apt";
        console.log("Correct domain set");
        console.log("  tr:", i18n.tr("Done"))
        console.log("  dtr:", i18n.dtr("apt", "Done"));
    }
}

Follow ups