translations are not updated after calling i18n.bindtextdomain

Bug #1220395 reported by Sam Segers
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu UI Toolkit
Fix Released
Undecided
Unassigned
ubuntu-ui-toolkit (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When using i18n.tr, the stings don't get updated after you call i18n.bindtextdomain to set the directory for where to search for translations. This is needed to put translations in Click packages.

Tags: i18n

Related branches

Revision history for this message
Tim Peeters (tpeeters) wrote :

 we monitor signals for when the domain or language is changed, and redraw everything when that happens so new translated strings are used, but this is not the case for the textdomain

Changed in ubuntu-ui-toolkit:
status: New → Confirmed
status: Confirmed → New
Revision history for this message
Tim Peeters (tpeeters) wrote :

I'm referring to this code in plugin.cpp:
    static ContextPropertyChangeListener i18nChangeListener(context, "i18n");
    QObject::connect(&UbuntuI18n::instance(), SIGNAL(domainChanged()),
                     &i18nChangeListener, SLOT(updateContextProperty()));
    QObject::connect(&UbuntuI18n::instance(), SIGNAL(languageChanged()),
                     &i18nChangeListener, SLOT(updateContextProperty()));

and the EMITs in i18n.cpp:
void UbuntuI18n::setDomain(QString domain) {
    m_domain = domain;
    C::textdomain(domain.toUtf8().constData());
    Q_EMIT domainChanged();
}

void UbuntuI18n::setLanguage(const QString &lang) {
    m_language = lang;
    setenv("LANGUAGE",lang.toUtf8().constData(),1);
    Q_EMIT languageChanged();
}

something similar will need to be added for bindtextdomain if we automatically want to redraw the scene when the textdomain changes.

Revision history for this message
Tim Peeters (tpeeters) wrote :

Sam, could you include a simple test project with instructions how to run it that should work but is not working? That will make it easier for us to test when we work on this? thanks!

Revision history for this message
Sam Segers (sam-sgrs) wrote :

In the example, I use i18n.tr on a couple of items. They don't change after calling i18n.bindtextdomain
I also included a test case, (make check) that fails, but shouldn't (have to be on nl or en locale for this to work and seems that export LANG="en" doesn't work.)

Revision history for this message
Sam Segers (sam-sgrs) wrote :

A temporary workaround is:
i18n.bindtextdomain(i18n.domain,"locale")
i18n.domain = i18n.domain

Revision history for this message
David Planella (dpm) wrote :

Thanks a lot Sam: your test app makes it a lot easier to test!

One thing I've noticed is that bindtextdomain does get set and gettext itself does load the translations, but they don't seem to appear in the UI.

Here's an extract of running:

  strace -e trace=open qmlscene i18n-test.qml

open("/tmp/i18n-test/locale/ca/LC_MESSAGES/i18n-test.mo", O_RDONLY) = 18
This works: Hola...

So you see that it's opening the right .mo file at the right location (I created a translation for Catalan) and it's translating it on the command line, but not on the UI.

Revision history for this message
Sam Segers (sam-sgrs) wrote :

Yes, but if you call i18n.domain = i18n.domain, the UI gets updated.
Tim Peeters already said on the IRC that domain changed connects to an other signal that updates the ui.
So if we just add a new signal to UbuntuI18n called textDomainChanged or so and emit it in domainChanged method and do in plugin.cpp:
void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
    ...

    QObject::connect(&UbuntuI18n::instance(), SIGNAL(textDomainChanged()),
                     &i18nChangeListener, SLOT(updateContextProperty()));

Or just emit domainChanged from bindtextdomain method in UbuntuI18n.

Wouldn't that do it?

David Planella (dpm)
tags: added: i18n
Revision history for this message
Cris Dywan (kalikiana) wrote :

I think Sam's suggestion is sensible - there is no property involved so we should just emit domainChanged.

Note there's a separate bug 1233071 so that all apps don't need to bind the click package folder just to get it working.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:ubuntu-ui-toolkit at revision None, scheduled for release in ubuntu-ui-toolkit, milestone Unknown

Changed in ubuntu-ui-toolkit:
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-ui-toolkit - 0.1.46+13.10.20131007-0ubuntu1

---------------
ubuntu-ui-toolkit (0.1.46+13.10.20131007-0ubuntu1) saucy; urgency=low

  [ Zoltán Balogh ]
  * Add default tools (LP: #1233709). (LP: #1233709)

  [ Loïc Molinari ]
  * Added URI handler support.
  * Fixed UbuntuShape warnings when using a ShaderEffectSource as an
    image.

  [ <email address hidden> ]
  * Added test cases for text field testing.
  * Minor change to make the OptionSelector more testable by adding
    objectName property to uniquely identify the object. (LP: #1234020)

  [ Christian Dywan ]
  * Set offline storage path and add a unit test. (LP: #1231863)
  * Emit domainChanged from bindtextdomain to trigger updates. (LP:
    #1220395)
  * Support TextArea used with an action.
  * Support option selector used with an action.
  * Add haptic feedback to AbstractButton. (LP: #1189537)

  [ Zsombor Egri ]
  * Fix Picker module deployment.
  * index property added to Tab to be able to reference the Tab number.
    Fixes bug #1233402. (LP: #1233402)

  [ Jussi Pakkanen ]
  * Adds thumbnailer image provider.

  [ Christopher Lee ]
  * Preparing autopilot tests for an upcoming update in autopilot 1.3.

  [ Andrea Cimitan ]
  * Export a position value of the toolbar through dbus, setting the
    value of the dbus service created by the shell. (LP: #1224480)

  [ Guenter Schwann ]
  * Better handle the case of dismissing the OSK and focusing the text
    again fixes LP: #1228155. (LP: #1228155)

  [ Renato Araujo Oliveira Filho ]
  * Added "confirmRemoval" in ListItem.Empty This will ask for
    confirmation before remove the item. (LP: #1213046)
  * Disabled confirmation on swipe to delete as default.

  [ Leo Arias ]
  * index property added to Tab to be able to reference the Tab number.
    Fixes bug #1233402. (LP: #1233402)

  [ Ubuntu daily release ]
  * Automatic snapshot from revision 786
 -- Ubuntu daily release <email address hidden> Mon, 07 Oct 2013 04:36:33 +0000

Changed in ubuntu-ui-toolkit (Ubuntu):
status: New → Fix Released
Zoltan Balogh (bzoltan)
Changed in ubuntu-ui-toolkit:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.