Lua in other spoken languages?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua in other spoken languages?

Bertrand Mansion
For me, Lua is the ideal programming language to teach to children because it is easy to understand, has only a few keywords and data types, and more complex features like metatables and coroutines can be completely ignored. It also offers more freedom in syntax than Python.

I was trying to do some Lua programming with my son (in Love2D, a space invader game, he is 7) but I soon realized that the English keywords can make things more complex than necessary for a young French boy (same with other spoken languages).

Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?

Thanks,

Bertrand


Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Luiz Henrique de Figueiredo
> Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?

Translating keywords is quite simple: Just change luaX_tokens in llex.c
<http://www.lua.org/source/5.3/llex.c.html#luaX_tokens>, taking care to
preserve the order.

Translating functions names can be done directly in Lua.

Nevertheless, translating is a bad idea because you'll lose all the wisdom
and examples available in the web.

Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Luiz Henrique de Figueiredo
> Translating keywords is quite simple

On the other hand, translating error messages is not so simple. because
they're scattered in the code. Not impossible but will require some work.

Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Javier Guerra Giraldez
In reply to this post by Luiz Henrique de Figueiredo
On Fri, Sep 18, 2015 at 7:30 AM, Luiz Henrique de Figueiredo
<[hidden email]> wrote:
> Nevertheless, translating is a bad idea because you'll lose all the wisdom
> and examples available in the web.


it _is_ a bad, bad, bad, ugly, bad idea.   I once saw a microsoft
application basic script that no matter in which language it was
written, when opened on a different machine it was "translated" to the
"user language"... nobody could read the spanish translation, not even
those that really didn't knew any real english.

--
Javier

Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Pierre-Yves Gérardy
In reply to this post by Bertrand Mansion
On Fri, Sep 18, 2015 at 2:20 PM, Bertrand Mansion <[hidden email]> wrote:
> I was trying to do some Lua programming with my son (in Love2D, a space invader game, he is 7) but I soon realized that the English keywords can make things more complex than necessary for a young French boy (same with other spoken languages).
>
> Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?

Hello Bertrand,

I had programming courses at school when I was ten using both Logo
(translated in French) and Basica (the language in English, the error
messages may have been translated), and I don't think that having the
keywords and library functions (print, input, chr$, list, run, ...) in
English was problematic.

The programming languages are so constrained and arbitrary compared to
natural languages that it doesn't matter much wether you're useing
'for' and 'if' or 'repète' and 'si'... It may even make it easier to
have custom words for the well defined meaning of the terms rather
than using words that also make sense in other contexts.

We used letters for variable names so there wasn't any mismatch...

For Löve, you may want to translate the love.x.y names though, and
have him use French for naming his own fariables and functions. The
same goes for the Lua standard library ('require' -> 'demande',
'print' -> 'imprime', try to use verbs of the first group (in 'er') it
makes spelling simpler).

—Pierre-Yves

Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Dirk Laurie-2
In reply to this post by Bertrand Mansion
2015-09-18 14:20 GMT+02:00 Bertrand Mansion <[hidden email]>:
>
> I was trying to do some Lua programming with my son (in Love2D, a space invader game, he is 7) but I soon realized that the English keywords can make things more complex than necessary for a young French boy (same with other spoken languages).
>
> Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?

I would leave the keywords unchanged, but assign the library functions
to local variables with easy=to-remember names. Many  programmers
cache them even in English. E.g. I find it useful to say

    local append=table.insert

Also 'require' is not the most natural word for what the function
does, and I have not even started on polysyllabic behemoths
'semetatable'. Nice, short French words (no accent, please)
can only be a bonus.

But for keywords you can argue that they are just meaningless
tokens. (In Algol 60 they were officially just that.) 'for' reminds
me a bit of Basic's 'let': chosen because it is short and the syntax
demands a keyword. In Fortran the same job is done by 'do',
even shorter.

