New LanguageCodeToHumanReadableString function in templates

Bug #832084 reported by arspr on 2011-08-23
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Charles Haley

Bug Description

As discussed an explained here:

Even before 0.8.15, I had two language fields in my database (one for its language an another one for its original language) and even a third one with a comparison through strcmp function which evaluates if the book is a translation or an original version.

Because the new official Languages field doesn't store a string with the selected language name, but its ISO 639 code, I have troubles with the "translation evaluation".

My preferred solution would be this one:

Nevertheless maybe another easier solution could be implementing a "LanguageCodeToHumanReadableString()" (maybe similar to existing human_readable()) which would allow performing a strcmp comparison between official "Languages" field (which shows language names, but internally stores just an ISO 639 code) and a tag-like custom column (which shows and stores language names).

I mean, this should work:

{#original:'strcmp(field('#original_language'), LanguageCodeToHumanReadableString(field('languages')), 'No', 'Yes', 'No')'}

Related branches

Changing the component for this bug.

 assignee cbhaley
 status triaged

Changed in calibre:
assignee: nobody → Charles Haley (cbhaley)
status: New → Triaged
Charles Haley (cbhaley) wrote :

Enhancement submitted.

New formatter functions:
    * ``language_codes(lang_strings)`` -- return the language codes for the strings passed in `lang_strings`. The strings must be in the language of the current locale. `Lang_strings` is a comma-separated list.
    * ``language_strings(lang_codes, localize)`` -- return the strings for the language codes passed in `lang_codes`. If `localize` is zero, return the strings in English. If localize is not zero, return the strings in the language of the current locale. `Lang_codes` is a comma-separated list.

Changed in calibre:
status: Triaged → Fix Committed

Fixed in branch lp:calibre. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

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

Other bug subscribers