Hi Alex,

Hi Jon,

 do you do if the text to be translated is the result of some function?
 This doesn't seem to work:

 ,(someTextBasedOn X Y Z)

Yes, in this context the comma makes only sense immediately before the
transient symbol.

The comma read macro does nothing else than putting the following
expression into a global idx tree (i.e. into '*Uni'). The 'locale'
function then iterates over this tree, and replace the values of all
symbols with the new translated values.

If you put a list into '*Uni', like in the example above, 'locale'
cannot process it.

Thus, a function can only return a transient symbol (for which hopefully
then a translation exists). You could do

   (de foo ()
      (list ,"My new string" X Y Z) )

Then, if "My new string" exists in the "loc/xx" file, it will behave as

But perhaps you intend to build the string dynamically?

Well, this is possible, though I never tested it before. Let's try it:

   : (locale "DE" "de")

As an example, I take the string "Numeric input expected". It has a
standard translation:

   : (val ,"Numeric input expected")
   -> "Zahleneingabe erforderlich"

Now, to look up the string dynamically, we can do the following:

   : (val (car (idx '*Uni (pack "Numeric " "input" " expected"))))
   -> "Zahleneingabe erforderlich"

So, in summary, your function could look like this:

   (de foo ()
         (car (idx '*Uni (pack "My new" " string")))
         Z ) )

This should do it.

Thanks! This was what I needed:

(de translate (Txt)
        (val (car (idx '*Uni Txt))) )

I still have a lot to learn! ;-)


Reply via email to