translating app name ... again

241 views
Skip to first unread message

patrickk

unread,
Mar 4, 2009, 12:39:05 PM3/4/09
to Django users
so far, it doesn´t seem possible to translate the app-names within the
admin-interface, which results in a strange index-site with mixed
languages.

any updates on this issue? any ideas?

thanks,
patrick

Malcolm Tredinnick

unread,
Mar 4, 2009, 8:51:32 PM3/4/09
to django...@googlegroups.com

If you put each of your app names into a file that was then processed by
makemessages (so the strings were included in the PO file) and then
translated them, I believe the translated version will show up on the
site (the app name is certainly marked as "to be translated" in the
template). So you need to write down the app names by hand.

Right now, there's no automatic extraction of application names. No
great plans to do so either (although if somebody came along with an
ideal setup, we'd certainly include it). Hacks aren't interesting -- we
need a decent, robust solution and are prepared to wait until that
appears. It's one of those cases where localisation has to compromise to
code, instead of the other way around.

Regards,
Malcolm


patrickk

unread,
Mar 5, 2009, 2:30:50 AM3/5/09
to Django users
great - a gleam of hope ... but what do you mean with "put each of
your app names into a file ..."? what file? where? can I use
__init__.py within my app and just put the app-names there and mark
them as to translate?

I already tried to translate the app-names by using a translation-file
(django.po, django.mo), but that doesn´t work. probably because I´m
missing that "file" you´re talking about.

thanks,
patrick


On Mar 5, 2:51 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

patrickk

unread,
Mar 5, 2009, 2:58:05 AM3/5/09
to Django users
just tried to write the app-names to my applications __init__-file.
the po-file is generated fine, but the translation still doesn´t work.

Malcolm Tredinnick

unread,
Mar 5, 2009, 4:23:43 AM3/5/09
to django...@googlegroups.com
On Wed, 2009-03-04 at 23:30 -0800, patrickk wrote:
> great - a gleam of hope ... but what do you mean with "put each of
> your app names into a file ..."? what file? where?

Any file. It doesn't matter. Some file that "makemessages" will pick up
and read, so best make it a .py file. It could be an empty file that
just contains a big docstring with the names of the applications.

> can I use
> __init__.py within my app and just put the app-names there and mark
> them as to translate?

Sounds reasonable.

>
> I already tried to translate the app-names by using a translation-file
> (django.po, django.mo), but that doesn´t work. probably because I´m
> missing that "file" you´re talking about.

Hmm ... I would have thought that would work. Maybe I'm forgetting some
obvious step. I haven't actually tested this, but I'd be surprised if it
doesn't work. If you still have no look, post back to the list and maybe
I'll find some time, or somebody else will, to try out some options.

Regards,
Malcolm


patrickk

unread,
Mar 5, 2009, 9:57:29 AM3/5/09
to Django users
well, I tried some things within the last couple of hours (like
changing upper/lowercase), but it still doesn´t work.

although automatic extraction of app-names would be perfect,
translating the names manually is totally fine for me (if it works).
it just want to get rid of that language-mix (even if you do speak
english, "auth" is not very descriptive).

thanks,
patrick

Nadya Sevova

unread,
Mar 6, 2009, 8:48:54 AM3/6/09
to Django users
I put my translations in the django.po file and also changed a little
bit the admin's index.html template.

Replaced this:
<caption>
<a href="{{ app.app_url }}" class="section">
{% blocktrans with app.name as name %}{{ name }}{%
endblocktrans %}
</a>
</caption>

with this:
<caption><a href="{{ app.app_url }}" class="section">{%
trans app.name %}</a></caption>


I can't figure out why blocktranslate does not work in this case.
Tested it in a separate template and everything was ok.

Also cannot translate the app name in the admin's breadcrumbs.

Nadya Sevova

unread,
Mar 6, 2009, 8:49:05 AM3/6/09
to Django users

Muslu Yüksektepe

unread,
Mar 6, 2009, 8:56:58 AM3/6/09
to django...@googlegroups.com
i dont understand..
do u wanna mean your app name?
if u wanna tell about your app name in admin panel

i think u can use

USE_I18N = True

in settings.py


 and

    class Meta:
        verbose_name_plural = "Your App Name"

in models.py



try it and write me answer please

2009/3/4 patrickk <sehma...@gmail.com>



--
Muslu YÜKSEKTEPE

patrickk

unread,
Mar 6, 2009, 9:39:13 AM3/6/09
to Django users
you´re talking about the models name, not the applications name ...

@nadya: with changing index.html the way you did it works for me as
well.
for changing the breadcrumbs (which obviously is a "must" if you
change the app-names) you have to change change_list.html and
change_form.html

replace {{ app_label|capfirst }} with {% trans app_label %}

in this case, you also have to provide the translations for app_label
(lowercase).

thanks,
patrick


On 6 Mrz., 14:56, Muslu Yüksektepe <musluyuksekt...@gmail.com> wrote:
> i dont understand..
> do u wanna mean your app name?
> if u wanna tell about your app name in admin panel
>
> i think u can use
>
> *USE_I18N = True
>
> in settings.py*
>
>  and
>
>    * class Meta:
>         verbose_name_plural = "Your App Name"
>
> in models.py*
>
> try it and write me answer please
>
> 2009/3/4 patrickk <sehmasch...@gmail.com>

patrickk

unread,
Mar 6, 2009, 10:01:22 AM3/6/09
to Django users
so, now here´s a little tutorial for translating app-names throughout
the admin-interface:

1. define the app-names: I´m currently using the __init__-file of my
blog-application. it looks like this:

from django.utils.translation import ugettext_lazy as _

_(u'auth')
_(u'configuration')
_(u'comments')
_(u'flatpages')
_(u'sites')
_(u'Auth')
_(u'Configuration')
_(u'Comments')
_(u'Flatpages')
_(u'Sites')
_(u'Auth-Verwaltung')
_(u'Configuration-Verwaltung')
_(u'Comments-Verwaltung')
_(u'Flatpages-Verwaltung')
_(u'Sites-Verwaltung')

2. translation (see django-tutorial). my translation looks like this
(don´t forget upper/lowercase as well as the translation for "app
index"):

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE
package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-03-05 07:45+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <L...@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: __init__.py:3
msgid "auth"
msgstr "Benutzer & Gruppen"

#: __init__.py:4
msgid "configuration"
msgstr "Konfiguration"

#: __init__.py:5
msgid "comments"
msgstr "Kommentare"

#: __init__.py:6
msgid "flatpages"
msgstr "Statische Seiten"

#: __init__.py:7
msgid "sites"
msgstr "Domains"

#: __init__.py:3
msgid "Auth"
msgstr "Benutzer & Gruppen"

#: __init__.py:4
msgid "Configuration"
msgstr "Konfiguration"

#: __init__.py:5
msgid "Comments"
msgstr "Kommentare"

#: __init__.py:6
msgid "Flatpages"
msgstr "Statische Seiten"

#: __init__.py:7
msgid "Sites"
msgstr "Domains"

#: __init__.py:3
msgid "Auth-Verwaltung"
msgstr "Benutzer & Gruppen (Übersicht)"

#: __init__.py:4
msgid "Configuration-Verwaltung"
msgstr "Konfiguration (Übersicht)"

#: __init__.py:5
msgid "Comments-Verwaltung"
msgstr "Kommentare (Übersicht)"

#: __init__.py:6
msgid "Flatpages-Verwaltung"
msgstr "Statische Seiten (Übersicht)"

#: __init__.py:7
msgid "Sites-Verwaltung"
msgstr "Domains (Übersicht)"

3. change app-names in index.html /// on line 18 replace {% blocktrans
with app.name as name %}{{ name }}{% endblocktrans %} with {% trans
app.name %}

4. change breadcrumbs in change_list.html /// on line 25 replace
{{ app_label|capfirst }} with {% trans app_label %}

5. change breadcrumbs in change_form.html /// on line 28 replace
{ app_label|capfirst }} with {% trans app_label %}

