[Libosinfo] [PATCH 3/5] install-config: Drop support for encoding in l10n params

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Fri Dec 28 23:14:04 UTC 2012


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

This doesn't just simplify existing scripts but will also make it easier
to port these l10n mapping to datamaps.
---
 data/install-scripts/fedora.xml           | 27 ++-------------------------
 data/install-scripts/windows-unattend.xml | 30 ++----------------------------
 osinfo/osinfo_install_config.c            | 15 +++++++--------
 tools/osinfo-install-script.c             |  2 +-
 4 files changed, 12 insertions(+), 62 deletions(-)

diff --git a/data/install-scripts/fedora.xml b/data/install-scripts/fedora.xml
index 99218cd..a7c30e8 100644
--- a/data/install-scripts/fedora.xml
+++ b/data/install-scripts/fedora.xml
@@ -60,17 +60,7 @@
 	</xsl:template>
 
         <xsl:template name="country-from-keyboard">
-          <xsl:variable name="locale">
-            <xsl:choose>
-              <xsl:when test="contains(config/l10n-keyboard,'.')">
-                <xsl:value-of select="substring-before(config/l10n-keyboard,'.')"/>
-              </xsl:when>
-              <xsl:otherwise>
-                <xsl:value-of select="config/l10n-keyboard"/>
-              </xsl:otherwise>
-            </xsl:choose>
-          </xsl:variable>
-          <xsl:value-of select="substring-after($locale,'_')"/>
+          <xsl:value-of select="substring-after(config/l10n-keyboard,'_')"/>
         </xsl:template>
 
 	<xsl:template name="keyboard">
@@ -261,20 +251,7 @@ reboot
 	</xsl:template>
 
         <xsl:template name="country-from-keyboard">
-          <xsl:variable name="locale">
-            <xsl:choose>
-              <xsl:when test="contains(config/l10n-keyboard,'.')">
-                <xsl:value-of select="substring-before(config/l10n-keyboard,'.')"/>
-              </xsl:when>
-              <xsl:otherwise>
-                <xsl:value-of select="config/l10n-keyboard"/>
-              </xsl:otherwise>
-            </xsl:choose>
-          </xsl:variable>
-          <xsl:variable name="country">
-            <xsl:value-of select="substring-after($locale,'_')"/>
-          </xsl:variable>
-          <xsl:value-of select="translate($country,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
+          <xsl:value-of select="substring-after(config/l10n-keyboard,'_')"/>
         </xsl:template>
 
 	<xsl:template name="keyboard">
diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml
index de84b65..db08ac2 100644
--- a/data/install-scripts/windows-unattend.xml
+++ b/data/install-scripts/windows-unattend.xml
@@ -36,20 +36,7 @@
         </xsl:template>
 
         <xsl:template name="language">
-          <xsl:variable name="language">
-            <xsl:value-of select="config/l10n-language"/>
-          </xsl:variable>
-          <xsl:variable name="formatted-language">
-            <xsl:value-of select="translate($language,'_','-')"/>
-          </xsl:variable>
-          <xsl:choose>
-            <xsl:when test="contains($formatted-language,'.')">
-              <xsl:value-of select="substring-before($formatted-language,'.')"/>
-            </xsl:when>
-            <xsl:otherwise>
-              <xsl:value-of select="$formatted-language"/>
-            </xsl:otherwise>
-          </xsl:choose>
+          <xsl:value-of select="translate(config/l10n-language,'_','-')"/>
         </xsl:template>
 
 	<xsl:template name="arch">
@@ -269,20 +256,7 @@
       </xsl:template>
 
       <xsl:template name="language">
-        <xsl:variable name="language">
-          <xsl:value-of select="config/l10n-language"/>
-        </xsl:variable>
-        <xsl:variable name="formatted-language">
-          <xsl:value-of select="translate($language,'_','-')"/>
-        </xsl:variable>
-        <xsl:choose>
-          <xsl:when test="contains($formatted-language,'.')">
-            <xsl:value-of select="substring-before($formatted-language,'.')"/>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:value-of select="$formatted-language"/>
-          </xsl:otherwise>
-        </xsl:choose>
+       <xsl:value-of select="translate(config/l10n-language,'_','-')"/>
       </xsl:template>
 
       <xsl:template name="arch">
diff --git a/osinfo/osinfo_install_config.c b/osinfo/osinfo_install_config.c
index 46d4999..8572e1a 100644
--- a/osinfo/osinfo_install_config.c
+++ b/osinfo/osinfo_install_config.c
@@ -153,13 +153,13 @@ osinfo_install_config_init (OsinfoInstallConfig *config)
 
     osinfo_entity_set_param(OSINFO_ENTITY(config),
                             OSINFO_INSTALL_CONFIG_PROP_L10N_KEYBOARD,
-                            "en_US.UTF-8");
+                            "en_US");
     osinfo_entity_set_param(OSINFO_ENTITY(config),
                             OSINFO_INSTALL_CONFIG_PROP_L10N_TIMEZONE,
                             "America/New_York");
     osinfo_entity_set_param(OSINFO_ENTITY(config),
                             OSINFO_INSTALL_CONFIG_PROP_L10N_LANGUAGE,
-                            "en_US.UTF-8");
+                            "en_US");
 
     for (i = 0 ; i < sizeof(pass)-1 ; i++) {
         gint val = g_random_int_range(0, sizeof(valid));
@@ -179,9 +179,8 @@ osinfo_install_config_init (OsinfoInstallConfig *config)
  *
  * Construct a new install configuration with default values for
  * language, keyboard, timezone and admin password. The default values
- * are to use an 'en_US.UTF-8' language and keyboard, and an
- * 'America/New_York' timezone. The admin password is set to a random
- * 8 character password.
+ * are to use an 'en_US' language and keyboard, and an 'America/New_York'
+ * timezone. The admin password is set to a random 8 character password.
  *
  * Returns: (transfer full): an install configuration with default
  * values
@@ -240,7 +239,6 @@ const gchar *osinfo_install_config_get_hardware_arch(OsinfoInstallConfig *config
                                          OSINFO_INSTALL_CONFIG_PROP_HARDWARE_ARCH);
 }
 
-
 /**
  * osinfo_install_config_set_l10n_keyboard:
  * @config: the install config
@@ -277,8 +275,9 @@ const gchar *osinfo_install_config_get_l10n_keyboard(OsinfoInstallConfig *config
  *
  * https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Locale-Names.html
  *
- * Encoding is accepted but option while variant is not yet supported. For example, both
- * 'pt_BR' and 'pt_BR.utf8' are accepted as the language codes for Brazilian Portuguese.
+ * Encoding and variant are (at least for now) not supported. For example,
+ * 'pt_BR' is accepted is accepted as the language codes for Brazilian Portuguese
+ * but 'pt_BR.utf8' is not.
  */
 void osinfo_install_config_set_l10n_language(OsinfoInstallConfig *config,
                                              const gchar *language)
diff --git a/tools/osinfo-install-script.c b/tools/osinfo-install-script.c
index 5a766ba..2311e68 100644
--- a/tools/osinfo-install-script.c
+++ b/tools/osinfo-install-script.c
@@ -325,7 +325,7 @@ The following usage generates a Fedora 16 kickstart script
          --profile jeos \
          --config l10n-timezone=GMT \
          --config l10n-keyboard=uk \
-         --config l10n-language=en_GB.UTF-8 \
+         --config l10n-language=en_GB \
          --config admin-password=123456 \
          --config user-login=berrange \
          --config user-password=123456 \
-- 
1.8.0.2




More information about the Libosinfo mailing list