Your son does not need to know what 'for' means in English.
He only needs to know that for ... do ... end are the brackets
for the initialization and body of an iteration. The French
translations of the English words will still be just such brackets.
Apart from `fin` for `end`, they will probably have more letters.

Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Sean Conner
In reply to this post by Bertrand Mansion
It was thus said that the Great Bertrand Mansion once stated:
> For me, Lua is the ideal programming language to teach to children because
> it is easy to understand, has only a few keywords and data types, and more
> complex features like metatables and coroutines can be completely ignored.
> It also offers more freedom in syntax than Python.
>
> I was trying to do some Lua programming with my son (in Love2D, a space
> invader game, he is 7) but I soon realized that the English keywords can
> make things more complex than necessary for a young French boy (same with
> other spoken languages).

  I covered this a bit on my blog (http://boston.conman.org/2008/01/04.1)
where I created the Swedish programming language Håstad that looks like:

        medan not_done
        börja
          för x:= 1 till 5 gör
          börja
            om person^.age = 120 så
              too_old(person);
            om person^.age > 130 så
              gåtill person_should_be_dead;
          slut;
        slut;

  I thought I might try at least converting 'if' and 'then' into Swedish
(since I had the words [1]) in Lua 5.3.  I had mixed results.

  I changed luaX_tokens[] so that 'if' became 'om' and 'then' became 'så'.
I then tried [2]:

        Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio
        > x = 3
        > om x == 3 så print("hello") end
        stdin:1: 'så' expected near 's'

  When I changed 'så' to 'sa' and ran the same fragment:

        Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio
        > x = 3
        > om x == 3 sa print("hello") end
        hello

  I did try changing my locale and try using 'så' again but:

        [spc]lucy:/tmp/lua-5.3>echo $LANG
        se_NO.UTF-8
        [spc]lucy:/tmp/lua-5.3>date
        bearjadat, čakčamánu 18. b. 2015 17:17:20 EDT
        [spc]lucy:/tmp/lua-5.3>./src/lua
        Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio
        > x = 3
        > om x == 3 så print("hello") end
        stdin:1: 'så' expected near 's'

  For accented characters you may have some more work to get this working.

  -spc (bjork bjork bjork)

[1] I have this friend from Sweden see ...

[2] My language setting is en_US.UTF-8.

Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

zejian ju
In reply to this post by Bertrand Mansion
Hello Bertrand,

Virtual Programming Environment (such as those based on Blockly) may be better for a 7-years-old boy.

Regards,
Zenk

2015-09-18 20:20 GMT+08:00 Bertrand Mansion <[hidden email]>:
For me, Lua is the ideal programming language to teach to children because it is easy to understand, has only a few keywords and data types, and more complex features like metatables and coroutines can be completely ignored. It also offers more freedom in syntax than Python.

I was trying to do some Lua programming with my son (in Love2D, a space invader game, he is 7) but I soon realized that the English keywords can make things more complex than necessary for a young French boy (same with other spoken languages).

Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?

Thanks,

Bertrand



Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

stepa alimov
Hello Bertrand,

I think the simplest way is to write some kind of preprocesor, for example:

local utf8 = require 'utf8'

local dict = {
  if = "если",
  then = "тогда",
  else = "иначе",
  elseif = "иначе_если",
  end = "закончить",
  function = "функция",
}

local to_russian = table.deepcopy(dict)
local from_russian = table.foreach(table.deepcopy(dict), function(t, k, v) t[v], t[k] = k, nil end)

local s = "%s"

for line in io.lines(arg[1]) do
  for keyword, repl in pairs(from_russian) do
    utf8.gsub( line, s .. '(' .. keyword .. ')' .. s, repl )
  end
end

I hope idea is clear. Good luck!

btw, some time ago I've made pure-lua implementation of string library for utf8 charsequences https://gist.github.com/Stepets/3b4dbaf5e6e6a60f3862

--
Best Regards, Alimov S.G.
Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Bertrand Mansion
In reply to this post by Dirk Laurie-2

> Le 18 sept. 2015 à 23:19, Dirk Laurie <[hidden email]> a écrit :
>
> 2015-09-18 14:20 GMT+02:00 Bertrand Mansion <[hidden email]>:
>>
>> I was trying to do some Lua programming with my son (in Love2D, a space invader game, he is 7) but I soon realized that the English keywords can make things more complex than necessary for a young French boy (same with other spoken languages).
>>
>> Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?
>
> I would leave the keywords unchanged, but assign the library functions
> to local variables with easy=to-remember names. Many  programmers
> cache them even in English. E.g. I find it useful to say
>
>    local append=table.insert
>
> Your son does not need to know what 'for' means in English.
> He only needs to know that for ... do ... end are the brackets
> for the initialization and body of an iteration. The French
> translations of the English words will still be just such brackets.
> Apart from `fin` for `end`, they will probably have more letters.

> Le 18 sept. 2015 à 21:01, Pierre-Yves Gérardy <[hidden email]> a écrit :
>
> For Löve, you may want to translate the love.x.y names though, and
> have him use French for naming his own fariables and functions. The
> same goes for the Lua standard library ('require' -> 'demande',
> 'print' -> 'imprime', try to use verbs of the first group (in 'er') it
> makes spelling simpler).

Thank you all for your suggestions, I will go this way, just translating the names of function and variables and keeping the keywords as they are.

> Le 19 sept. 2015 à 03:08, zejian ju <[hidden email]> a écrit :
>
> Virtual Programming Environment (such as those based on Blockly) may be better for a 7-years-old boy.


I already tried Scratch (https://scratch.mit.edu/) with him, which is also visual. But at some point, when you start using variables, I found that things became more complex to explain than just "a = 1". As long as all you do is animation and sprites movements, it's fine though and it's fun.

Thanks,

Bertrand


Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Philippe Lhoste
In reply to this post by Luiz Henrique de Figueiredo
On 18/09/2015 14:30, Luiz Henrique de Figueiredo wrote:

>> Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?
>
> Translating keywords is quite simple: Just change luaX_tokens in llex.c
> <http://www.lua.org/source/5.3/llex.c.html#luaX_tokens>, taking care to
> preserve the order.
>
> Translating functions names can be done directly in Lua.
>
> Nevertheless, translating is a bad idea because you'll lose all the wisdom
> and examples available in the web.

I fully agree. Visual Basic for Applications translations were a bad idea, as they
fragmented the help available, and made seeking for help on the Net quite hard outside of
the community of same language.

Beside, as you said, the number of words used by Lua is relatively small, so it shouldn't
be too hard to memorize with their meaning. Beside, I guess your son will soon be exposed
(if not already) to English, so it can be a good head start... :-)

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --


Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Rena
On Mon, Sep 28, 2015 at 7:59 AM, Philippe Lhoste <[hidden email]> wrote:

> On 18/09/2015 14:30, Luiz Henrique de Figueiredo wrote:
>>>
>>> Do you know if attempts to translate Lua keywords/functions in other
>>> languages has been done already ? Or do you think this can be done and how
>>> could it be done then ?
>>
>>
>> Translating keywords is quite simple: Just change luaX_tokens in llex.c
>> <http://www.lua.org/source/5.3/llex.c.html#luaX_tokens>, taking care to
>> preserve the order.
>>
>> Translating functions names can be done directly in Lua.
>>
>> Nevertheless, translating is a bad idea because you'll lose all the wisdom
>> and examples available in the web.
>
>
> I fully agree. Visual Basic for Applications translations were a bad idea,
> as they fragmented the help available, and made seeking for help on the Net
> quite hard outside of the community of same language.
>
> Beside, as you said, the number of words used by Lua is relatively small, so
> it shouldn't be too hard to memorize with their meaning. Beside, I guess
> your son will soon be exposed (if not already) to English, so it can be a
> good head start... :-)
>
> --
> Philippe Lhoste
> --  (near) Paris -- France
> --  http://Phi.Lho.free.fr
> --  --  --  --  --  --  --  --  --  --  --  --  --  --
>
>

