Translating Aranduka

6 views
Skip to first unread message

Andrés Gattinoni

unread,
Jul 14, 2011, 2:00:00 PM7/14/11
to aranduka...@googlegroups.com
Hi guys,

After a long time without much time to do anything I'm trying to give
some love to Aranduka.
I'm trying to implement I18N following Roberto's guide:
http://nomuerde.netmanagers.com.ar/6.html

One question. What's the appropriate way to deal with wildcards on strings?:

Traceback (most recent call last):
File "main.py", line 399, in on_books_itemActivated
self.title.setText(self.tr(u'Properties of "%s"') % item.book.title)
TypeError: unsupported operand type(s) for %: 'QString' and 'unicode'

Like this?
self.title.setText(self.tr(u'Properties of "%s"' % item.book.title))

Like this?
self.title.setText("%s %s" % (self.tr(u'Properties of'), item.book.title)))

Thanks!

A

Ramiro Algozino

unread,
Jul 14, 2011, 2:12:32 PM7/14/11
to aranduka...@googlegroups.com
2011/7/14 Andrés Gattinoni <andresg...@gmail.com>:

I do it like this:

self.title.setText(unicode(self.tr(u"Properties of %s")) % item.book.title)

But I don't know wich is the best or recommended way..

--
Ramiro Algozino
http://ramiroalgozino.com.ar/

Andrés Gattinoni

unread,
Jul 14, 2011, 2:29:03 PM7/14/11
to aranduka...@googlegroups.com
On Thu, Jul 14, 2011 at 3:12 PM, Ramiro Algozino <algo...@gmail.com> wrote:
> I do it like this:
>
> self.title.setText(unicode(self.tr(u"Properties of %s")) % item.book.title)
>
> But I don't know wich is the best or recommended way..

Thanks! I haven't thought of that. I was reviewing Marave's code and I
think Roberto does it that way too, so I'll go with that.

Ramiro Algozino

unread,
Jul 14, 2011, 2:30:23 PM7/14/11
to aranduka...@googlegroups.com
2011/7/14 Andrés Gattinoni <andresg...@gmail.com>:

glad to help! :-)

Andrés Gattinoni

unread,
Jul 14, 2011, 3:56:58 PM7/14/11
to aranduka...@googlegroups.com
For some reasong I'm not being able to make it work.
The translations are there, I'm loading them, the QTranslator.load()
method is returning True and I'm not seeing any errors, but it just
doesn't load the translated texts. It always shows everything in
english.

Here's the code where I load the translations. Do you see any errors?
http://code.google.com/p/aranduka/source/browse/src/main.py?name=issue59#432

Ramiro Algozino

unread,
Jul 14, 2011, 4:12:37 PM7/14/11
to aranduka...@googlegroups.com
2011/7/14 Andrés Gattinoni <andresg...@gmail.com>:

I'm at work so sadly I can't test the code, but it seems to be OK;
just to be sure:

1- Are you storing the "aranduka_es_AR.qm" file in the translations
folder right? Assuming that your locale is "es_AR".
2- Is your system's locale different from english?
3- Did you generate the release, .qm, files from the .ts?

If all this are ok the only other thing I think may be problematic is
that in line 439 you are not adding the .qm extension to the filename,
it should work either way but you can try to add ".qm" to the filename
like this:

translator.load(u'aranduka_%s.qm' % locale,
os.path.join(os.path.abspath(
os.path.dirname(__file__)),
'translations'))

I'm out of ideas..

Andrés Gattinoni

unread,
Jul 14, 2011, 4:47:32 PM7/14/11
to aranduka...@googlegroups.com
On Thu, Jul 14, 2011 at 5:12 PM, Ramiro Algozino <algo...@gmail.com> wrote:
> 2011/7/14 Andrés Gattinoni <andresg...@gmail.com>:
>> For some reasong I'm not being able to make it work.
>> The translations are there, I'm loading them, the QTranslator.load()
>> method is returning True and I'm not seeing any errors, but it just
>> doesn't load the translated texts. It always shows everything in
>> english.
>>
>> Here's the code where I load the translations. Do you see any errors?
>> http://code.google.com/p/aranduka/source/browse/src/main.py?name=issue59#432
> I'm at work so sadly I can't test the code, but it seems to be OK;
> just to be sure:
>
> 1- Are you storing the "aranduka_es_AR.qm" file in the translations
> folder right? Assuming that your locale is "es_AR".
> 2-  Is your system's locale different from english?
> 3- Did you generate the release, .qm, files from the .ts?
>
> If all this are ok the only other thing I think may be problematic is
> that in line 439 you are not adding the .qm extension to the filename,
> it should work either way but you can try to add ".qm" to the filename
> like this:
>
> translator.load(u'aranduka_%s.qm' % locale,
>                    os.path.join(os.path.abspath(
>                            os.path.dirname(__file__)),
>                    'translations'))
>
> I'm out of ideas..

I think it's a problem on my system.
My locale is en_US, so I run once aranduka with "python main.py" and,
of course, the UI appeared in english.
Then I ran:
LANG=es_AR; python main.py

And I got this:

(process:5779): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Loading translations for 'es_AR'

And the UI loads in english too. Then if I want to go back to en_US I
still get the same GTK error:

ellbarto@tarantino:~/aranduka-i18n/src$ LANG=es_US; python main.py
Setting up database sqlite:////home/elbarto/.aranduka/books.sqlite

(process:5791): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
Loading translations for 'es_US'

Any idea why is that?

Ramiro Algozino

unread,
Jul 15, 2011, 10:08:40 AM7/15/11
to aranduka...@googlegroups.com
2011/7/14 Andrés Gattinoni <andresg...@gmail.com>:

Andres,

I don't have a clue about your error sadly, but I tried in my PC and
the translations are not working either, no error this time. The Qt
translations *do* work though, i.e., the OK buttons are translated to
"Aceptar" and "Cancel" into "Cancelar"; I couldn't figure out where is
the bug.. :-( maybe something related with the ui files?

Ramiro Algozino

unread,
Sep 7, 2011, 11:18:07 AM9/7/11
to aranduka...@googlegroups.com
2011/7/15 Ramiro Algozino <algo...@gmail.com>:

I've found the "bug"!! :D

To get the translations working you just have to install the
QtTranslator first and then the aranduka translator, and everything
works! :-)

I don't know if this is the spected behavior or is some kind of bug.. :S

To try it yourself, just move the main.py 443 line
(translators.append(translator)) after the 450 line
(translators.append(qtTranslator))


Yay!

Andrés Gattinoni

unread,
Sep 7, 2011, 11:20:06 AM9/7/11
to aranduka...@googlegroups.com

Cool! Thanks!

Andrés Gattinoni

unread,
Jan 21, 2012, 4:38:31 PM1/21/12
to aranduka...@googlegroups.com
2011/9/7 Andrés Gattinoni <andresg...@gmail.com>:

I've made some progress on this today. Ramiro's fix enabled
translations on the core application.
I've also updated the branch with the latest changes on integrate and
added some new translations.

I made two further changes on this branch:

- Updated Yapsy to version 1.9 (it provides a couple of methods that
were useful)
- Now after plugins are loaded, the main app tries to load
translations for each plugin. For that it looks for a "translation"
directory within each plugin's folder and if it finds it, it attempts
to load the translation for the current locale. I need to test this
yet.

You can check it out here:
http://code.google.com/p/aranduka/source/list?name=issue59

Reply all
Reply to author
Forward
0 new messages