@@ -85,8 +85,8 @@ def format_unsupported(self, block):
8585
8686 with dominate .tags .div (cls = "unsupported-content-block" ) as unsupported :
8787 with dominate .tags .div (cls = "unsupported-content-block-message" ):
88- dominate .tags .h1 (self .localizer [ "unsupported_block_header" ] )
89- dominate .tags .p (self .localizer [ "unsupported_block_description" ] )
88+ dominate .tags .h1 (i18n . translate ( self .localizer , "unsupported_block_header" ) )
89+ dominate .tags .p (i18n . translate ( self .localizer , "unsupported_block_description" ) )
9090
9191 return unsupported
9292
@@ -136,7 +136,8 @@ def _format_link(self, block):
136136 poster_container .add (
137137 dominate .tags .img (
138138 srcset = srcset ,
139- alt = block .site_name or self .localizer ["link_block_poster_alt_text" ].format (site = block .url ),
139+ alt = block .site_name
140+ or i18n .translate (self .localizer , "link_block_poster_alt_text" ).format (site = block .url ),
140141 sizes = "(max-width: 540px) 100vh, 540px" ,
141142 )
142143 )
@@ -212,8 +213,10 @@ def _format_video(self, block):
212213 if not media_url .hostname .endswith (".tumblr.com" ):
213214 return self ._audiovisual_link_block_fallback (
214215 block ,
215- title = self .localizer ["error_link_block_fallback_native_video_player_non_tumblr_source" ],
216- description = self .localizer ["video_link_block_fallback_description" ],
216+ title = i18n .translate (
217+ self .localizer , "error_link_block_fallback_native_video_player_non_tumblr_source"
218+ ),
219+ description = i18n .translate (self .localizer , "video_link_block_fallback_description" ),
217220 )
218221
219222 additional_attrs = {}
@@ -260,14 +263,14 @@ def _format_video(self, block):
260263 if self .forbid_external_iframes and (block .embed_html or block .embed_url or block .embed_iframe ):
261264 return self ._audiovisual_link_block_fallback (
262265 block ,
263- self .localizer [ "link_block_fallback_embeds_are_disabled" ] , # type: ignore
264- self .localizer [ "video_link_block_fallback_description" ] , # type: ignore
266+ i18n . translate ( self .localizer , "link_block_fallback_embeds_are_disabled" ) , # type: ignore
267+ i18n . translate ( self .localizer , "video_link_block_fallback_description" ) , # type: ignore
265268 )
266269 else :
267270 return self ._audiovisual_link_block_fallback (
268271 block ,
269- self .localizer [ "error_video_link_block_fallback_heading" ] , # type: ignore
270- self .localizer [ "video_link_block_fallback_description" ] , # type: ignore
272+ i18n . translate ( self .localizer , "error_video_link_block_fallback_heading" ) , # type: ignore
273+ i18n . translate ( self .localizer , "video_link_block_fallback_description" ) , # type: ignore
271274 )
272275
273276 video_block = dominate .tags .div (** root_video_block_attrs )
@@ -304,8 +307,8 @@ def _format_audio(self, block):
304307 if not media_url .hostname .endswith (".tumblr.com" ):
305308 return self ._audiovisual_link_block_fallback (
306309 block ,
307- title = self .localizer [ "error_link_block_fallback_native_audio_player_non_tumblr_source" ] , # type: ignore
308- description = self .localizer [ "audio_link_block_fallback_description" ] , # type: ignore
310+ title = i18n . translate ( self .localizer , "error_link_block_fallback_native_audio_player_non_tumblr_source" ) , # type: ignore
311+ description = i18n . translate ( self .localizer , "audio_link_block_fallback_description" ) , # type: ignore
309312 site_name = media_url .hostname ,
310313 )
311314
@@ -333,7 +336,7 @@ def _format_audio(self, block):
333336 dominate .tags .img (
334337 src = self .url_handler (block .poster [0 ].url ),
335338 srcset = ", " .join (image .create_srcset (block .poster , self .url_handler )),
336- alt = block .title or self .localizer [ "fallback_audio_block_thumbnail_alt_text" ] ,
339+ alt = block .title or i18n . translate ( self .localizer , "fallback_audio_block_thumbnail_alt_text" ) ,
337340 sizes = "(max-width: 540px) 100vh, 540px" ,
338341 cls = "ab-poster" ,
339342 )
@@ -362,14 +365,14 @@ def _format_audio(self, block):
362365 if self .forbid_external_iframes and (block .embed_html or block .embed_url ):
363366 return self ._audiovisual_link_block_fallback (
364367 block ,
365- self .localizer [ "link_block_fallback_embeds_are_disabled" ] , # type: ignore
366- self .localizer [ "audio_link_block_fallback_description" ] , # type: ignore
368+ i18n . translate ( self .localizer , "link_block_fallback_embeds_are_disabled" ) , # type: ignore
369+ i18n . translate ( self .localizer , "audio_link_block_fallback_description" ) , # type: ignore
367370 )
368371 else :
369372 return self ._audiovisual_link_block_fallback (
370373 block ,
371- self .localizer [ "error_audio_link_block_fallback_heading" ] , # type: ignore
372- self .localizer [ "audio_link_block_fallback_description" ] , # type: ignore
374+ i18n . translate ( self .localizer , "error_audio_link_block_fallback_heading" ) , # type: ignore
375+ i18n . translate ( self .localizer , "audio_link_block_fallback_description" ) , # type: ignore
373376 )
374377
375378 audio_block = dominate .tags .div (cls = "audio-block" )
@@ -402,7 +405,9 @@ def _format_poll(self, block):
402405 f"width: { round ((votes [1 ]/ block .total_votes ) * 100 , 3 )} %;"
403406 )
404407
405- dominate .tags .p (votes [1 ], cls = "vote-count" )
408+ dominate .tags .p (
409+ i18n .format_decimal (self .localizer , "poll-choice-vote-count" , votes [1 ]), cls = "vote-count"
410+ )
406411
407412 poll_choices .add (poll_choice )
408413
@@ -425,7 +430,14 @@ def _format_poll(self, block):
425430
426431 if block .votes :
427432 poll_metadata .add (
428- dominate .tags .span (self .localizer ["plural_poll_total_votes" ](block .total_votes )),
433+ dominate .tags .span (
434+ i18n .translate (
435+ self .localizer ,
436+ "plural_poll_total_votes" ,
437+ number = block .total_votes ,
438+ votes = i18n .format_decimal (self .localizer , "poll_votes" , block .total_votes ),
439+ )
440+ ),
429441 dominate .tags .span ("•" , cls = "separator" ),
430442 )
431443
@@ -434,31 +446,37 @@ def _format_poll(self, block):
434446 if expiration > now :
435447 # Build time duration string
436448 remaining_time = expiration - now
437- duration_string = self .localizer [ "format_duration_func" ]( remaining_time ) # type: ignore
449+ duration_string = i18n . format_duration ( self .localizer , "poll_duration" , remaining_time ) # type: ignore
438450
439451 poll_metadata .add (
440452 dominate .tags .span (
441453 dominate .util .raw (
442- self .localizer ["poll_remaining_time" ].format ( # type: ignore
443- duration = HTMLTimeTag (
444- duration_string , datetime = helpers .build_duration_string (remaining_time )
445- ).render (pretty = False )
454+ i18n .translate (
455+ self .localizer ,
456+ "poll_remaining_time" ,
457+ duration = (
458+ HTMLTimeTag (
459+ duration_string , datetime = helpers .build_duration_string (remaining_time )
460+ ).render (pretty = False )
461+ ),
446462 )
447463 )
448464 )
449465 )
450466
451467 else :
452- human_readable_expiration = self .localizer [ "format_datetime_func" ]( expiration ) # type: ignore
468+ human_readable_expiration = i18n . format_datetime ( self .localizer , "poll_ended_on" , expiration ) # type: ignore
453469 formatted_expiration = expiration .strftime ("%Y-%m-%dT%H:%M" )
454470
455471 poll_metadata .add (
456472 dominate .tags .span (
457473 dominate .util .raw (
458- self .localizer ["poll_ended_on" ].format ( # type: ignore
474+ i18n .translate (
475+ self .localizer ,
476+ "poll_ended_on" ,
459477 ended_date = HTMLTimeTag (human_readable_expiration , datetime = formatted_expiration ).render (
460478 pretty = False
461- )
479+ ),
462480 )
463481 )
464482 )
0 commit comments