-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/i18n yaml inheritance #550
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4371575
defensive coding of edition i18n: https://github.com/metanorma/isodoc…
opoudjis 57fbc82
iterate through all available i18n languages: https://github.com/meta…
opoudjis 81e0f55
custom-charset is a comma-delimited list of pairs in presentation met…
opoudjis 034e767
debug: metanorma/metanorma#339
opoudjis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,10 @@ def bibdata(docxml) | |
"</localized-strings>" | ||
end | ||
|
||
def extension_insert(docxml, path = []) | ||
ins = docxml.at(ns("//metanorma-extension")) || | ||
docxml.at(ns("//bibdata"))&.after("<metanorma-extension/>")&.next_element || | ||
docxml.root.elements.first.before("<metanorma-extension/>").previous_element | ||
def extension_insert(xml, path = []) | ||
ins = xml.at(ns("//metanorma-extension")) || | ||
xml.at(ns("//bibdata"))&.after("<metanorma-extension/>")&.next_element || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [81/80] |
||
xml.root.elements.first.before("<metanorma-extension/>").previous_element | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [81/80] |
||
path.each do |n| | ||
ins = ins.at(ns("./#{n}")) || ins.add_child("<#{n}/>").first | ||
end | ||
|
@@ -39,24 +39,24 @@ def passthrough_xslt | |
@output_formats.empty? and return nil | ||
@output_formats.each_key.with_object([]) do |k, m| | ||
m << <<~XSLT | ||
<preprocess-xslt format="#{k}"> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0"> | ||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/> | ||
<xsl:strip-space elements="*"/> | ||
<xsl:template match="@* | node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@* | node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
<xsl:template match="*[local-name() = 'passthrough']"> | ||
<xsl:if test="contains(@formats,',#{k},')"> <!-- delimited --> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@* | node()"/> | ||
</xsl:copy> | ||
</xsl:if> | ||
</xsl:template> | ||
</xsl:stylesheet> | ||
</preprocess-xslt> | ||
<preprocess-xslt format="#{k}"> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0"> | ||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/> | ||
<xsl:strip-space elements="*"/> | ||
<xsl:template match="@* | node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@* | node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
<xsl:template match="*[local-name() = 'passthrough']"> | ||
<xsl:if test="contains(@formats,',#{k},')"> <!-- delimited --> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@* | node()"/> | ||
</xsl:copy> | ||
</xsl:if> | ||
</xsl:template> | ||
</xsl:stylesheet> | ||
</preprocess-xslt> | ||
XSLT | ||
end.join("\n") | ||
end | ||
|
@@ -67,8 +67,7 @@ def preprocess_xslt_read | |
end | ||
|
||
def toc_metadata(docxml) | ||
return unless @tocfigures || @toctables || @tocrecommendations | ||
|
||
@tocfigures || @toctables || @tocrecommendations or return | ||
ins = extension_insert(docxml) | ||
@tocfigures and | ||
ins << "<toc type='figure'><title>#{@i18n.toc_figures}</title></toc>" | ||
|
@@ -89,8 +88,7 @@ def address_precompose(bib) | |
end | ||
|
||
def fonts_metadata(xmldoc) | ||
return unless @fontist_fonts | ||
|
||
@fontist_fonts or return | ||
ins = xmldoc.at(ns("//presentation-metadata")) || | ||
xmldoc.at(ns("//metanorma-extension")) || xmldoc.at(ns("//bibdata")) | ||
CSV.parse_line(@fontist_fonts, col_sep: ";").map(&:strip).each do |f| | ||
|
@@ -144,9 +142,10 @@ def hash_translate(bibdata, hash, xpath, lang = @lang) | |
def edition_translate(bibdata) | ||
x = bibdata.at(ns("./edition")) or return | ||
/^\d+$/.match?(x.text) or return | ||
@i18n.edition_ordinal or return | ||
edn = edition_translate1(x.text.to_i) or return | ||
tag_translate(x, @lang, | ||
@i18n.edition_ordinal.sub(/%(Spellout|Ordinal)?/, | ||
edition_translate1(x.text.to_i))) | ||
@i18n.edition_ordinal.sub(/%(Spellout|Ordinal)?/, edn)) | ||
end | ||
|
||
def edition_translate1(num) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment Branch Condition size for extension_insert is too high. [<3, 16, 6> 17.35/15]
Cyclomatic complexity for extension_insert is too high. [7/6]