New LanguageCodeToHumanReadableString function in templates

Bug #832084 reported by arspr
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Charles Haley

Bug Description

As discussed an explained here: http://www.mobileread.com/forums/showpost.php?p=1710196&postcount=6

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: https://bugs.launchpad.net/calibre/+bug/832074

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

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 832084

Changing the component for this bug.

 assignee cbhaley
 status triaged

Changed in calibre:
assignee: nobody → Charles Haley (cbhaley)
status: New → Triaged
Revision history for this message
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
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in lp:calibre

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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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