Internationalization (i18n) formatting

Bug #513946 reported by Lance Arthur
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Library
Fix Released
Medium
Anand Chitipothu

Bug Description

There are cases where Python (chiefly, commify) is included in a text string, and others where the text labels are being generated via Python and I'm not sure how to format the text in i18n strings so that it will be translatable. Examples:

In the search results page, the facet labels are generated from a script, but attempting to include the usual i18n envelope around the label is unsuccessful, the text and the envelope (i.e. $_("eBook?")) are all rendering. The same thing happens on the Work page for Subject labels.

On the same page, the number of results is being inserted in a text string at top, and the result is commified via Python. Rather than split the sentence into fragments, can we include the commify instruction in the i18n string?

George (george-archive)
Changed in openlibrary:
assignee: nobody → Anand Chitipothu (anandology)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Anand Chitipothu (anandology) wrote :

The i18n strings can take parameters. For example:

$:_("We found <strong>%s results</strong> that match your query.", commify(num_found))

The occurrences of %s will be replaced with the arguments in the specified order.

I've fixed commify to respect locale.

http://upstream.openlibrary.org/search?q=book&lang=en
http://upstream.openlibrary.org/search?q=book&lang=te

Changed in openlibrary:
milestone: none → upstream
status: Confirmed → Fix Released
status: Fix Released → In Progress
Revision history for this message
Lance Arthur (lance-arthur) wrote :

We're placing the search labels used in the header/footer search drop-downs like so:

$ advanced = (
$ ('title', 'Title'),
$ ('author', 'Author'),
$ ('isbn', 'ISBN'),
$ ('subject', 'Subject'),
$ ('place', 'Place'),
$ ('person', 'Person'),
$ ('publisher', 'Publisher'),
$ )

I tried using the $_(" method but the code shows up along with the labels...?

Revision history for this message
Anand Chitipothu (anandology) wrote : Re: [Bug 513946] Re: Internationalization (i18n) formatting

On 30-Jan-10, at 3:40 AM, Lance Arthur wrote:

> We're placing the search labels used in the header/footer search drop-
> downs like so:
>
> $ advanced = (
> $ ('title', 'Title'),
> $ ('author', 'Author'),
> $ ('isbn', 'ISBN'),
> $ ('subject', 'Subject'),
> $ ('place', 'Place'),
> $ ('person', 'Person'),
> $ ('publisher', 'Publisher'),
> $ )
>
> I tried using the $_(" method but the code shows up along with the
> labels...?

You are already in the code mode because of the $ in the beginning.
Just use _("Title").

Revision history for this message
Lance Arthur (lance-arthur) wrote :

I changed it to:

$ advanced = (
$ ('title', _("Title")),
$ ('author', _("Author")),
$ ('isbn', ISBN),
$ ('subject', _("Subject")),
$ ('place', _("Place")),
$ ('person', _("Person")),
$ ('publisher', _("Publisher")),
$ )

But the i18n parts still render in the live site. Also, without placing ISBN in the i18n stuff, the page calls it an error.

Revision history for this message
Anand Chitipothu (anandology) wrote :

On 10-Feb-10, at 6:27 AM, Lance Arthur wrote:

> I changed it to:
>
> $ advanced = (
> $ ('title', _("Title")),
> $ ('author', _("Author")),
> $ ('isbn', ISBN),
> $ ('subject', _("Subject")),
> $ ('place', _("Place")),
> $ ('person', _("Person")),
> $ ('publisher', _("Publisher")),
> $ )
>
> But the i18n parts still render in the live site. Also, without
> placing
> ISBN in the i18n stuff, the page calls it an error.

You should put "ISBN" not ISBN.

Revision history for this message
Lance Arthur (lance-arthur) wrote :

Yay! All works now.

Changed in openlibrary:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.