Localization to German - if, when and how to get?

40 views
Skip to first unread message

Peter Noske

unread,
Sep 21, 2014, 3:04:19 PM9/21/14
to leo-e...@googlegroups.com

Hello to everybody.

Sorry for my limited English.


Today is my most important question:

Is there a way now to have / get a version of Leo in German language, a localization one's?

If yes, how is the way to get it?

Xoogle would not help in this.

If you can do,

that would be great and very helpful.


Anyway

have a excellent time

cordially

Peter

Edward K. Ream

unread,
Sep 22, 2014, 7:17:38 AM9/22/14
to leo-editor
On Sun, Sep 21, 2014 at 2:04 PM, Peter Noske <noske....@t-online.de> wrote:

> Is there a way now to have / get a version of Leo in German language, a
> localization one's?

For menus, see @@menu 文件 in leoSettings.leo

In other words, all you need to do is create your own @menu settings
(in myLeoSettings.leo)

For log message, note the docstring for g.es:

Put all non-keyword args to the log pane.
The first, third, fifth, etc. arg translated by g.translateString.

The g.translateString function essentially just returns gettext.gettext(s) See:

https://docs.python.org/2/library/gettext.html

I doubt that gettext is properly inited, but I could be wrong. In
other words, a bit more work will likely be needed to translate g.es
text to German.

HTH.

Edward

Terry Brown

unread,
Sep 22, 2014, 11:22:10 AM9/22/14
to leo-e...@googlegroups.com
On Mon, 22 Sep 2014 06:17:36 -0500
"Edward K. Ream" <edre...@gmail.com> wrote:

> On Sun, Sep 21, 2014 at 2:04 PM, Peter Noske
> <noske....@t-online.de> wrote:
>
> > Is there a way now to have / get a version of Leo in German
> > language, a localization one's?

Maybe not adding much here, but my just guessing haven't done
it myself impression of the most general approach to localization is
that all in code strings are wrapped in a function call, with the
function often being called `_` to minimize its intrusiveness. E.g

g.es("No @file nodes in tree")

becomes

g.es(_("No @file nodes in tree"))

I.e. english (typically) is chosen as the language to use throughout
the source, and then the localization machinery handles the
translation, using a lookup table for each supported language, going
from the english to the language in question.

Which is fine for simple text output from code.

Leo will be a bit more complicated because of the way it uses plain
text as a data type. How would we distinguish non-translatable text,
e.g.

@string body-font-family = @font-family

non-translatable in the sense that

@string körper-sind-familie = @sind-familie

won't work, vs. translatable text, e.g.

@string cleo_time_name = 'weeks'

could be

@string cleo_time_name = 'wochen'

I'm guessing the second case is extremely rare though.

But I don't see any reason the _("") part couldn't be worked on - apart
from adding the _("") I assume it's mostly automatic in terms of
extracting the list of strings to translate and generating the tables
for other languages - assuming you can find someone to fill them in.
Presumably the english is shown for untranslated strings.

Cheers -Terry

Edward K. Ream

unread,
Sep 22, 2014, 11:30:40 AM9/22/14
to leo-editor
On Mon, Sep 22, 2014 at 10:21 AM, 'Terry Brown' via leo-editor
<leo-e...@googlegroups.com> wrote:

> Maybe not adding much here, but my just guessing haven't done
> it myself impression of the most general approach to localization is
> that all in code strings are wrapped in a function call, with the
> function often being called `_` to minimize its intrusiveness. E.g
>
> g.es("No @file nodes in tree")
>
> becomes
>
> g.es(_("No @file nodes in tree"))

That should not be necessary. The convention that odd-numbered args
get translated is equivalent to wrapping odd-numbered args x in calls
to _(x). The convention allows you to mix translated and untranslated
arguments. For example:

g.es('can not open',fileName) # Translate 'can not open' but not fileName.

