View Single Post
Old 03-20-2011, 12:33 PM   #17
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by arspr View Post
Unless you can give a really, REALLY good hint, I feel the template coding can be really painful because you have to:
Here is a hint.

Go to preferences -> template functions. Enter:

Function: names_to_sort
Arg count: 1
Documentation: Given an author-like string, return the author-sort for it.
Program code:
Code:
def evaluate(self, formatter, kwargs, mi, locals, names):
    from calibre.ebooks.metadata import authors_to_sort_string, string_to_authors

    return authors_to_sort_string(string_to_authors(names))
Press the Create button, then the Apply icon. Now create a custom column that you want to contain the sort string for an author-like field and enter the template. For 'authors' the template would be:
Code:
{authors:names_to_sort()}
Change 'authors' to the lookup name for your translator column.

Last edited by chaley; 03-20-2011 at 04:15 PM. Reason: Correct the function name
chaley is offline   Reply With Quote