|
|
Thread Tools | Search this Thread |
03-29-2015, 12:08 PM | #1 | |
Connoisseur
Posts: 65
Karma: 10
Join Date: Mar 2015
Device: KPW, Ipad 2, Note 5
|
How to manually set the language for each source of the news recipe?
Greetings!
I would like to know if there is a way to set the language for each source of my recipe. For instance, French for Le Monde, Spanish for El País and so on... Here is the detailed reason why I need to do this. But in a few words, Kindle's Vocabulary Builder doesn't work properly with multilingual documents. So, I'm trying to figure out a way to fix this problem and maybe if there is a way to set the metadata language for each source it may work. Here is how my recipe looks like. Edit: In red below is what I want to do. Set the language (in red) for each source. Quote:
Last edited by mendesitba; 03-29-2015 at 05:37 PM. |
|
03-29-2015, 11:58 PM | #2 |
creator of calibre
Posts: 43,859
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use postprocess_html and set the lang attribute on each downloaded html file appropriately.
|
Advert | |
|
04-02-2015, 12:20 AM | #3 | |
Connoisseur
Posts: 65
Karma: 10
Join Date: Mar 2015
Device: KPW, Ipad 2, Note 5
|
Quote:
I have zero experience on programming, so I didn't really understand what you said. I thought it would be as simple as adding something like << language = en >>, << language = fr >> in front of each source. I have been searching "postprocess_html" on mobileread forums to discover how to set the lang with that, but so far I don't have any idea of how to do it. Does it involve adding many lines on my recipe ? Is there some place that I can find the complete code which I can copy and paste on my recipe (just editing the code with the language I want)? |
|
04-02-2015, 12:35 AM | #4 |
creator of calibre
Posts: 43,859
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You will need to learn at least a little bit of programming to do that. There are examples of using postprocess_html etc to do other taks in the user manual, but you wont find a copy/paste solution.
|
04-02-2015, 10:19 AM | #5 |
Connoisseur
Posts: 65
Karma: 10
Join Date: Mar 2015
Device: KPW, Ipad 2, Note 5
|
I'll try that. But, what language I should know in order to edit recipes? Is it python or html?
|
Advert | |
|
04-02-2015, 01:38 PM | #6 |
Connoisseur
Posts: 65
Karma: 10
Join Date: Mar 2015
Device: KPW, Ipad 2, Note 5
|
Hello. I found this article: "Declaring language in HTML" by w3.org.
They describe the following code to set language attributes: Code:
<html lang="fr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml"> Code:
def postprocess_html(self, soup, first_fetch): <html lang="fr" xml:lang="fr" xmlns="http://www.lemonde.fr/diplomatie/rss_full.xml"> <html lang="en" xml:lang="en" xmlns="http://www.project-syndicate.org/rss/politics"> <html lang="en" xml:lang="en" xmlns="http://www.postwesternworld.com/feed/"> #and so on for each source.... Is that what I need? Is that at least close to what I need to do? Thanks Edit: I noticed that all recipes has "def" before postprocess_html, so I included it. Moreover, many recipes include (self, soup, first_fetch) after postprocess_html, while others include (self, soup, first_fetch, job_info) or only (self, soup). I added to my code the first option (self, soup, first_fetch) since it is the most used, but I don't know if it's necessary. Edit 2: When I use the above code in Calibre recipe advanced settings, I get syntax error for the line with <html lang="fr" xml:lang="fr" xmlns="http://www.lemonde.fr/diplomatie/rss_full.xml"> Last edited by mendesitba; 04-02-2015 at 02:51 PM. |
04-02-2015, 06:42 PM | #7 |
Ex-Helpdesk Junkie
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
You will need to know at least a little python, and take a look at what postprocess_html does and how to use it.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Hanvon C18: how do you set the interface language? | Heba | More E-Book Readers | 1 | 05-18-2014 05:26 AM |
SET READING LOCATION IN SOURCE - How do I do that? | mibtp | Kindle Formats | 18 | 06-20-2013 06:05 AM |
K4NT - How to set time manually? And other questions | Beemspam01 | Amazon Kindle | 0 | 04-20-2013 03:14 AM |
Cant get past the set language menu | Dividizzl | Kobo Reader | 17 | 10-29-2012 03:56 AM |
Custom news recipe default language | ppclarke | Recipes | 2 | 04-13-2012 07:58 AM |