Skip to content

Commit

Permalink
y2makepot: transform control files into glade compatible format (bnc#…
Browse files Browse the repository at this point in the history
…881278)

so the files can be processed by xgettext (the latest xgettext does
some format validation before processing)

- 3.1.19
  • Loading branch information
lslezak committed Jun 5, 2014
1 parent a1ccdca commit b9230a6
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
2 changes: 2 additions & 0 deletions build-tools/scripts/Makefile.am
Expand Up @@ -11,4 +11,6 @@ pkgdata_SCRIPTS = \
y2makepot \
gettextdomains

dist_control_DATA = control_to_glade.xsl

EXTRA_DIST = $(bin_SCRIPTS) $(pkgdata_SCRIPTS)
41 changes: 41 additions & 0 deletions build-tools/scripts/control_to_glade.xsl
@@ -0,0 +1,41 @@
<!--
Extract translatable strings from a Yast XML control file, output them in the
format accepted by xgettext (Glade compatible XML)
-->

<xsl:stylesheet version="1.0"
xmlns:n="http://www.suse.com/1.0/yast2ns"
xmlns:config="http://www.suse.com/1.0/configns"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes"/>

<!-- attribute definition for <interface> element -->
<xsl:attribute-set name="translatable_label">
<xsl:attribute name="name">label</xsl:attribute>
<xsl:attribute name="translatable">yes</xsl:attribute>
</xsl:attribute-set>

<!-- replace <label> by <property>, keep the original value -->
<xsl:template match="n:label">
<xsl:element name="property" use-attribute-sets="translatable_label">
<xsl:copy-of select="text()"/>
</xsl:element>
</xsl:template>

<!--
replace the root <productDefines> element by <interface>
due to namespace it cannot be used literally
-->
<xsl:template match="/n:productDefines">
<xsl:element name="interface">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>

<!-- remove the remaining non-matched text -->
<xsl:template match="text()">
</xsl:template>

</xsl:stylesheet>

19 changes: 18 additions & 1 deletion build-tools/scripts/y2makepot
Expand Up @@ -16,6 +16,9 @@
CWD=`dirname $0`
. $CWD/gettextdomains

# list of generated files which should be removed at the end
CLEAN_FILES=""

function gettext_call()
{
MODULE=$1
Expand All @@ -41,6 +44,12 @@ function gettext_call()
xgettext_call "$MODULE" "$SOURCE_FILES"
rxgettext_call "$MODULE" "$SOURCE_RUBY_FILES"
fi

if [ -n "$CLEAN_FILES" ]; then
echo "Removing generated files: $CLEAN_FILES"
rm -f $CLEAN_FILES
CLEAN_FILES=""
fi
}

function xgettext_call()
Expand Down Expand Up @@ -147,7 +156,15 @@ function generate_potfiles()
if [[ "$F" =~ \.(erb|rb)$ ]]; then
RUBY_FILES="$RUBY_FILES $F";
else
FILES="$FILES $F" ;
if [[ "$F" =~ \.glade$ ]]; then
echo "Processing $F file..."
GLADE_FILE="$F.translations.glade"
xsltproc /usr/share/YaST2/control/control_to_glade.xsl "$F" > "$GLADE_FILE"
FILES="$FILES $GLADE_FILE" ;
CLEAN_FILES="$CLEAN_FILES $GLADE_FILE" ;
else
FILES="$FILES $F" ;
fi
fi
done

Expand Down
8 changes: 8 additions & 0 deletions package/yast2-devtools.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Jun 5 13:07:52 UTC 2014 - lslezak@suse.cz

- y2makepot: transform control files into glade compatible format
so they can be processed by xgettext (the latest xgettext does
some format validation before processing) (bnc#881278)
- 3.1.19

-------------------------------------------------------------------
Tue Jun 3 15:48:06 UTC 2014 - jreidinger@suse.com

Expand Down
4 changes: 3 additions & 1 deletion package/yast2-devtools.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-devtools
Version: 3.1.18
Version: 3.1.19
Release: 0
Url: http://github.com/yast/yast-devtools

Expand Down Expand Up @@ -143,6 +143,8 @@ EOF
%{_datadir}/YaST2/data/devtools/bin/y2makepot
%{_datadir}/YaST2/data/devtools/bin/gettextdomains
%{_datadir}/YaST2/data/devtools/bin/ycp_puttext
%dir %{_datadir}/YaST2/control/
%{_datadir}/YaST2/control/control_to_glade.xsl


%files -n yast2-buildtools
Expand Down

0 comments on commit b9230a6

Please sign in to comment.