6. change app-names in app_index.html /// on line 11 replace {%
blocktrans with app.name as name %}{{ name }}{% endblocktrans %} with
{% trans app.name %}

7. change title in base_site.html /// on line 69 replace {{ title }}
with {% trans title %}

a bit over-complicated, but it works ... be sure to have all possible
translations within your translation-file (django.po)

thanks to everybody for your help,
patrick

Malcolm Tredinnick

unread,
Mar 6, 2009, 8:21:36 PM3/6/09
to django...@googlegroups.com
On Fri, 2009-03-06 at 07:01 -0800, patrickk wrote:
> so, now here´s a little tutorial for translating app-names throughout
> the admin-interface:

Nice summary. :-)

> 3. change app-names in index.html /// on line 18 replace {% blocktrans
> with app.name as name %}{{ name }}{% endblocktrans %} with {% trans
> app.name %}

Not sure what's going on there, but it's a bug. Blocktrans shouldn't be
behaving strangely (using "trans" isn't wrong and we could just switch
to that, but I'd like to understand what's going with "blocktrans",
too).

That's why I thought this should have just worked with marking the names
for translation in a file somewhere. Hmm ... mysterious. :-(



>
> 4. change breadcrumbs in change_list.html /// on line 25 replace
> {{ app_label|capfirst }} with {% trans app_label %}
>
> 5. change breadcrumbs in change_form.html /// on line 28 replace
> { app_label|capfirst }} with {% trans app_label %}
>
> 6. change app-names in app_index.html /// on line 11 replace {%
> blocktrans with app.name as name %}{{ name }}{% endblocktrans %} with
> {% trans app.name %}
>
> 7. change title in base_site.html /// on line 69 replace {{ title }}
> with {% trans title %}

