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

Fabiano Fidêncio fabiano at fidencio.org
Mon Nov 26 23:15:10 UTC 2012


On Fri, Nov 23, 2012 at 1:42 PM, Zeeshan Ali (Khattak)
<zeeshanak at gnome.org> wrote:
> On Fri, Nov 23, 2012 at 5:03 PM, Fabiano Fidêncio <fabiano at fidencio.org> wrote:
>> Add this translation in the windows template file because the script
>> must have the language is being set using
>> https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Locale-Names.html
>> While, for Windows, the standard being used is:
>> https://www.ietf.org/rfc/rfc4646.txt (page 56, Language-Region topic).
>>
>> A practical example is:
>> Windows will use, for Brazilian Portuguese, pt-BR instead of pt_BR.
>> ---
>>  data/install-scripts/windows-unattend.xml | 50 ++++++++++++++++++++++++++-----
>>  osinfo/osinfo_install_config.c            | 14 ++++++++-
>>  2 files changed, 55 insertions(+), 9 deletions(-)
>>
>> diff --git a/data/install-scripts/windows-unattend.xml b/data/install-scripts/windows-unattend.xml
>> index d3b2df5..86031ed 100644
>> --- a/data/install-scripts/windows-unattend.xml
>> +++ b/data/install-scripts/windows-unattend.xml
>> @@ -32,6 +32,23 @@
>>            </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">
>
> Is a new variable really needed? Can't you override the value of
> existing variable?

I tried, but I'm newbie.
If you know a better way to do this, feel free to change the patch and
commit with your name (as it's a really trivial change). :)

>
>> +            <xsl:value-of select="translate($l10n-language,'_','-')"/>
>> +          </xsl:variable>
>> +          <xsl:choose>
>> +            <xsl:when test="contains($new-l10n-language,'.')">
>> +              <xsl:value-of select="substring-before($new-l10n-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 +116,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 +230,23 @@
>>          </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:value-of select="substring-before($new-l10n-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 +317,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..a8a78e0 100644
>> --- a/osinfo/osinfo_install_config.c
>> +++ b/osinfo/osinfo_install_config.c
>> @@ -140,7 +140,19 @@ 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 gettext Locale Names[0]
>> + * standard  with both encoding and variant are accepted but are optional.
>> + *
>> + * For example, 'pt_BR' is used to Brazilian Portuguese. 'pt_BR.utf8' is
>> + * accepted but the encoding part is optional.
>> + *
>> + * [0]: https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Locale-Names.html
>
> This will not translate into footnote (as its meant to be) in the
> generated docs. See if there is any way to create links in gtk-doc. If
> not, you want to inline it.

It's inline now.
Thanks!

>
> Looks good otherwise.
>
> --
> Regards,
>
> Zeeshan Ali (Khattak)
> FSF member#5124


Best Regards,
--
Fabiano Fidêncio




More information about the virt-tools-list mailing list