[virt-tools-list] [libosinfo v3] install-scripts: Translate lang format when needed
Fabiano Fidêncio
fabiano at fidencio.org
Thu Nov 15 17:18:37 UTC 2012
Add this translation in the windows template file because the script
must have the language set using non-linux standard format.
Windows will use, for instance, en-US instead of en_US or en_US.utf8.
---
data/install-scripts/windows-unattend.xml | 56 ++++++++++++++++++++++++++-----
osinfo/osinfo_install_config.c | 10 +++++-
2 files changed, 57 insertions(+), 9 deletions(-)
diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml
index d3b2df5..56672b9 100644
--- a/data/install-scripts/windows-unattend.xml
+++ b/data/install-scripts/windows-unattend.xml
@@ -32,6 +32,26 @@
</xsl:choose>
</xsl:template>
+ <xsl:template name="language">
+ <xsl:variable name="l10n-language">
+ <xsl:value-of select="config/l10n-language"/>
+ </xsl:variable>
+ <xsl:variable name="new-l10n-language">
+ <xsl:value-of select="translate($l10n-language,'_','-')"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="contains($new-l10n-language,'.')">
+ <xsl:variable name="windows-language">
+ <xsl:value-of select="substring-before($new-l10n-language,'.')"/>
+ </xsl:variable>
+ <xsl:value-of select="$windows-language"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$new-l10n-language"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
<xsl:template name="arch">
<xsl:choose>
<xsl:when test="count(config/hardware-arch) > 0">
@@ -99,11 +119,11 @@
<xsl:call-template name="arch"/>
</xsl:attribute>
<SetupUILanguage>
- <UILanguage><xsl:value-of select="config/l10n-language"/></UILanguage>
+ <UILanguage><xsl:call-template name="language"/></UILanguage>
</SetupUILanguage>
- <SystemLocale><xsl:value-of select="config/l10n-language"/></SystemLocale>
- <UILanguage><xsl:value-of select="config/l10n-language"/></UILanguage>
- <UserLocale><xsl:value-of select="config/l10n-language"/></UserLocale>
+ <SystemLocale><xsl:call-template name="language"/></SystemLocale>
+ <UILanguage><xsl:call-template name="language"/></UILanguage>
+ <UserLocale><xsl:call-template name="language"/></UserLocale>
</component>
</settings>
<settings pass="oobeSystem">
@@ -213,6 +233,26 @@
</xsl:choose>
</xsl:template>
+ <xsl:template name="language">
+ <xsl:variable name="l10n-language">
+ <xsl:value-of select="config/l10n-language"/>
+ </xsl:variable>
+ <xsl:variable name="new-l10n-language">
+ <xsl:value-of select="translate($l10n-language,'_','-')"/>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="contains($new-l10n-language,'.')">
+ <xsl:variable name="windows-language">
+ <xsl:value-of select="substring-before($new-l10n-language,'.')"/>
+ </xsl:variable>
+ <xsl:value-of select="$windows-language"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$new-l10n-language"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
<xsl:template name="arch">
<xsl:choose>
<xsl:when test="config/hardware-arch = 'x86_64'">
@@ -283,11 +323,11 @@
<xsl:call-template name="arch"/>
</xsl:attribute>
<SetupUILanguage>
- <UILanguage><xsl:value-of select="config/l10n-language"/></UILanguage>
+ <UILanguage><xsl:call-template name="language"/></UILanguage>
</SetupUILanguage>
- <SystemLocale><xsl:value-of select="config/l10n-language"/></SystemLocale>
- <UILanguage><xsl:value-of select="config/l10n-language"/></UILanguage>
- <UserLocale><xsl:value-of select="config/l10n-language"/></UserLocale>
+ <SystemLocale><xsl:call-template name="language"/></SystemLocale>
+ <UILanguage><xsl:call-template name="language"/></UILanguage>
+ <UserLocale><xsl:call-template name="language"/></UserLocale>
</component>
</settings>
<xsl:if test="os/version > 6.0">
diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
index f146aec..8736ee7 100644
--- a/osinfo/osinfo_install_config.c
+++ b/osinfo/osinfo_install_config.c
@@ -140,7 +140,15 @@ const gchar *osinfo_install_config_get_l10n_keyboard(OsinfoInstallConfig *config
OSINFO_INSTALL_CONFIG_PROP_L10N_KEYBOARD);
}
-
+/**
+ * osinfo_install_config_set_l10n_language:
+ *
+ * Sets the #OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE parameter.
+ *
+ * The expected format to set l10n_language follows the unix standard for
+ * locales, containing or not the encode set after the language (e.g: en_US,
+ * en_US.utf8, pt_BR.iso8859-1)
+ */
void osinfo_install_config_set_l10n_language(OsinfoInstallConfig *config,
const gchar *language)
{
--
1.8.0
More information about the virt-tools-list
mailing list