[virt-tools-list] [libosinfo v3] install-scripts: Translate lang format when needed

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Thu Nov 15 20:22:30 UTC 2012


On Thu, Nov 15, 2012 at 7:18 PM, Fabiano Fidêncio <fabiano at fidencio.org> wrote:
> 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.

This log and the doc comment below could be improved:

* There is no 'unix standard' or 'non-linux standard'.
* You want to point to what you are calling the standard:
https://www.ietf.org/rfc/rfc4646.txt
* The above log still makes it sound like windows is the one thats not
following the standard. You want to point out that although Linux is
not following the standard, why we are expected the string in Linux
format.
* We should probably specify more explitictly that '.utf8' part is
accepted but optional.

> ---
>  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,'.')">

What does 'substring-before' return if there is not '.' ? Just
wondering if its worth it to have this check here.

> +              <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"/>

Are you sure "$" is needed here?

> +            </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
>
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list



-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124




More information about the virt-tools-list mailing list