Class: Jekyll::L10n::PostWriteProcessor
- Inherits:
-
Object
- Object
- Jekyll::L10n::PostWriteProcessor
- Defined in:
- lib/jekyll-l10n/jekyll/post_write_processor.rb
Overview
Post-Write Processor - Extracts strings and applies translations after Jekyll build
This class handles the final localization phase of the Jekyll build process. It runs after Jekyll has written all HTML files to disk (via the site:post_write hook).
The processor coordinates two main operations:
-
String Extraction: Finds new and modified translatable strings in generated HTML
-
HTML Reprocessing: Applies translations to localized page variants
Key responsibilities:
-
Invoke the Extractor to scan generated HTML for translatable content
-
Update PO files with new/changed strings
-
Reprocess localized HTML if PO files were modified
-
Provide logging of extraction results
This is invoked automatically by Jekyll during the post_write phase and should not be called directly in most use cases.
This runs in phase 5 of the Jekyll build pipeline (Post-Write Phase). See the “Build Pipeline” section in lib/jekyll-l10n.rb for the complete workflow.
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(site) ⇒ PostWriteProcessor
constructor
Initialize the post-write processor.
-
#process_localizations ⇒ void
Process all localizations for the site.
Constructor Details
#initialize(site) ⇒ PostWriteProcessor
Initialize the post-write processor
46 47 48 |
# File 'lib/jekyll-l10n/jekyll/post_write_processor.rb', line 46 def initialize(site) @site = site end |
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
41 42 43 |
# File 'lib/jekyll-l10n/jekyll/post_write_processor.rb', line 41 def site @site end |
Instance Method Details
#process_localizations ⇒ void
This is automatically called by Jekyll’s site:post_write hook
This method returns an undefined value.
Process all localizations for the site
Runs the extraction and reprocessing pipeline:
-
Extracts translatable strings from all HTML files
-
Updates PO files with new entries and modified translations
-
If PO files were created or updated, reprocess localized pages to apply translations
Returns early with no output if no pages are marked for localization.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/jekyll-l10n/jekyll/post_write_processor.rb', line 61 def process_localizations return unless any_pages_localized? extractor = Extractor.new(@site) extraction_result = extractor.extract_site # Reprocess localized HTML if PO files were created/updated return unless extraction_result && extraction_result[:po_files_created].positive? reprocessor = PostWriteHtmlReprocessor.new(@site) reprocessor.reprocess_localized_pages end |