Class: Jekyll::L10n::PageTranslationLoader
- Inherits:
-
Object
- Object
- Jekyll::L10n::PageTranslationLoader
- Defined in:
- lib/jekyll-l10n/translation/page_translation_loader.rb
Overview
Loads and merges page-specific and compendium translations.
PageTranslationLoader combines compendium (site-wide) translations with page-specific translations for a given locale and URL. It loads both translation sources from PO files, merges them (page-specific takes precedence), and returns the combined translation hash for use by HtmlTranslator.
Key responsibilities:
-
Load compendium translations for a locale
-
Convert page URLs to PO file paths
-
Load page-specific translations
-
Merge compendium and page-specific translations
-
Filter empty translations (untranslated entries)
-
Log loading progress at debug level
Class Method Summary collapse
- .construct_po_page_path(url) ⇒ Object
-
.load(site, locale, original_url, config) ⇒ Hash
Load and merge translations for a page in a specific locale.
Class Method Details
.construct_po_page_path(url) ⇒ Object
60 61 62 |
# File 'lib/jekyll-l10n/translation/page_translation_loader.rb', line 60 def self.construct_po_page_path(url) UrlPathBuilder.url_to_po_page_path(url) end |
.load(site, locale, original_url, config) ⇒ Hash
Load and merge translations for a page in a specific locale.
Loads the compendium (site-wide) translations and page-specific translations, merges them (page-specific entries override compendium), and returns the combined hash. Filters out untranslated entries (empty msgstr).
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/jekyll-l10n/translation/page_translation_loader.rb', line 44 def self.load(site, locale, original_url, config) po_manager = PoFileManager.new(site, config.locales_dir) page_path = construct_po_page_path(original_url) compendium = po_manager.load_compendium(locale) log_compendium_loaded(locale, compendium) page_specific = po_manager.load_po_file(locale, page_path) log_page_specific_loaded(page_path, page_specific) translations = compendium.merge(page_specific) log_translations_merged(translations) translations.reject { |_msgid, msgstr| msgstr.empty? } end |