Class: Jekyll::L10n::RegenerationChecker
- Inherits:
-
Object
- Object
- Jekyll::L10n::RegenerationChecker
- Defined in:
- lib/jekyll-l10n/jekyll/regeneration_checker.rb
Overview
Regeneration Checker - Optimizes incremental builds by skipping unchanged pages
This class implements incremental build optimization for localized pages. When Jekyll’s incremental build mode is enabled, it checks whether a specific locale variant of a page needs to be regenerated based on source modification times.
The checker compares modification times of:
-
Source page file
-
Page-specific PO translation file
-
Compendium (shared translations) PO file
-
Jekyll configuration (_config.yml)
If any of these are newer than the output HTML, the page is regenerated. This significantly speeds up rebuilds when only a few files have changed.
Instance Method Summary collapse
-
#initialize(site, locales_dir = DEFAULT_LOCALES_DIR) ⇒ RegenerationChecker
constructor
Initialize the regeneration checker.
-
#should_regenerate?(page, locale) ⇒ Boolean
Determine if a localized page variant should be regenerated.
Constructor Details
#initialize(site, locales_dir = DEFAULT_LOCALES_DIR) ⇒ RegenerationChecker
Initialize the regeneration checker
38 39 40 41 42 43 |
# File 'lib/jekyll-l10n/jekyll/regeneration_checker.rb', line 38 def initialize(site, locales_dir = DEFAULT_LOCALES_DIR) @site = site @locales_dir = locales_dir @source = SiteConfigAccessor.source(@site) @destination = @site&.config&.dig('destination') || '' end |
Instance Method Details
#should_regenerate?(page, locale) ⇒ Boolean
Determine if a localized page variant should be regenerated
Returns true if:
-
Incremental builds are disabled (always regenerate)
-
Output file doesn’t exist yet
-
Source page has been modified since output was generated
-
PO translation files have been modified since output was generated
-
Jekyll configuration has been modified since output was generated
Returns false if incremental builds are enabled and output is up-to-date.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jekyll-l10n/jekyll/regeneration_checker.rb', line 59 def should_regenerate?(page, locale) return true unless incremental_enabled? return true unless dest_path_exists?(page, locale) dest_mtime = File.mtime(dest_path(page, locale)) source_modified?(page, dest_mtime) || po_files_modified?(page, locale, dest_mtime) || config_modified?(dest_mtime) end |