diff options
author | Edwin Mons <edwin.mons@isode.com> | 2017-11-07 10:46:20 (GMT) |
---|---|---|
committer | Edwin Mons <edwin.mons@isode.com> | 2017-11-07 14:25:40 (GMT) |
commit | f742f3bf00ec35960c2f5e0545eea47a28d8c75d (patch) | |
tree | e06a2b8bdfd6eb16c0573715619b106658326a1a /BuildTools/TranslationCoverage.xslt | |
parent | c29df10f0ab47db63509634fb1661ff55b8b47b3 (diff) | |
download | swift-f742f3bf00ec35960c2f5e0545eea47a28d8c75d.zip swift-f742f3bf00ec35960c2f5e0545eea47a28d8c75d.tar.bz2 |
Analytics for translations
Adds an XSLT that can check coverage of ts files.
Test-Information:
Runs on macOS 10.12 using libxml 20904, libxslt 10129 and libexslt 817
Change-Id: Ia7e66f3ae2e00010b03056db7578f7a2529250c8
Diffstat (limited to 'BuildTools/TranslationCoverage.xslt')
-rw-r--r-- | BuildTools/TranslationCoverage.xslt | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/BuildTools/TranslationCoverage.xslt b/BuildTools/TranslationCoverage.xslt new file mode 100644 index 0000000..4329174 --- /dev/null +++ b/BuildTools/TranslationCoverage.xslt @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + +<!-- + +To use this XSLT, run it with xsltproc: + + xsltproc BuildTools/TranslationCoverage.xslt Swift/Translations/swift_nl.ts + +Supported parameters: + + full if set to 1 or true, generate a full report instead of the default oneliner. + +--> + +<xsl:param name="full" select="'0'" /> +<xsl:param name="filename" /> +<xsl:output method="text" /> + +<xsl:variable name="contexts" select="count(TS/context)"/> +<xsl:variable name="vanished" select="count(TS/context/message/translation[@type = 'vanished'])"/> +<xsl:variable name="obsolete" select="count(TS/context/message/translation[@type = 'obsolete'])"/> +<xsl:variable name="strings" select="count(TS/context/message/source) - $vanished - $obsolete"/> +<xsl:variable name="translations" select="count(TS/context/message/translation[not(@type) and text()])"/> +<xsl:variable name="missing" select="$strings - $translations"/> +<xsl:variable name="percent_done" select="floor($translations div $strings * 100)"/> + +<xsl:template match="/TS"> + <xsl:choose> + <xsl:when test="$full != '0' and $full != 'false'"><xsl:call-template name="full" /></xsl:when> + <xsl:otherwise><xsl:call-template name="terse" /></xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="terse"><xsl:value-of select="$percent_done"/>% complete, <xsl:value-of select="$vanished"/> vanished, <xsl:value-of select="$obsolete"/> obsolete, <xsl:value-of select="$missing"/> missing +</xsl:template> + +<xsl:template name="full"><xsl:if test="$filename">Report for <xsl:value-of select="$filename" />: + +</xsl:if>Contexts: <xsl:value-of select="$contexts"/> +Active Strings: <xsl:value-of select="$strings"/> +Translations: <xsl:value-of select="$translations"/>, <xsl:value-of select="$percent_done"/>% complete +Missing: <xsl:value-of select="$missing"/> +Vanished: <xsl:value-of select="$vanished"/> +Obsolete: <xsl:value-of select="$obsolete"/> + +Note: Strings and Translations do not include vanished or obsolete messages. +</xsl:template> + +</xsl:stylesheet> |