On a bit of a tangent, I recall one copy protection scheme back in the
day failed on non-English systems, because the game would ask the OS
what type of CD was inserted, and abort if the response wasn't "data".
Some genius decided to translate these identifiers, so on French
systems, the game would refuse to run from a "données" CD.

--
Sent from my Game Boy.

Reply | Threaded
Open this post in threaded view
|

Re: Lua in other spoken languages?

Diogo Mildenberger
In reply to this post by Philippe Lhoste
It is my intention, as a pet project, to do so.

On another note, I am new to the list, and relatively new to the language, but I am having a good time while practicing with it. Hello!

Diogo

2015-09-28 8:59 GMT-03:00 Philippe Lhoste <[hidden email]>:
On 18/09/2015 14:30, Luiz Henrique de Figueiredo wrote:
Do you know if attempts to translate Lua keywords/functions in other languages has been done already ? Or do you think this can be done and how could it be done then ?

Translating keywords is quite simple: Just change luaX_tokens in llex.c
<http://www.lua.org/source/5.3/llex.c.html#luaX_tokens>, taking care to
preserve the order.

Translating functions names can be done directly in Lua.

Nevertheless, translating is a bad idea because you'll lose all the wisdom
and examples available in the web.

I fully agree. Visual Basic for Applications translations were a bad idea, as they fragmented the help available, and made seeking for help on the Net quite hard outside of the community of same language.

Beside, as you said, the number of words used by Lua is relatively small, so it shouldn't be too hard to memorize with their meaning. Beside, I guess your son will soon be exposed (if not already) to English, so it can be a good head start... :-)

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --