Re: [ACTION-107] Locale Filter

Hi Yves, Shaun, all,

I tried to implement the output of this thread in the spec - see
http://www.w3.org/International/multilingualweb/lt/drafts/its20/its20.html#LocaleFilter
does this look OK for you? David, can you put this on the agenda for
Thursday, in addition to
http://lists.w3.org/Archives/Public/public-multilingualweb-lt/2012Aug/0093.html
just a small slot for people on the call.

Thanks,

Felix

2012/8/6 Yves Savourel <ysavourel@enlaso.com>

> +1.****
>
> ** **
>
> I’ve tried to code the extended filtering and I think it’s working.****
>
> It’s certainly more involved than the basic filtering, but doable.****
>
> ** **
>
> I can’t think of a good reason to keep localeFilterType either.****
>
> ‘include’ should be enough to express all cases.****
>
> ** **
>
> -ys****
>
> ** **
>
> ** **
>
> *From:* Felix Sasaki [mailto:fsasaki@w3.org]
> *Sent:* Friday, August 03, 2012 11:34 AM
>
> *To:* Shaun McCance
> *Cc:* public-multilingualweb-lt@w3.org
> *Subject:* Re: [ACTION-107] Locale Filter****
>
> ** **
>
> +1 - I think you can change the spec text ****
>
> ** **
>
>
> http://www.w3.org/International/multilingualweb/lt/drafts/its20/its20.odd#LocaleFilter
> ****
>
>
> http://www.w3.org/International/multilingualweb/lt/drafts/its20/its20.html#LocaleFilter
> ****
>
> ** **
>
> right away. The "canadian locales" only, independent of the language, is a
> compelling example.****
>
>
> Best,****
>
> ** **
>
> Felix****
>
> 2012/8/3 Shaun McCance <shaunm@gnome.org>****
>
> On Fri, 2012-08-03 at 11:59 -0400, Shaun McCance wrote:
> > On Fri, 2012-08-03 at 11:56 +0200, Felix Sasaki wrote:
> > > Hi Shaun, all,
> > >
> > >
> > > one more aspect about the locale filter data category. Currently we
> > > specify basic filtering
> > > http://tools.ietf.org/html/rfc4647#section-3.3.1
> > > as the method to match locales in the localeFilter rule and in the
> > > content. Would it make sense to use extended filtering
> > > http://tools.ietf.org/html/rfc4647#section-3.3.2
> > > and extended language ranges
> > > http://tools.ietf.org/html/rfc4647#section-2.2
> > > instead?
> > >
> > >
> > > This allows you to specify a language range like de-*-DE , which
> > > matches e.g. de-latn-DE.
> > >
> > >
> > > I have an action item from the i18n core working group to check this.
> >
> >
> http://lists.w3.org/Archives/Public/public-multilingualweb-lt/2012Jul/0184.html
> >
> >   I chose basic filtering because I think the algorithm for
> >   extended filtering is tricky (but not impossible) to do in
> >   XSLT 1.0, at least without EXSLT. Basic filtering is easy.
> >   If anybody feels strongly that we should use extended
> >   filtering, speak up. I'm not really opposed.
> >
> > I can implement the extended filtering algorithm easily in
> > Python for itstool. I was just trying to keep things easy
> > for others. I'd like input from other implementers.****
>
> Actually turned out to not be as difficult as I'd thought to
> implement in XSLT 1.0. Implementation is below. Tested on the
> examples in RFC 4647, but not fully QA'd. No guarantees. Free
> to use, modify, and redistribute without restriction.
>
> Given the ease of implementation, I'm inclined to switch to
> extended filtering. The current examples use "en-CA,fr-CA"
> to restrict to Canadian locales. With extended filtering,
> this is just "*-CA". I suspect restricting to a region will
> be common. Objections?
>
> <xsl:template name="extended-range-filter">
>   <xsl:param name="range"/>
>   <xsl:param name="language"/>
>   <xsl:variable name="range_l"
>                 select="translate($range,
>                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
>                         'abcdefghijklmnopqrstuvwxyz')"/>
>   <xsl:variable name="language_l"
>                 select="translate($language,
>                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
>                         'abcdefghijklmnopqrstuvwxyz')"/>
>   <xsl:variable name="subrange">
>     <xsl:choose>
>       <xsl:when test="contains($range_l, '-')">
>         <xsl:value-of select="substring-before($range_l, '-')"/>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:value-of select="$range_l"/>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:variable>
>   <xsl:variable name="sublanguage">
>     <xsl:choose>
>       <xsl:when test="contains($language_l, '-')">
>         <xsl:value-of select="substring-before($language_l, '-')"/>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:value-of select="$language_l"/>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:variable>
>   <xsl:choose>
>     <xsl:when test="$subrange != $sublanguage and $subrange != '*'">
>       <xsl:text>0</xsl:text>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:call-template name="extended-range-filter-sub">
>         <xsl:with-param name="range" select="$range_l"/>
>         <xsl:with-param name="language" select="$language_l"/>
>       </xsl:call-template>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
> <xsl:template name="extended-range-filter-sub">
>   <xsl:param name="range"/>
>   <xsl:param name="language"/>
>   <xsl:variable name="subrange">
>     <xsl:choose>
>       <xsl:when test="contains($range, '-')">
>         <xsl:value-of select="substring-before($range, '-')"/>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:value-of select="$range"/>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:variable>
>   <xsl:variable name="sublanguage">
>     <xsl:choose>
>       <xsl:when test="contains($language, '-')">
>         <xsl:value-of select="substring-before($language, '-')"/>
>       </xsl:when>
>       <xsl:otherwise>
>         <xsl:value-of select="$language"/>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:variable>
>   <xsl:choose>
>     <xsl:when test="$subrange = ''">
>       <xsl:text>1</xsl:text>
>     </xsl:when>
>     <xsl:when test="$subrange = '*'">
>       <xsl:call-template name="extended-range-filter-sub">
>         <xsl:with-param name="range"
>                         select="substring-after($range, '-')"/>
>         <xsl:with-param name="language" select="$language"/>
>       </xsl:call-template>
>     </xsl:when>
>     <xsl:when test="$sublanguage = ''">
>       <xsl:text>0</xsl:text>
>     </xsl:when>
>     <xsl:when test="$subrange = $sublanguage">
>       <xsl:call-template name="extended-range-filter-sub">
>         <xsl:with-param name="range"
>                         select="substring-after($range, '-')"/>
>         <xsl:with-param name="language"
>                         select="substring-after($language, '-')"/>
>       </xsl:call-template>
>     </xsl:when>
>     <xsl:when test="string-length($sublanguage) = 1">
>       <xsl:text>0</xsl:text>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:call-template name="extended-range-filter-sub">
>         <xsl:with-param name="range" select="$range"/>
>         <xsl:with-param name="language"
>                         select="substring-after($language, '-')"/>
>       </xsl:call-template>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
>
>
> ****
>
>
>
> ****
>
> ** **
>
> --
> Felix Sasaki****
>
> DFKI / W3C Fellow****
>
> ** **
>



-- 
Felix Sasaki
DFKI / W3C Fellow

Received on Tuesday, 7 August 2012 07:29:13 UTC