Module: Jekyll::L10n::XPathReferenceGenerator
- Defined in:
- lib/jekyll-l10n/utils/xpath_reference_generator.rb
Overview
Generates file location references for extracted strings.
XPathReferenceGenerator creates location references for extracted translatable strings in the format “file_path:line_number”. These references appear as comments in PO files to help translators locate text in the original source. Note: Despite the module name, these are file location references, not XPath expressions.
Key responsibilities:
-
Generate location references from DOM nodes
-
Include file path and line number
-
Format references for PO file comments
Class Method Summary collapse
-
.generate(node, file_path, dest, _attr_name = nil) ⇒ String
Generate a reference for an extracted string.
Class Method Details
.generate(node, file_path, dest, _attr_name = nil) ⇒ String
Generate a reference for an extracted string.
Creates a reference in the format “file_path:line_number” for use as a PO file comment marking where a string was extracted from.
37 38 39 40 41 42 |
# File 'lib/jekyll-l10n/utils/xpath_reference_generator.rb', line 37 def generate(node, file_path, dest, _attr_name = nil) relative_path = UrlPathBuilder.relative_path(file_path, dest) line_number = node.line.to_s "#{relative_path}:#{line_number}" end |