Loading ...
Sorry, an error occurred while loading the content.

localization with separate language files

Expand Messages
  • odekij61
    Hello, Currently I have one external variables file that stores all boilerplate text for 15 languages. I use the xsl:include statement as the first thing in my
    Message 1 of 4 , Feb 16 2:34 PM
    • 0 Attachment
      Hello,

      Currently I have one external variables file that stores all
      boilerplate text for 15 languages.
      I use the xsl:include statement as the first thing in my main
      stylesheet. <xsl:include href='fo-variables.xsl'/>

      I would like to change this to a separate file for every language to
      ease in translating new words.

      I would like to do this:
      <xsl:if test="@language='french'"><xsl:include
      href='french.xsl'/></xsl:if>
      <xsl:if test="@language='greek'"><xsl:include href='greek.xsl'/></xsl:if>

      My problem is it gives the following error: "Keyword xsl:stylesheet
      may not contain xsl:if"

      How do I do an if statement or choose statement to only include the
      corresponding language file?

      Thanks,
      Jeremy
    • Eliot Kimber
      ... You can t. A better way to approach this problem is probably to use a separate XML document with the translations that you then get as needed, rather than
      Message 2 of 4 , Feb 16 2:55 PM
      • 0 Attachment
        odekij61 wrote:

        > Hello,
        >
        > Currently I have one external variables file that stores all
        > boilerplate text for 15 languages.
        > I use the xsl:include statement as the first thing in my main
        > stylesheet. <xsl:include href='fo-variables.xsl'/>
        >
        > I would like to change this to a separate file for every language to
        > ease in translating new words.
        >
        > I would like to do this:
        > <xsl:if test="@language='french'"><xsl:include
        > href='french.xsl'/></xsl:if>
        > <xsl:if test="@language='greek'"><xsl:include href='greek.xsl'/></xsl:if>
        >
        > My problem is it gives the following error: "Keyword xsl:stylesheet
        > may not contain xsl:if"
        >
        > How do I do an if statement or choose statement to only include the
        > corresponding language file?

        You can't.

        A better way to approach this problem is probably to use a separate XML
        document with the translations that you then get as needed, rather than
        using statically-defined variables. For example, if you name your files
        with the language code, then you can do something like this:

        <xsl:variable name="langCode" select="/*/@xml:lang"/>

        <xsl:variable name="boiler-plate-item-one"
        select="document(concat('trans/boilerplate_',
        $langCode,
        '.xml'),.)/boilerplate[@id = 'item-01']/>

        This will select the <boilerplate> element with the ID "item-01" from
        the file "./trans/boilerplate_zh-CN.xml" [relative to the current
        document, leave out the ",." parameter of document() if you want the URL
        to be relative to the stylesheet] if the value of the root element's
        xml:lang= attribute is "zh-CN".

        Cheers,

        Eliot
        --
        W. Eliot Kimber
        Professional Services
        Innodata Isogen
        9030 Research Blvd, #410
        Austin, TX 78758
        (512) 372-8122

        eliot@...
        www.innodata-isogen.com
      • odekij61
        ... to ... href= greek.xsl / ... xsl:stylesheet ... the ... XML ... than ... files ... item-01 ]/ ... from ... URL ... element s ... Hello, Thanks
        Message 3 of 4 , Feb 17 12:39 PM
        • 0 Attachment
          --- In XSL-FO@yahoogroups.com, Eliot Kimber <ekimber@i...> wrote:
          > odekij61 wrote:
          >
          > > Hello,
          > >
          > > Currently I have one external variables file that stores all
          > > boilerplate text for 15 languages.
          > > I use the xsl:include statement as the first thing in my main
          > > stylesheet. <xsl:include href='fo-variables.xsl'/>
          > >
          > > I would like to change this to a separate file for every language
          to
          > > ease in translating new words.
          > >
          > > I would like to do this:
          > > <xsl:if test="@language='french'"><xsl:include
          > > href='french.xsl'/></xsl:if>
          > > <xsl:if test="@language='greek'"><xsl:include
          href='greek.xsl'/></xsl:if>
          > >
          > > My problem is it gives the following error: "Keyword
          xsl:stylesheet
          > > may not contain xsl:if"
          > >
          > > How do I do an if statement or choose statement to only include
          the
          > > corresponding language file?
          >
          > You can't.
          >
          > A better way to approach this problem is probably to use a separate
          XML
          > document with the translations that you then get as needed, rather
          than
          > using statically-defined variables. For example, if you name your
          files
          > with the language code, then you can do something like this:
          >
          > <xsl:variable name="langCode" select="/*/@xml:lang"/>
          >
          > <xsl:variable name="boiler-plate-item-one"
          > select="document(concat('trans/boilerplate_',
          > $langCode,
          > '.xml'),.)/boilerplate[@id =
          'item-01']/>
          >
          > This will select the <boilerplate> element with the ID "item-01"
          from
          > the file "./trans/boilerplate_zh-CN.xml" [relative to the current
          > document, leave out the ",." parameter of document() if you want the
          URL
          > to be relative to the stylesheet] if the value of the root
          element's
          > xml:lang= attribute is "zh-CN".
          >
          > Cheers,
          >
          > Eliot
          > --
          > W. Eliot Kimber
          > Professional Services
          > Innodata Isogen
          > 9030 Research Blvd, #410
          > Austin, TX 78758
          > (512) 372-8122
          >
          > eliot@i...
          > www.innodata-isogen.com

          Hello,

          Thanks for your help. I got it working! I am not using the xml:lang
          attribute, but I got it working with my @language attribute.

          Thanks,
          Jeremy Odekirk
        • Ronald Muller
          We use a complete different solution after trying several others (including Eliot s suggestion): We write the XSLT documents using JSP (and using the I18n tag
          Message 4 of 4 , Mar 5, 2004
          • 0 Attachment
            We use a complete different solution after trying several others (including Eliot's suggestion):

            We write the XSLT documents using JSP (and using the I18n tag library), for every locale a different document is generated and cached as javax.xml.transform.Templates objects. This works great, the only disadvantage might be that it is a Java based solution.

            Regards,

            Ronald Muller
            XIAM Solutions B.V.
            Product Content Management and e-Business Solutions
            rmuller@...

            ----- Original Message -----
            From: Eliot Kimber
            To: XSL-FO@yahoogroups.com
            Sent: Monday, February 16, 2004 11:55 PM
            Subject: Re: [XSL-FO] localization with separate language files


            odekij61 wrote:

            > Hello,
            >
            > Currently I have one external variables file that stores all
            > boilerplate text for 15 languages.
            > I use the xsl:include statement as the first thing in my main
            > stylesheet. <xsl:include href='fo-variables.xsl'/>
            >
            > I would like to change this to a separate file for every language to
            > ease in translating new words.
            >
            > I would like to do this:
            > <xsl:if test="@language='french'"><xsl:include
            > href='french.xsl'/></xsl:if>
            > <xsl:if test="@language='greek'"><xsl:include href='greek.xsl'/></xsl:if>
            >
            > My problem is it gives the following error: "Keyword xsl:stylesheet
            > may not contain xsl:if"
            >
            > How do I do an if statement or choose statement to only include the
            > corresponding language file?

            You can't.

            A better way to approach this problem is probably to use a separate XML
            document with the translations that you then get as needed, rather than
            using statically-defined variables. For example, if you name your files
            with the language code, then you can do something like this:

            <xsl:variable name="langCode" select="/*/@xml:lang"/>

            <xsl:variable name="boiler-plate-item-one"
            select="document(concat('trans/boilerplate_',
            $langCode,
            '.xml'),.)/boilerplate[@id = 'item-01']/>

            This will select the <boilerplate> element with the ID "item-01" from
            the file "./trans/boilerplate_zh-CN.xml" [relative to the current
            document, leave out the ",." parameter of document() if you want the URL
            to be relative to the stylesheet] if the value of the root element's
            xml:lang= attribute is "zh-CN".

            Cheers,

            Eliot
            --
            W. Eliot Kimber
            Professional Services
            Innodata Isogen
            9030 Research Blvd, #410
            Austin, TX 78758
            (512) 372-8122

            eliot@...
            www.innodata-isogen.com


            Yahoo! Groups Sponsor
            ADVERTISEMENT





            ------------------------------------------------------------------------------
            Yahoo! Groups Links

            a.. To visit your group on the web, go to:
            http://groups.yahoo.com/group/XSL-FO/

            b.. To unsubscribe from this group, send an email to:
            XSL-FO-unsubscribe@yahoogroups.com

            c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.