> Leo will be a bit more complicated because of the way it uses plain
> text as a data type. How would we distinguish non-translatable text,
> e.g.
>
> @string body-font-family = @font-family
>
> non-translatable in the sense that
>
> @string körper-sind-familie = @sind-familie

Correct. It would require significant work to translate settings.

> But I don't see any reason the _("") part couldn't be worked on - apart
> from adding the _("")

The only thing needed to translate log messages is to get the call to
gettext.gettext(s) inside g.translateString to work properly.

Edward

Terry Brown

unread,
Sep 22, 2014, 11:48:11 AM9/22/14
to leo-e...@googlegroups.com
On Mon, 22 Sep 2014 10:30:38 -0500
"Edward K. Ream" <edre...@gmail.com> wrote:

> The only thing needed to translate log messages is to get the call to
> gettext.gettext(s) inside g.translateString to work properly.

I was thinking of more general translation, e.g.

self.createIconButton(
text='script-button',
command = self.addScriptButtonCommand,
statusLine='Make script button from selected node',
kind="script-button-button")

becomes

self.createIconButton(
text=_('script-button'),
command = self.addScriptButtonCommand,
statusLine=_('Make script button from selected node'),
kind="script-button-button")

where _ points to whatever, but I think it should point to something off the shelf, given all the work that's already been done on managing translation tables.

Cheers -Terry

Edward K. Ream

unread,
Sep 22, 2014, 12:00:23 PM9/22/14
to leo-editor
On Mon, Sep 22, 2014 at 10:47 AM, 'Terry Brown' via leo-editor
<leo-e...@googlegroups.com> wrote:

>> The only thing needed to translate log messages is to get the call to
>> gettext.gettext(s) inside g.translateString to work properly.
>
> I was thinking of more general translation, e.g.

_ = g.translateString

Edward

Terry Brown

unread,
Sep 22, 2014, 12:19:06 PM9/22/14
to leo-e...@googlegroups.com
On Mon, 22 Sep 2014 11:00:21 -0500
"Edward K. Ream" <edre...@gmail.com> wrote:

Ooops, sorry, didn't realize that g.translateString was just a thin
wrapper around https://docs.python.org/3/library/gettext.html

Sorry for the noise ;-)

Cheers -Terry

Edward K. Ream

unread,
Sep 22, 2014, 12:24:59 PM9/22/14
to leo-editor
On Mon, Sep 22, 2014 at 11:18 AM, 'Terry Brown' via leo-editor
<leo-e...@googlegroups.com> wrote:

>> _ = g.translateString
>
> Ooops, sorry, didn't realize that g.translateString was just a thin
> wrapper around https://docs.python.org/3/library/gettext.html

No problem. It will be interesting to see what it takes to do German.
And as you point out, a lot of underscores may have to be added...

Edward

Peter Noske

unread,
Sep 22, 2014, 5:35:41 PM9/22/14
to leo-e...@googlegroups.com

> Is there a way now to have / get a version of Leo in German language, a
> localization one's?
 
Great.
 
- thanks for answering.
 
For menus, see @@menu 文件 in leoSettings.leo 
I have found this and have a look at it, with notepad++ (NP) .
What a big ship.

In other words, all you need to do is create your own @menu settings
(in myLeoSettings.leo)
 
What i understood:
 I can make and use a new individual German file (myLeoSettings.leo) .
But in my thinking I have to have a list  of menu_words_English to start with and then I can have a second list the same terms in German menu_words_German.  Then 'Leo' can overlay  it's basics menu in my language.
It´s out of my range to extract this list of menu_words_English from Leo, then do a translation by machine or by hand and then put it  in the right place.

-----
I start to like literate programming. This explicit descriptions , i do like to read.  But, but, but, fare out of my range to do this job.
So i will study customizing.txt  and then see what i would like to do or not.
Or  is here someone from Berlin Germany to help me by this eye of a needle.

Again thanks for the hints.
Have a nice excellent time
peter


Reply all
Reply to author
Forward
0 new messages