[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: ePerl and language-dependent output

On Mon, Jul 17, 2000 at 01:31:56PM +0200, Stephan Petersen wrote:

> But when I simply enclose this into <d: ... >, like this
> <d:
> <set-var myvar="xyz">
> <perl>
>     my $myperlvar = qq/<get-var myvar>/;
>     print "The value of myperlvar is $myperlvar\n";
> </perl>
> >
> I get an ePerl error (Can't locate object method "is" via package
> "xyz" at ...).

The problem is that quotes in attributes are used to group words and so
must be removed in output.
For instance, what output do you expect with
   <e: "Hello, world!">

You should use the short form only with few words, as above. And write
  <set-var myvar="xyz">
      my $myperlvar = qq/<get-var myvar>/;
      print "The value of myperlvar is $myperlvar\n";

> Apart from the question where I made a mistake (conceptually?), what
> is the best way to solve the original problem, i.e. making the output
> from ePerl language-dependent? The rest of the multilingual features
> of wml work fine for me, btw.

Adding this feature has never gone to the top of my TODO list.
It is not very hard, you simply have to manage a stack of current
languages.  When entering in a language area, put its name onto the
stack, and pop up when leaving area. So current language is always the
value found at top of the stack.

If you want, try the code below.  The lang:current variable should
always contain current language.

  #use wml::std::lang
  <set-var __lang:stack=>
  <define-tag lang:push whitespace=delete>
    <set-var lang:current="%0">
    <array-push __lang:stack %0>
  <define-tag lang:pop whitespace=delete>
    <set-var lang:current="<array-pop __lang:stack>">
  <define-tag lang:new>
  <preserve id short>
  <set-var short=*>
  <set-var %attributes>
  <set-var __ok=1>\
  <set-var __i=0>\
  <while <get-var __languages[<get-var __i>]>>\
     <ifeq "<get-var __languages[<get-var __i>]>" "<get-var id>" <set-var __ok=0>>
  <increment __i>
  <when <eq "<get-var __ok>" 1>>
    <array-push __languages <get-var id>>
          "=LT=define-tag lang:<get-var id>: attributes=verbatim>[LANG_<upcase <get-var id>>:=LT=lang:push <get-var id>>%%attributes=LT=lang:pop>:]=LT=/define-tag>
           =LT=define-tag lang:<get-var id> endtag=required>[LANG_<upcase <get-var id>>:=LT=lang:push <get-var id>>%%body=LT=lang:pop>:]=LT=/define-tag>" 
       "=LT=" "<"
    <when <not <get-var short>>>
          "=LT=define-tag <get-var id>: attributes=verbatim>[LANG_<upcase <get-var id>>:=LT=lang:push <get-var id>>%%attributes=LT=lang:pop>:]=LT=/define-tag>
           =LT=define-tag <get-var id> endtag=required>[LANG_<upcase <get-var id>>:=LT=lang:push <get-var id>>%%body=LT=lang:pop>:]=LT=/define-tag>" 
       "=LT=" "<"
  <restore  id short>

Denis Barbier
WML Maintainer
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com