hello po!

1 view
Skip to first unread message

"mitcho (Michael 芳貴 Erlewine)"

unread,
Jun 15, 2009, 11:23:28 AM6/15/09
to ubiqui...@googlegroups.com
Hi all,

I just wanted to let the i18n group know that I today implemented
localization with po (gettext portable object) files. Based on a
number of comments I received in the past week, including a few from
our very knowledgeable l10n team at Mozilla, I decided to at least
give the po a stab. It turns out that using the jsgettext library (http://developer.berlios.de/projects/jsgettext/
) I could get it working in less than a day. This change will open
Ubiquity command localization up to the vast resources and tools of
the po world.

One particular advantage of po is that it is a truly bilingual format,
so the source text can be right there as a reference. There are no
particular format restrictions on the keys (message ID's, or msgid),
as opposed to properties files. There also is a message context
(msgctxt) property which helps keep the msgid's less cluttered. Here's
an example entry from firefox.ja.po which I was using to test:

msgctxt "zoom.preview"
msgid "Zooms the Firefox window to ${replacement} of its normal size."
msgstr "ウインドウを通常の${replacement}のサイズで表
示。"

So here's the string "Zooms the Firefox window to ${replacement} of
its normal size." in the context of the preview() of the zoom command,
and its Japanese equivalent. Properties (like names) don't take
contexts and look like this:

msgid "zoom.names"
msgstr "ズーム|ズームして|ズームする|ズームしろ"

I also updated the localization template tool to produce po-formatted
templates (often called .pot). You can go to the command list and
click on a feed's "get localization template" link to get the
template. The localization template tool's recognition of _()'d
strings in preview and execute are imperfect, but they will hopefully
pick up a good number of the strings required in localization. If it's
missing some, of course, you can add your own entries to the po file.
Moreover, many strings in commands have yet to be _()'d... we'd
appreciate anyone who wants to pitch in and make some more commands
localizable as well.

Thanks for all the comments and feedback!

mitcho

--
mitcho (Michael 芳貴 Erlewine)
mit...@mitcho.com
http://mitcho.com/
linguist, coder, teacher

Blair McBride

unread,
Jun 15, 2009, 9:54:09 PM6/15/09
to ubiqui...@googlegroups.com
Impressive!

- Blair

Jono

unread,
Jun 16, 2009, 1:24:21 AM6/16/09
to ubiqui...@googlegroups.com
Great work, Mitcho!

What do I need to do to make strings _() able? Can you point me at
some documentation or examples for that? I am currently going through
all the standard feeds renaming commands for the Overlord Verbs
standard, so I might as well _() ify them at the same time, once I
know how.
--Jono

"mitcho (Michael 芳貴 Erlewine)"

unread,
Jun 16, 2009, 1:34:23 AM6/16/09
to ubiqui...@googlegroups.com
All you have to do is wrap localizable strings in preview's or
execute's with _(). Since moving to po _() doesn't support
replacements via printf format, you can simply leave ${variables} in
the strings and run the result through RenderTemplate, if need be.

I recommend leaving as much formatting as possible out of the
individual strings to localize. For example, if your string is
something like "<p>Here's a paragraph.</p><p>Here's another.</p>",
then it would be best if you put it as "<p>"+_("Here's a paragraph")
+"</p><p>"+_('Here's another.')+"</p>". A little messy, perhaps, but
it will make localizations much cleaner and more straightforward.

mitcho

Jono

unread,
Jun 16, 2009, 12:46:35 PM6/16/09
to ubiqui...@googlegroups.com
Is there a particular source file that needs to be included for _() to
be in the namespace?

--Jono

2009/6/15 "mitcho (Michael 芳貴 Erlewine <mit...@mitcho.com>:

"mitcho (Michael 芳貴 Erlewine)"

unread,
Jun 16, 2009, 8:14:35 PM6/16/09
to ubiqui...@googlegroups.com
Nope, there shouldn't need to be. _ should be defined in the
namespace. Is there an instance where that's not the case?

m
Reply all
Reply to author
Forward
0 new messages