Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 02-06-2023, 03:47 PM   #1
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 62
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
2-characters language code

Seems template expression {languages} returns (ISO 639.2) 3-characters language code (actually "terminology" variant).
fra for French, deu for German, ces for Czech, etc.

Is there a way how to get (ISO 639.1) 2-characters code?
fr, de, cs, ...
quinta@ebf.cz is offline   Reply With Quote
Old 02-06-2023, 04:29 PM   #2
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by quinta@ebf.cz View Post
Seems template expression {languages} returns (ISO 639.2) 3-characters language code (actually "terminology" variant).
fra for French, deu for German, ces for Czech, etc.

Is there a way how to get (ISO 639.1) 2-characters code?
fr, de, cs, ...
No, there isn't, in the template languge. It might be possible in a python template. I would need to check the calibre API, which I can't do at the moment.
chaley is offline   Reply With Quote
Advert
Old 02-06-2023, 05:55 PM   #3
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 62
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
It's not particulary important. 2-character language codes just seem more readable to me.

Although... Seems Calibre writes 3-chars into OPF of converted e-books... Isn't _this_ behavior in contrary of EPUB standard? I mean:
Quote:
Originally Posted by RFC 3066, 2.3 Choice of language tag:
2. When a language has both an ISO 639-1 2-character code and an ISO 639-2 3-character code, you MUST use the tag derived from the ISO 639-1 2-character code.

Last edited by quinta@ebf.cz; 02-06-2023 at 06:00 PM.
quinta@ebf.cz is offline   Reply With Quote
Old 02-06-2023, 06:42 PM   #4
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Quote:
Originally Posted by quinta@ebf.cz View Post
It's not particulary important. 2-character language codes just seem more readable to me.

Although... Seems Calibre writes 3-chars into OPF of converted e-books... Isn't _this_ behavior in contrary of EPUB standard? I mean:
As far as I know calibre doesn't write a 3-char language code into a converted epub, it writes a 2-char code.

I think it may use a 3-char code (e.g. eng) in its own main database plus the metadata.opf backup file stored with each book record in the calibre library.
jackie_w is offline   Reply With Quote
Old 02-07-2023, 08:13 AM   #5
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 62
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
Quote:
Originally Posted by jackie_w View Post
As far as I know calibre doesn't write a 3-char language code into a converted epub, it writes a 2-char code.
You are right. Sorry. I did not see 3-char in epub, but in azw3. It was just quick epub>azw3 conversion test...
- library metadata.opf file uses 3-chars, as mentioned
- conversion to epub makes 2-chars (even if there are only 3-char sources in library...)

So 3-chars "issue" actually detected just in azw3.
quinta@ebf.cz is offline   Reply With Quote
Advert
Old 02-07-2023, 09:20 AM   #6
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 7,073
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
Where in the azw3 file are you seeing this? If it is in the OPF file as shown by the calibre editor then you should be aware that is a recreation of what the equivalent EPUB metadata would be for the book. Kindle formats do not actually have an OPF. They encode metadata in a proprietary way. And the book’s language is actually stored as a number, not an ISO code.
jhowell is offline   Reply With Quote
Old 02-07-2023, 11:20 AM   #7
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 62
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
As you said. In OPF file, when AZW3 is opened in Calibre editor... Thx for background info.
quinta@ebf.cz is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Language code ignored in Edit Metadata screen? cloggy Conversion 5 06-05-2014 03:36 AM
Code view displays square box instead of non latin characters mashru Sigil 10 08-20-2013 11:09 AM
Template language query. Removing all text after a set of characters da_jane Calibre 1 12-14-2012 01:37 PM
Programming language code snippets in ebooks? Connochaetes Writers' Corner 7 10-18-2010 02:43 PM
National characters in .js code mkaluza Sony Reader Dev Corner 1 08-28-2008 10:42 AM


All times are GMT -4. The time now is 09:47 AM.


MobileRead.com is a privately owned, operated and funded community.