All of those are bugs (the same bug: not marking app name for
translation). If you'd like to open a ticket and drop in a patch, it's
an more-or-less obviously correct set of changes to make.

Put it in the "internationalisation" component.

Regards,
Malcolm


Malcolm Tredinnick

unread,
Mar 6, 2009, 9:15:32 PM3/6/09
to django...@googlegroups.com
On Sat, 2009-03-07 at 12:21 +1100, Malcolm Tredinnick wrote:
[...]

> All of those are bugs (the same bug: not marking app name for
> translation). If you'd like to open a ticket and drop in a patch, it's
> an more-or-less obviously correct set of changes to make.
>
> Put it in the "internationalisation" component.

Looks like the discussion for the technical fixes here (and Ramiro
Morales seems to be taking care of the bug filing) has moved to the
django-i18n list:

http://groups.google.com/group/Django-I18N/browse_thread/thread/bdcdaf433bfcd144

Regards,
Malcolm

Ramiro Morales

unread,
Mar 8, 2009, 6:10:57 PM3/8/09
to django...@googlegroups.com
On Fri, Mar 6, 2009 at 11:21 PM, Malcolm Tredinnick
<mal...@pointy-stick.com> wrote:
>
> On Fri, 2009-03-06 at 07:01 -0800, patrickk wrote:
>> so, now here´s a little tutorial for translating app-names throughout
>> the admin-interface:
>
> Nice summary. :-)
>
>> 3. change app-names in index.html /// on line 18 replace {% blocktrans
>> with app.name as name %}{{ name }}{% endblocktrans %} with {% trans
>> app.name %}
>
> Not sure what's going on there, but it's a bug. Blocktrans shouldn't be
> behaving strangely (using "trans" isn't wrong and we could just switch
> to that, but I'd like to understand what's going with "blocktrans",
> too).
>
> That's why I thought this should have just worked with marking the names
> for translation in a file somewhere. Hmm ... mysterious. :-(
>
>>
>> 4. change breadcrumbs in change_list.html /// on line 25 replace
>> {{ app_label|capfirst }} with {% trans app_label %}
>>
>> 5. change breadcrumbs in change_form.html /// on line 28 replace
>> { app_label|capfirst }} with {% trans app_label %}
>>
>> 6. change app-names in app_index.html /// on line 11 replace {%
>> blocktrans with app.name as name %}{{ name }}{% endblocktrans %} with
>> {% trans app.name %}
>>
>> 7. change title in base_site.html /// on line 69 replace {{ title }}
>> with {% trans title %}

I've opened [1]ticket 10436 for this , please test the patch attached
and/or post
feedback about it or the ticket description notes.

>
> All of those are bugs (the same bug: not marking app name for
> translation). If you'd like to open a ticket and drop in a patch, it's
> an more-or-less obviously correct set of changes to make.
>
> Put it in the "internationalisation" component.
>

I've selected django.contrib.admin instead, change it to internationalization
if you consider it more correct.

--
Ramiro Morales
http://rmorales.net

1. http://code.djangoproject.com/ticket/10436

Reply all
Reply to author
Forward
0 new messages