Nebojša, or somebody else who's knowledgable, can you provide a basic
checklist of all the things we need to do to get i18n up and running?
I've seen your patches, but I'd appreciate a higher-level overview of
all the steps we need to take.
Thanks,
Adrian
2005/8/2, Nebojša Đorđević - nesh <ne...@studioquattro.co.yu>:
>
> OTOH, maybe we can go for database based solution like some PHP CMS I
> seen?
-1
It's my first i18n experience, but I think it's better to stick to an
accepted standard here.
--
Ksenia
So, the way we do it in Plone (since someone asked on the wiki), is
more or less like this:
- We have a component called "translation service", which loads the
message catalogs and indexes them in memory.
- The templates have i18n markup; so the strings are translated when
the template is being rendered.
- I originally implemented PlacelessTranslationService to choose a
language based on the HTTP header, overridable by a cookie. Alas, that
didn't work out so well :-( turns out most people don't even know they
can set up language preferences in their browser. The more recent
versions of plone are migrating to a click-the-flag system (which
essentialy just sets the aforementioned cookie).
Ah, that's great news - so the patch will be a tested one? Great. I
really would like to see something like this to make it into the django
source soon, because it will be a blocking problem for me, too -
without at least i18n (l10n isn't really needed for me, as I can easily
circumvent those problems by just changing templates) I won't be able
to do much with it at work. The alternative for me would be to just
translate the strings in django validators to german and run with a
modified django source, but I would prefer a multi-language solution
over such a hack.
bye, hugo-
> your implementation for template tag don't have any plural
> support. You can probably add something like {% i18n ngettext(x,
> 'singular', 'plural') %}, patch is attached (untested).
Yep, plural support was missing up to now. I took your patch and
applied it and added some more stuff to smooth it out. Now there is a
ngettext helper and ngettext i18n form. And there are unit tests for
i18n templating.
bye, Georg
I am adding it to my branch. I did provide a default LANGUAGES
definition in the global settings that lists all languages that are
already available - the idea being that users can just take that list
and show it to their users, or extend it with local languages they
provided.
I did change the LANGUAGE_CODE stuff for the DjangoContext a bit,
because LANGUAGE_CODE is only defined on the request if you have the
i18n middleware loaded - now the DjangoContext either carries
request.LANGUAGE_CODE or settings.LANGUAGE_CODE.
Commit will follow soon, I need to take a few tests, first.
Thanks for your input (and more thanks that you don't feel put off
because I did the patch a bit different than your first patch ;) )
bye, Georg
2005/10/3, Nebojša Đorđević - nesh <ne...@studioquattro.co.yu>:
> Also in get_language_from_request I added support to set language via
> GET parameter and store that selection in the session or cookie, so
> you can set current locale (and store it) with .../?django_locale=de.
what about dropping the "django_" part of the name? something like
"../?locale=de" seems neatier to me... or maybe i18n_locale, if
polluting namespace bother you...
>I'm found while writing current application that this pattern is very
>common (almost a 2/3 of my models are using some type of localized
>name/description fields) and it will be great that i18n/model
>framework supports that without any additional code.
I agree that this is a rather common pattern - but I don't think it's
something that the i18n branch should solve, but something that could
go into another patch. The reason being that "metamodels" like that are
things where not everybody will agree on - it might be that some want
to do it just by adding additional attributes to their model while
others might want to normalize it out into a dependend table and stuff
like that.
So I'd opt to leave that stuff out of the i18n branch for now and to
concentrate on the "translations for string constants" part and some
other branch or patch can introduce the "multilinguality of models"
patterns later.
That way it's easier for Jacob and Adrian to see what the patch
actually will do and to decide wether they need some changes before
merging it into trunk.
Oh, and I think I would quite like I18NCharField or I18NTextField -
with automatic creation of the dependend table and a way in the admin
to select what language content to edit. But that's just me. And maybe
it should wait for the new_admin branch of rjwittams, as his stuff
might make the extension of the admin to incorporate those I18N*Fields
easier.
bye, Georg
Yes, I had to search&replace ".html.py" to ".html" in order to use
poedit reference tool. There was also an issue with incorrect line
numbers, but I see that was fixed in changeset 801
(http://code.djangoproject.com/changeset/801).
I just wanted to say that you guys are doing a bloody good job with
i18n, and django in general :)
--
Петар Марић
Irrigation of the land with seawater desalinated by fusion power is
ancient. It's called 'rain'. - Michael McClary
Offtopic: I think it's for the best to recode the current translation
file to cyrillic, because we can use automated tools to make latin
translation out of that. Saves quite a some time.
If it's allright with you nesh, I would get right on it :)
Agreed.
just some heads-up on the i18n stuff: I am now mostly done with the
first part of implementing the base code. So I switched my gallery site
- http://viele-bunte-bilder.de/ - to use my branch and to run it. So
you can see the first app running with full i18n.
The source to that gallery stuff is online:
https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/browser/gallery/trunk/
The project is using the django translations (of course they aren't
complete, yet - that will come later, when the source is about ready)
and project-local translations.
bye, Georg
>Currently I have setup where I have two (almost) separate project
>which use same set of templates, so I'll be needing some way to
>manually set path to locale directory because my templates are
>outside of the booth projects.
I added an optional LOCALE_PATHS setting that you can use in your
settings module. If set, it needs to be a list of paths (like
TEMPLATE_PATHS) where the translation system looks for language files.
This isn't tested, though, as I don't have the need for that feature at
the moment - try it and tell me wether it works ;-)
Oh, and the paths in LOCALE_PATHS are used directly - there is no
"locale/" subdirectory attached, the system directly expects the
language code below the paths.
bye, Georg