Class: Jekyll::L10n::PostWriteProcessor

Inherits:
Object
  • Object
show all
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:

  1. String Extraction: Finds new and modified translatable strings in generated HTML

  2. 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.

Examples:

Manual invocation (advanced)

processor = PostWriteProcessor.new(site)
processor.process_localizations

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ PostWriteProcessor

Initialize the post-write processor

Parameters:

  • site (Jekyll::Site)

    The Jekyll site object



46
47
48
# File 'lib/jekyll-l10n/jekyll/post_write_processor.rb', line 46

def initialize(site)
  @site = site
end

Instance Attribute Details

#siteObject (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_localizationsvoid

Note:

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:

  1. Extracts translatable strings from all HTML files

  2. Updates PO files with new entries and modified translations

  3. 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