Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Internationalization, i18n ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Benoit Masson  
View profile  
 More options Nov 13 2005, 11:44 am
From: Benoit Masson <beno...@perenite.com>
Date: Sun, 13 Nov 2005 17:44:21 +0100
Local: Sun, Nov 13 2005 11:44 am
Subject: Internationalization, i18n ?
Hi Herre again with my development, what about multi-langage in  
turbogears ? I've seen a i18n class in SVN but how do we use that ?  
Is this for multi-language web-site or not ? Does any one has already  
done multi-language site with turbogears ?

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Elvelind Grandin  
View profile  
 More options Nov 13 2005, 1:35 pm
From: Elvelind Grandin <elvel...@gmail.com>
Date: Sun, 13 Nov 2005 19:35:46 +0100
Local: Sun, Nov 13 2005 1:35 pm
Subject: Re: [TurboGears] Internationalization, i18n ?
I've used it for a small quick test site.
Hopefully there will be docs on it soon, atleast before 0.9 gets out.

On 11/13/05, Benoit Masson <beno...@perenite.com> wrote:

> Hi Herre again with my development, what about multi-langage in
> turbogears ? I've seen a i18n class in SVN but how do we use that ?
> Is this for multi-language web-site or not ? Does any one has already
> done multi-language site with turbogears ?

> Thanks

--
cheers
    elvelind grandin

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benoit Masson  
View profile  
 More options Nov 13 2005, 7:32 pm
From: Benoit Masson <beno...@perenite.com>
Date: Mon, 14 Nov 2005 01:32:35 +0100
Local: Sun, Nov 13 2005 7:32 pm
Subject: Re: [TurboGears] Re: Internationalization, i18n ?
Do you still have the code or some example that would help me getting  
into testing it on my app ?
Thanks
Le 13 nov. 05 à 19:35, Elvelind Grandin a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Jacob  
View profile  
 More options Nov 14 2005, 6:23 am
From: "Dan Jacob" <dan.ja...@xeepra.fi>
Date: Mon, 14 Nov 2005 03:23:37 -0800
Local: Mon, Nov 14 2005 6:23 am
Subject: Re: Internationalization, i18n ?
The i18n module uses Python gettext to translate text. The first step
is to localize all your text strings, for example:

@turbogears.expose(html="index")
def index(self):
     flash(_('Welcome to TurboGears'))
     return dict()

You should then have for example the following files:

my_project/
   locales/
      messages.pot
      en/
          LC_MESSAGES/
             messages.po
             messages.mo
      fi/
          LC_MESSAGES/
             messages.po
             messages.mo

The Python tools pygettext.py and msgfmt.py (under Tools/i18n of your
Python distribution) are used to extract and format your text strings.
(Eventually they will be integrated with tg-admin). You can use these
tools to create your translated text strings.  See
http://docs.python.org/lib/module-gettext.html for more information on
this. Basically the pygettext.py script creates a file called
<domain>.pot, which has entries like this:

msgid "Welcome to TurboGears"
msgstr ""

You then copy this file to each language in the file structure shown
above, renaming the file <domain>.po and adding your translations, for
example in my_project/locales/fi/LC_MESSAGES/messages.po:

msgid "Welcome to TurboGears"
msgstr "Tervetuloa TurboGearsiin"

NB: make sure the Content-Type line at the top is set correctly ! For
example:

"Content-Type: text/plain; charset=iso-8859-1\n"

You then have to run the msgfmt.py script on this .po file to create a
.mo file, which is used by gettext.

Instead of the standard gettext.gettext function, TurboGears uses a
modified gettext function which gets the user locale from the session.
If the session does not contain the user locale, the HTTP
Accept-Language header is checked, and failing that, the default locale
is used, which can be set in your configuration file as
i18n.defaultLocale. You can also pass the locale in  the function, for
example:

_('Welcome to TurboGears', 'fi')

The _ function is an alias for gettext and is added to the builtins
namespace and so can be called from anywhere in your code.

In the present code text inside Kid templates can be handled by using
the following code:

<translate py:match="item.get('lang')" py:replace="translate(item,
'lang')" />

This will match any element with the lang attribute and replace the
text of the element, and any child elements, with the translated
version, for example:

<div lang="fi">Welcome to Turbogears</div>

is translated to <div lang="fi">Tervetuloa TurboGearsiin</div>

However I'd like to replace this code with a filter in the template, so
this boilerplate is unnecessary: you just set in your config file :

i18n.runTemplateFilter=True

and the text in the template will be translated according to the user
locale, although the "lang" attribute can still be used to override
this locale.

There are a few caveats here: first, template attributes are not
affected by the filter, so they have to be translated manually, e.g.:

<img py:attrs="caption=_('My logo')">

I really don't like this, so if any one has any good ideas let me know.
Of course, all attrs could be translated as well, but I'm not sure if
this might be too resource-intensive. Perhaps TAL:like i18n attributes
could be used instead.

Secondly, FormEncode returns untranslated strings, which then have to
be translated. I've added some suggestions for handling gettext on the
FormEncode mailing list, so that we can use TurboGears i18n seamlessly
with FormEncode.

Once the module is a bit more stable I'll get some documentation going.

BTW Elvelind, any feedback/comments ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »