@@ -18,6 +18,7 @@ use crate::{
1818 util:: path:: extract_title_from_path,
1919 xml_to_text:: XmlToText ,
2020 } ,
21+ t,
2122 types:: { HeadingInfo , LinkInfo , ListInfo , ListItemInfo , SeparatorInfo , TableInfo } ,
2223 util:: {
2324 text:: { collapse_whitespace, trim_string, url_decode} ,
@@ -133,16 +134,20 @@ impl Parser for EpubParser {
133134 let package_node = opf_doc
134135 . descendants ( )
135136 . find ( |n| n. node_type ( ) == NodeType :: Element && n. tag_name ( ) . name ( ) == "package" )
136- . ok_or_else ( || anyhow:: anyhow!( "OPF package element missing" ) ) ?;
137+ // TRANSLATORS: Error shown when an EPUB's OPF document has no <package> element
138+ . ok_or_else ( || anyhow:: anyhow!( t( "OPF package element missing" ) ) ) ?;
137139 let ( manifest, spine, nav_path, ncx_path, metadata) = parse_package ( package_node, & opf_dir) ;
138140 let mut conversion = convert_spine_items ( & mut archive, & manifest, & spine, context. render_tables_inline ) ;
139141 if conversion. sections . is_empty ( ) {
140142 let reason = if conversion. conversion_errors . is_empty ( ) {
141- String :: from ( "no readable spine items" )
143+ // TRANSLATORS: Reason given when an EPUB has no spine items that could be read
144+ t ( "no readable spine items" )
142145 } else {
143- format ! ( "failed to convert spine items: {}" , conversion. conversion_errors. join( ", " ) )
146+ // TRANSLATORS: Reason given when EPUB spine items failed to convert; {} is a comma-separated list of underlying errors
147+ t ( "failed to convert spine items: {}" ) . replace ( "{}" , & conversion. conversion_errors . join ( ", " ) )
144148 } ;
145- anyhow:: bail!( "EPUB has no readable content ({reason})" ) ;
149+ // TRANSLATORS: Error shown when an EPUB has no readable content; {} is the specific reason (see the two messages above)
150+ anyhow:: bail!( t( "EPUB has no readable content ({})" ) . replace( "{}" , & reason) ) ;
146151 }
147152 let title = metadata
148153 . title
@@ -275,7 +280,8 @@ fn find_container_path<R: Read + Seek>(archive: &mut ZipArchive<R>) -> Result<St
275280 return Ok ( path. to_string ( ) ) ;
276281 }
277282 }
278- anyhow:: bail!( "rootfile not found in container.xml" )
283+ // TRANSLATORS: Error shown when an EPUB's container.xml is missing its rootfile reference
284+ anyhow:: bail!( t( "rootfile not found in container.xml" ) )
279285}
280286
281287struct PackageMetadata {
@@ -386,7 +392,8 @@ fn convert_section(content: &str, render_tables_inline: bool) -> Result<SectionC
386392 id_positions : html_converter. get_id_positions ( ) . clone ( ) ,
387393 } ) ;
388394 }
389- anyhow:: bail!( "unsupported content" )
395+ // TRANSLATORS: Error shown when an EPUB spine item's content type cannot be converted
396+ anyhow:: bail!( t( "unsupported content" ) )
390397}
391398
392399fn resolve_href ( current_path : & str , target : & str ) -> String {
0 commit comments