[Merge] lp:~songofacandy/bzr/i18n into lp:bzr
David Planella
david.planella at ubuntu.com
Wed May 11 11:38:24 UTC 2011
El dc 11 de 05 de 2011 a les 14:24 +0300, en/na Alexander Belchenko va
escriure:
> Alexander Belchenko пишет:
> > Vincent Ladeuil пишет:
> >> <snip/>
> >>
> >> > Because _ has special meaning in PDB. Why does it matter?
>
> I can add even more reasons against using _() in first place.
>
> Function _() is just alias to some gettext method which is bound to
> specific language at installing time.
>
> So the usual practice for GUI applications is to install _() into global
> namespace leaving gettext to determine what language user wants to see
> and don't care about translations anymore.
>
Not arguing in favour of any approach here, just a quick note here to
mention that most of the translatable Python apps out there don't use
gettext.install() to install _() into global namespace.
They rather use something along the lines of:
import gettext
gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')
gettext.textdomain('myapplication')
_ = gettext.gettext
# ...
print _('This is a translatable string.')
(Example from the Python gettext docs)
Additionally you can call setlocale to explicitly set the default system
locale.
> I think this is wrong approach, although it may work OK for many
> projects out there.
>
> 1) Function _() translates the strings to some language immediately.
> That's could not what you want if you don't plan to show all those
> strings to user from the start. That could be OK for GUI applications,
> which shows most of their strings as menu/interface to the user. But
> this is simply the wrong way for CLI like bzr, who wants to achieve
> speed. Bzr wants to be lazy and don't do extra work until it's really
> needed.
>
> 2) Function _() translate the strings to some language immediately.
> That will be VERY bad for tests which check output of bzr commands.
> Output never will match until you have forced C locale before running tetst.
>
> 3) For QBzr/Explorer I've implemented support for user-defined language
> of the UI, it's stored as language option in bazaar.conf. And that's not
> whim. People asked for this to be able run our GUI in preferred
> language, maybe because translations could be incomplete. I don't see
> why CLI bzr won't support the same.
>
> More guides about proper usage of i18n in QBzr can be found here:
>
> http://bazaar.launchpad.net/~qbzr-dev/qbzr/trunk2a/view/head:/docs/gettext_usage.txt
> or
> http://bialix.com/qbzr/docs/gettext_usage.html
>
> I believe that approach used in QBzr and Explorer (plus nice
> ZzzTranslations class in explorer) is much more powerful and flexible
> than trying to use plain _(). I can be wrong of course, and will be
> happy to hear the contra arguments. But so far I haven't heard them.
> Maybe I'm trying to achieve too much, but in the end I'm not native
> English speaker and proper i18n/l10n stuff is important for me. So maybe
> my own standards a bit higher than in the other projects. Please, bear
> with me.
--
David Planella
Ubuntu Translations Coordinator
www.ubuntu.com / www.davidplanella.wordpress.com
www.identi.ca/dplanella / www.twitter.com/dplanella
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/bazaar/attachments/20110511/87d639e5/attachment.pgp>
More information about the bazaar
mailing list