Full Sage Notebook Internationalization (i18n)

86 views
Skip to first unread message

Luiz Aquino

unread,
Jul 3, 2010, 11:27:50 AM7/3/10
to sage-notebook
Hi,

Me and Dan Drake are working on a Full Sage Notebook
Internationalization (i18n).

I'm glad to say that I just finish the first version. Please, if you
want to try the Sage Notebook in your own language, follow the steps:

1. Download this file:
http://sites.google.com/site/lcmaquino/sage/sagenb.tar.gz?attredirects=0&d=1

2. Extract the file above in:
$SAGE_ROOT/local/lib/python/site-packages/sagenb-0.8-py2.6.egg

3. In the directory above, rename the file "sagenb/sagenb.pot" to
"sagenb/sagenb.po"

4. Edit sagenb.po to translate the strings. You can use the POEdit [1]
or a plain text editor.

5. Compile sagenb.po to create sagenb.mo. The POEdit does it for you.
Or, you can use on terminal:
msgfmt sagenb.po -o sagenb.mo

6. Copy sagenb.mo to:
$SAGE_ROOT/local/lib/python/site-packages/sagenb-0.8-py2.6.egg/sagenb/
locale/xx_YY/LC_MESSAGES

Where xx_YY is something like en_US, en_UK, pt_BR, etc.

7. Change the file sagenb/notebook/i18n.py (line 23) to
CURRENT_LANGUAGE = 'xx_YY'

8. Now, run the Sage Notebook. It's in your language!

Now, we need some help! Please, translate it to your own language and
give us a feedback! I translated it to pt_BR (Brazilian Portuguese),
so you can use it.

By the way, we want to change the language using "Settings > Notebook
Settings > Default Language", so we don't need to change the i18n.py
manually. I know that the settings are saved in the file conf.pickle,
at sage notebook directory ($HOME/.sage/sage_notebook.sagenb, by
default), but I don't know how to access this from i18n.py. Could
someone help me with this?

ps.: Before follow step 2., it's a good idea to make a backup of
sagenb directory.

Reference
[1] http://www.poedit.net/

Harald Schilly

unread,
Jul 3, 2010, 6:26:51 PM7/3/10
to sage-n...@googlegroups.com
Very good, great work!

On Sat, Jul 3, 2010 at 17:27, Luiz Aquino <aquino.lu...@gmail.com> wrote:
> Now, we need some help!

Is there some coordination to avoid duplicate work? I'll look into
de_DE/AT and although I will not promise anything, all others might
check with me. (... and if somebody else wants to lead german
translation effords just tell me and I'm happy to pass this on.)
Maybe there should be a central i18n wiki page where we collect the
.po files, too?

H

Luiz Aquino

unread,
Jul 3, 2010, 6:43:46 PM7/3/10
to sage-notebook
Hi Harald,

> Is there some coordination to avoid duplicate work?
Well, by now just me and Dan Drake are working on the i18n. If someone
wants to help, just tell us!

> Maybe there should be a central i18n wiki page where we collect the
> .po files, too?
It's a great idea! Maybe we can create it at http://wiki.sagemath.org/.

Cheers.

Harald Schilly

unread,
Jul 3, 2010, 6:49:59 PM7/3/10
to sage-n...@googlegroups.com
On Sun, Jul 4, 2010 at 00:43, Luiz Aquino <aquino.lu...@gmail.com> wrote:
> It's a great idea! Maybe we can create it at http://wiki.sagemath.org/

http://wiki.sagemath.org/i18n has a new paragraph for that now.

H

Tim Joseph Dumol

unread,
Jul 3, 2010, 10:06:04 PM7/3/10
to sage-n...@googlegroups.com
Awesome work!

If you want it to be a server-wide setting, you can just add an item
to the ``defaults`` and ``descriptions`` dictionaries in
server_conf.py. Accessing the variable is done by importing the global
notebook (twist.notebook) and calling notebook.conf().

If you want it to be a user-specific setting, you'll have to do a bit
more work. Edit user_conf.py and add a descriptions dictionary and
defauls_descriptions method similar to server_conf.py (the
descriptions dictionary should only contain your new setting, as the
settings in user_conf.py are either unused or hidden (as with next
worksheet id)). Then you'll have to change
sagenb/data/sage/html/settings/account_settings.html and add a {%if
auto_table %}{{ auto_table }}{% endif %} line, similar to that in
notebook_settings.html, and then finally, change twist.py to send
``auto_table`` to the templating engine in SettingsPage.render(),
similar to that in NotebookSettings.render().

I can do the work on the second myself, if needed, given a patch I can
apply to my repository.

> ps.: Before follow step 2., it's a good idea to make a backup of
> sagenb directory.
>
> Reference
> [1] http://www.poedit.net/
>

--
Tim Joseph Dumol

Dan Drake

unread,
Jul 4, 2010, 5:54:51 AM7/4/10
to sage-n...@googlegroups.com
On Sun, Jul 4, 2010 at 12:26 AM, Harald Schilly
<harald....@gmail.com> wrote:
> Is there some coordination to avoid duplicate work? I'll look into
> de_DE/AT and although I will not promise anything, all others might
> check with me. (... and if somebody else wants to lead german
> translation effords just tell me and I'm happy to pass this on.)
> Maybe there should be a central i18n wiki page where we collect the
> .po files, too?

First, great work Luiz!

Second, my thoughts for translation are that we will first get the
i18n working -- just work with one language and make sure we have
everything working. Then we can get an idea of how to merge new
translations and how we will distribute the translations (i.e., will
we distribute .mo files, or have something in the build script compile
them from .po files). After we have that working, then we can ask for
actual translations. Getting everything prepared first before asking
for translations seems like a good idea, since I anticipate we will
get a bunch of translations all at once, since there is a pretty big
global community of Sage users out there, and several people have
already expressed interest in translating.

With some more work, I think we can have the i18n working and several
translations working by the end of summer. Hopefully some students who
are not native English speakers can return to school this autumn and
use Sage in their own language!


(It is interesting that we are doing this now, during the World
Cup...with recent travel, I have watched matches in three
countries...)

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

Harald Schilly

unread,
Jul 4, 2010, 6:00:23 AM7/4/10
to sage-notebook
On Jul 3, 5:27 pm, Luiz Aquino <aquino.luizclau...@gmail.com> wrote:
> [1]http://www.poedit.net/

Just a quick note for all you, poedit looks terrible but works quite
well. The most important keyboard shortcut is Ctrl-Up/-Down. It
switches to the next or previous translation item when you are focused
in the target translation box.

H

ma...@mendelu.cz

unread,
Jul 4, 2010, 7:00:25 AM7/4/10
to sage-notebook
kbabel (linux only) looks much better than poedit

Also emacs has a mode for editing po files

Robert

ma...@mendelu.cz

unread,
Jul 4, 2010, 7:25:35 AM7/4/10
to sage-notebook

On 3 čnc, 17:27, Luiz Aquino <aquino.luizclau...@gmail.com> wrote:
> Hi,
>
> Me and Dan Drake are working on a Full Sage Notebook
> Internationalization (i18n).
>
> I'm glad to say that I just finish the first version. Please, if you
> want to try the Sage Notebook in your own language, follow the steps:
>
> 1. Download this file:http://sites.google.com/site/lcmaquino/sage/sagenb.tar.gz?attredirect...
>

Hi, big thank for worling on this.

I have problems when running Sage with the sagenb package above. I did
all the 8 steps to get Sage running czech translation (http://
user.mendelu.cz/marik/sage/sagenb.po) and got the following error.

Everything is O.K. if I switch the sagenb directory to the original
version.

Robert

marik@um-bc107:/opt/sage-4.4.4$ ./sage
----------------------------------------------------------------------
| Sage Version 4.4.4, Release Date: 2010-06-23 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
---------------------------------------------------------------------------
ImportError Traceback (most recent call
last)

/opt/sage-4.4.4/local/bin/<string> in <module>()

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/
preparser_ipython.py in <module>()
6
###########################################################################

7
----> 8 import sage.misc.interpreter
9
10 import preparser

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/
interpreter.py in <module>()
100
101 import os
--> 102 import log
103
104 import remote_file

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/log.py in
<module>()
63
64 import interpreter
---> 65 import latex
66 import misc
67

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/latex.py
in <module>()
38 import random
39
---> 40 from misc import tmp_dir, graphics_filename
41 import sage_eval
42 from sage.misc.misc import SAGE_DOC

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/misc.py in
<module>()
1925 return "0"*(size-len(str(s))) + str(s)
1926
-> 1927 import sage.server.support
1928
1929 def embedded():

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/server/
support.py in <module>()
17 import sage.misc.pager
18
---> 19 import sage.misc.sagedoc as sagedoc
20 import sage.misc.sageinspect as sageinspect
21

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/sagedoc.py
in <module>()
33 from sage.misc.viewer import browser
34 from sage.misc.misc import SAGE_DOC, tmp_dir
---> 35 from sagenb.misc.sphinxify import sphinxify
36 import sage.version
37

ImportError: No module named misc.sphinxify
WARNING: Failure executing code: 'import sage.misc.preparser_ipython;
sage.misc.preparser_ipython.magma_colon_equals=True'
---------------------------------------------------------------------------
ImportError Traceback (most recent call
last)

/opt/sage-4.4.4/local/lib/python2.6/site-packages/IPython/ipmaker.pyc
in force_import(modname)
64 reload(sys.modules[modname])
65 else:
---> 66 __import__(modname)
67
68

/opt/sage-4.4.4/local/bin/ipy_profile_sage.py in <module>()
1 import os
2 if 'SAGE_CLEAN' not in os.environ:
----> 3 import sage.misc.misc
4 from sage.misc.interpreter import preparser, _ip
5 preparser(True)

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/misc.py in
<module>()
1925 return "0"*(size-len(str(s))) + str(s)
1926
-> 1927 import sage.server.support
1928
1929 def embedded():

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/server/
support.py in <module>()
17 import sage.misc.pager
18
---> 19 import sage.misc.sagedoc as sagedoc
20 import sage.misc.sageinspect as sageinspect
21

/opt/sage-4.4.4/local/lib/python2.6/site-packages/sage/misc/sagedoc.py
in <module>()
33 from sage.misc.viewer import browser
34 from sage.misc.misc import SAGE_DOC, tmp_dir
---> 35 from sagenb.misc.sphinxify import sphinxify
36 import sage.version
37

ImportError: No module named misc.sphinxify
Error importing ipy_profile_sage - perhaps you should run %upgrade?
WARNING: Loading of ipy_profile_sage failed.

<ERROR: name 'sage_prompt' is not defined>


Luiz Aquino

unread,
Jul 4, 2010, 5:02:57 PM7/4/10
to sage-notebook
I agree with Dan Drake, we need to get i18n working well before making
the translations. But, I think that most of the job is done.

> I can do the work on the second myself, if needed, given a patch I can apply to my repository.

Please Tim Dumol, could you make this and send to me?

> If you want it to be a server-wide setting, you can just add an item to the ``defaults`` and ``descriptions`` dictionaries in
> server_conf.py. Accessing the variable is done by importing the global
> notebook (twist.notebook) and calling notebook.conf().

If you get the file that I send before, you'll see that I already
change the "defaults_descriptions" and "defaults" dictionaries in
server_conf.py, but I didn't know how to access this.

>Hi, big thank for worling on this.
>
>I have problems when running Sage with the sagenb package above. I did
>all the 8 steps to get Sage running czech translation (http://
>user.mendelu.cz/marik/sage/sagenb.po) and got the following error.\
>
>Everything is O.K. if I switch the sagenb directory to the original
>version.

About the error that you get, Robert, if I get this right, you just
replace the old sagenb directory with the file that I sent. But, what
you need to do is merge the old one with this new one. At the end of
the error message that you get, we can see "ImportError: No module
named misc.sphinxify". Now, if you look inside the old sagenb
directory, you'll see the file "misc/sphinxify.py", but there isn't a
'misc' directory in the file that I sent. So, please, merge the two
directories and send to me a feedback. I hope you solve your problem!

Cheers.

Luiz Aquino

unread,
Jul 4, 2010, 5:27:16 PM7/4/10
to sage-notebook
Hi Tim Dumol,

I don't know what is the best choice: server vs user settings.

If we want to set an international sage-notebook server, so our users
can speak a lot of languages and then a user settings is better.

But, If we want to set a local sage-notebook server, so all users
speak the same language and then a server settings is better.

Maybe, we can let the "admin" choose between this options. I mean, he/
she can set a default language and mark a check box to allow "user
language configuration", or something like that.

Any way, I'm sure about one thing: it's better (and comfortable) to
set the language by the "Settings" menu at sage notebook.

Cheers.

ma...@mendelu.cz

unread,
Jul 4, 2010, 6:39:55 PM7/4/10
to sage-notebook


On 4 čnc, 23:02, Luiz Aquino <aquino.luizclau...@gmail.com> wrote:
> 'misc' directory in the file that I sent. So, please, merge the two
> directories and send to me a feedback. I hope you solve your problem!

Many thanks, works for me now.

On our minor university I have Czech speaking students with no or pure
knowledge of English as well as Erasmus students from abroad (English,
Spain). I think that this is common on many other universities and it
would nice to allow the users to switch language of the notebook.

I think that translators can work on their translations despite that
fact the the work on i18n is not finished, since the translated po
files can be easily merged with updated pot file later. Right?

Many thanks again. Robert

ma...@mendelu.cz

unread,
Jul 4, 2010, 6:41:17 PM7/4/10
to sage-notebook


On 5 čnc, 00:39, "ma...@mendelu.cz" <ma...@mendelu.cz> wrote:
> On our minor university I have Czech speaking students with no or pure

Should be poor English, not pure English :)

Sorry for my poor English :)

Robert

Luiz Aquino

unread,
Jul 5, 2010, 8:33:58 AM7/5/10
to sage-notebook
It's true: "The translated po files can be easily merged with updated
pot file."

But, I think that the point is: we need to make i18n.py stable before
working on translations.

Maybe I'm wrong, but I think that i18n.py is stable enough to be
testing with another translations.

About the pt_BR translation I can say that it's working fine.

I tested everything, including account recovery and registration.

By the way, we need to make the i18n of challenge.py. About the
QUESTIONS dictionary (line 215), when I used _('What is 3 times 8?'),
with the translation (pt_BR) "Quanto é 3 vezes 8?" I got an error
because of "é". I think that unicode(_('What is 3 times 8?'), 'utf-8',
'replace') can solve the problem, but it's not so good. Any idea?

Cheers.

Tim Joseph Dumol

unread,
Jul 5, 2010, 8:42:20 AM7/5/10
to sage-n...@googlegroups.com
Hi,

The problem is that SIMPLE_TEMPLATE is a non-unicode string. Repalce

SIMPLE_TEMPLATE = """<p>..."""
with
SIMPLE_TEMPLATE = u"""<p>..."""

I've done the changes required to make the language settable in the
Account and Notebook Settings pages, with the former overriding the
latter. I'm ready to release a new package with the patch if you could
upload the latest translations with the QUESTIONS dictionary.
--
Tim Joseph Dumol <tim (at) timdumol (dot) com>
http://timdumol.com

Luiz Aquino

unread,
Jul 5, 2010, 9:49:11 AM7/5/10
to sage-notebook
> The problem is that SIMPLE_TEMPLATE is a non-unicode string. Repalce
>
> SIMPLE_TEMPLATE = """<p>..."""
> with
> SIMPLE_TEMPLATE = u"""<p>..."""

I made this change, but I got an error when I tried to answer the
simple challenge:
2010-07-05 10:35:31-0300 [HTTPChannel,2,127.0.0.1] Exception
rendering:
2010-07-05 10:35:31-0300 [HTTPChannel,2,127.0.0.1] Unhandled Error
Traceback (most recent call last):
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
twisted/internet/defer.py", line 625, in gotResult
_deferGenerator(g, deferred)
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
twisted/internet/defer.py", line 602, in _deferGenerator
deferred.callback(result)
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
twisted/internet/defer.py", line 238, in callback
self._startRunCallbacks(result)
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
twisted/internet/defer.py", line 307, in _startRunCallbacks
self._runCallbacks()
--- <exception caught here> ---
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
twisted/internet/defer.py", line 323, in _runCallbacks
self.result = callback(self.result, *args, **kw)
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
twisted/web2/resource.py", line 230, in <lambda>
).addCallback(lambda res: self.render(request))
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
sagenb-0.8-py2.6.egg/sagenb/notebook/twist.py", line 2256, in render
status = chal.is_valid_response(req_args = request.args)
File "/opt/sage-4.4.3-64bit/local/lib/python2.6/site-packages/
sagenb-0.8-py2.6.egg/sagenb/notebook/challenge.py", line 345, in
is_valid_response
if agree(response_field, QUESTIONS[challenge_field]):
exceptions.KeyError: 'Qual \xc3\xa9 o maior fator primo de 15?'

See that "é" in "Qual é o maior fator primo de 15?" ("What is the
largest prime factor of 15?") was replaced by "\xc3\xa9".

> I've done the changes required to make the language settable in the
> Account and Notebook Settings pages, with the former overriding the
> latter. I'm ready to release a new package with the patch if you could
> upload the latest translations with the QUESTIONS dictionary.
> --
> Tim Joseph Dumol <tim (at) timdumol (dot) com>http://timdumol.com

Please, get this file:
http://sites.google.com/site/lcmaquino/sage/sagenb_pt_BR.tar.gz?attredirects=0&d=1

By the way, maybe it sounds like a fool question, but how can I apply
your .patch? I never made this before! ;/

Cheers.

Luiz Aquino

unread,
Jul 5, 2010, 10:22:42 AM7/5/10
to sage-notebook
> I've done the changes required to make the language settable in the
> Account and Notebook Settings pages, with the former overriding the
> latter.

I saw what you did in i18n.py, but I'm not sure if it's a good idea to
load every language to the dictionary "languages". I mean, imagine
that we have to load 100 languages, but we'll need just one! I think
that we need to load just the language set by the user. What do you
think?

Cheers.

Tim Joseph Dumol

unread,
Jul 5, 2010, 10:30:17 AM7/5/10
to sage-n...@googlegroups.com

This probably is better discussed in the trac ticket. My reply will be there.

Tim Joseph Dumol

unread,
Jul 5, 2010, 11:25:21 AM7/5/10
to sage-n...@googlegroups.com
A package with this patch is now available for testing as
http://sage.math.washington.edu/home/timdumol/sagenb-0.9.spkg

Luiz Aquino

unread,
Jul 5, 2010, 12:16:10 PM7/5/10
to sage-notebook
Hi Tim Dumol,

On 5 jul, 12:25, Tim Joseph Dumol <t...@timdumol.com> wrote:
> A package with this patch is now available for testing as http://sage.math.washington.edu/home/timdumol/sagenb-0.9.spkg

I installed this package by: "sage -f /home/lcaquino/Desktop/
sagenb-0.9.spkg"

I got this error when I tried to run sage:

----------------------------------------------------------------------
| Sage Version 4.4.4, Release Date: 2010-06-23 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
---------------------------------------------------------------------------

ImportError Traceback (most recent call
last)

/opt/sage-4.4.4-64bit/local/lib/python2.6/site-packages/IPython/
ipmaker.pyc in force_import(modname)
64 reload(sys.modules[modname])
65 else:
---> 66 __import__(modname)
67
68

/opt/sage-4.4.4-64bit/local/bin/ipy_profile_sage.py in <module>()
5 preparser(True)
6
----> 7 import sage.all_cmdline
8 sage.all_cmdline._init_cmdline(globals())
9

/opt/sage-4.4.4-64bit/local/lib/python2.6/site-packages/sage/
all_cmdline.py in <module>()
12 try:
13
---> 14 from sage.all import *
15 from sage.calculus.predefined import x
16 preparser(on=True)

/opt/sage-4.4.4-64bit/local/lib/python2.6/site-packages/sage/all.py in
<module>()
83 from sage.modular.all import *
84 from sage.schemes.all import *
---> 85 from sage.graphs.all import *
86 from sage.groups.all import *
87 from sage.databases.all import *

/opt/sage-4.4.4-64bit/local/lib/python2.6/site-packages/sage/graphs/
all.py in <module>()
14 from sage.graphs.cliquer import *
15 from graph_database import graph_db_info
---> 16 from graph_editor import graph_editor
17
18

/opt/sage-4.4.4-64bit/local/lib/python2.6/site-packages/sage/graphs/
graph_editor.py in <module>()
19 from sage.misc.html import html
20
---> 21 import sagenb.notebook.interact
22 from sagenb.misc.support import EMBEDDED_MODE
23

/opt/sage-4.4.4-64bit/local/lib/python2.6/site-packages/sagenb-0.9-
py2.6.egg/sagenb/notebook/interact.py in <module>()
2110 JavascriptCodeButton.__init__(self, "Update", s)
2111
-> 2112 from sage.misc.misc import decorator_defaults
2113
2114 @decorator_defaults

ImportError: cannot import name decorator_defaults
Error importing ipy_profile_sage - perhaps you should run %upgrade?
WARNING: Loading of ipy_profile_sage failed.

How to solve this?

Cheers.

Luiz Aquino

unread,
Jul 5, 2010, 12:28:07 PM7/5/10
to sage-notebook
> A package with this patch is now available for testing ashttp://sage.math.washington.edu/home/timdumol/sagenb-0.9.spkg

By the way, in this package, in the file "src/sagenb/notebook/
server_conf.py", the variables G_APPEARANCE, G_AUTH, G_SERVER and
defaults_descriptions are not using the _ function to translate the
strings. Please, take a look on this.

Cheers.

Luiz Aquino

unread,
Jul 5, 2010, 12:33:50 PM7/5/10
to sage-notebook
On 5 jul, 13:28, Luiz Aquino <aquino.luizclau...@gmail.com> wrote:
> A package with this patch is now available for testing as http://sage.math.washington.edu/home/timdumol/sagenb-0.9.spkg

I'm sorry, but there is another problem: please, remove the file "src/
sagenb/sagenb/notebook/conf_lcma.py". It's just a backup. :s

Cheers.

Luiz Aquino

unread,
Jul 9, 2010, 8:39:57 AM7/9/10
to sage-notebook
Hi,

> A package with this patch is now available for testing as http://sage.math.washington.edu/home/timdumol/sagenb-0.9.spkg

I read the codes in this package and I think that there is a problem.

We need to use the _() function with an explicit string as argument to
be able to (automatically) extract the translatable strings and
generate a .pot file.

For example, in this package we have the file "src/sagenb/sagenb/
notebook/server_conf.py" with strings to be translated. But, we aren't
use _() function in this file to translate it. We are translating
those strings in the file "src/sagenb/sagenb/notebook/conf.py" (lines
147 and 152) in an implicit way. So, we can't (automatically) extract
those strings to the .pot file.

Let me show an example. Imagine that we have two files:
- In the first one we have a variable:
msg="The Sage Notebook"

- In the second one we import this variable and we translate (and
print) it:
print _(msg)

Doing this way (implicit), the automatic tool to extract the
translatable strings (e.g., pybabel) won't get "The Sage Notebook".
It'll be a problem to create the .pot file! So, I think that we have
to translate the string in the first file, not in the second, doing
this (explicit) by: msg=_("The Sage Notebook").

Cheers.

Tim Joseph Dumol

unread,
Jul 14, 2010, 10:12:37 AM7/14/10
to sage-n...@googlegroups.com
The strings have to be dynamically translated in conf.py rather than
in server_conf.py in order to allow for dynamic language
configuration. The best way to do what you want is by definding a
dummy _ function as so:

def _(message, username=None):
return message

in server_conf.py, user_conf.py and tutorial.py and other similar
places, and use those to mark the strings for translation. I'd be glad
to do so in a while, but I currently have a project that I need to
finish.

--

JinYeong Bak

unread,
Aug 4, 2010, 1:00:02 PM8/4/10
to sage-notebook
Hello.

I translate the sagemath notebook po file to Korean.

Here is Korean po file.

http://nosyu.iptime.org/~NoSyu/sagenb.po

And I test this file to my desktop. You can see this.

http://nosyu.iptime.org:8000


I found the some mistake that didn't include to po file.

For example, you click the link to register to my desktop server.

Then you'll see the English sentence.

Please ask the server administrator to configure a challenge!

I search this in po file, there is no line.


And some sentences are not correct, especially error message. Because
I rarely see those message, so I just read the source and translate
it.


And also I can't handle this lines.


#: notebook/template.py:74
#, python-format
msgid "%d second"
msgid_plural "%d seconds"
msgstr[0] ""
msgstr[1] ""

If I write this, there are errors to load the SAGE notebook.

#: notebook/template.py:74
#, python-format
msgid "%d second"
msgid_plural "%d seconds"
msgstr[0] "%d 초"
msgstr[1] "%d 초"

I don't know how to translate it.


I can get the any comments about this.


Thanks to make po file.


Have a nice day!

Sincerely.

On Jul 4, 12:27 am, Luiz Aquino <aquino.luizclau...@gmail.com> wrote:
> Hi,
>
> Me and Dan Drake are working on a Full Sage Notebook
> Internationalization (i18n).
>
> I'm glad to say that I just finish the first version. Please, if you
> want to try the Sage Notebook in your own language, follow the steps:
>
> 1. Download this file:http://sites.google.com/site/lcmaquino/sage/sagenb.tar.gz?attredirect...
>
> 2. Extract the file above in:
> $SAGE_ROOT/local/lib/python/site-packages/sagenb-0.8-py2.6.egg
>
> 3. In the directory above, rename the file "sagenb/sagenb.pot" to
> "sagenb/sagenb.po"
>
> 4. Edit sagenb.po to translate the strings. You can use the POEdit [1]
> or a plain text editor.
>
> 5. Compile sagenb.po to create sagenb.mo. The POEdit does it for you.
> Or, you can use on terminal:
> msgfmt sagenb.po -o sagenb.mo
>
> 6. Copy sagenb.mo to:
> $SAGE_ROOT/local/lib/python/site-packages/sagenb-0.8-py2.6.egg/sagenb/
> locale/xx_YY/LC_MESSAGES
>
> Where xx_YY is something like en_US, en_UK, pt_BR, etc.
>
> 7. Change the file sagenb/notebook/i18n.py (line 23) to
> CURRENT_LANGUAGE = 'xx_YY'
>
> 8. Now, run the Sage Notebook. It's in your language!
>
> Now, we need some help! Please, translate it to your own language and
> give us a feedback! I translated it to pt_BR (Brazilian Portuguese),
> so you can use it.
>
> By the way, we want to change the language using "Settings > Notebook
> Settings > Default Language", so we don't need to change thei18n.py
> manually. I know that the settings are saved in the file conf.pickle,
> at sage notebook directory ($HOME/.sage/sage_notebook.sagenb, by
> default), but I don't know how to access this fromi18n.py. Could

Mitesh Patel

unread,
Aug 4, 2010, 11:32:26 PM8/4/10
to sage-n...@googlegroups.com
On 08/04/2010 12:00 PM, JinYeong Bak wrote:
> I translate the sagemath notebook po file to Korean.
>
> Here is Korean po file.
>
> http://nosyu.iptime.org/~NoSyu/sagenb.po
>
> And I test this file to my desktop. You can see this.
>
> http://nosyu.iptime.org:8000
>
>
> I found the some mistake that didn't include to po file.
>
> For example, you click the link to register to my desktop server.
>
> Then you'll see the English sentence.
>
> Please ask the server administrator to configure a challenge!
>
> I search this in po file, there is no line.

This line appears to be from

sagenb.notebook.challenge

Have you intentionally enabled a challenge --- e.g., reCAPTCHA or a
simple question --- for account registration? You should be able to
disable or configure it from the admin user's Notebook Settings page.

Luiz Aquino

unread,
Aug 12, 2010, 12:13:44 PM8/12/10
to sage-notebook
Hi,

> And also I can't handle this lines.
>
> #: notebook/template.py:74
> #, python-format
> msgid "%d second"
> msgid_plural "%d seconds"
> msgstr[0] ""
> msgstr[1] ""

Before you translate the plural forms, you have to set up the Plural-
Forms line in the header entry of the .PO file. For exemple, the
Plural-Forms to pt-BR translation is:
"Plural-Forms: nplurals=2; plural=n>1;\n"

If you're using PoEdit, you can set up the plural form by the menu
"Catalog" > "Settings...". See [1] for more information about plural
forms.

> For example, you click the link to register to my desktop server.
>
> Then you'll see the English sentence.
>
> Please ask the server administrator to configure a challenge!
About the sentence "Please ask the server administrator to configure a
challenge!" (found in notebook/challenge.py), I forgot to put it
in .PO file. :/ I'm sorry!

I think that this message is because you choose the challenge
reCaptcha but you didn't set up it.

By the way, if you translate the words 'simple' and 'recaptcha' in the
code (notebook/server_conf.py):
'challenge_type': {
DESC : _('Type of challenge'),
GROUP : G_AUTH,
TYPE : T_CHOICE,
CHOICES : ['simple', 'recaptcha'],
},
you'll get this error, because in the code notebook/challenge.py there
are some tests that depend on those words.

> And some sentences are not correct, especially error message. Because
> I rarely see those message, so I just read the source and translate
> it.
What sentences?

Cheers.

Reference
[1] http://www.gnu.org/software/gettext/manual/gettext.html#Translating-plural-forms

ma...@mendelu.cz

unread,
Aug 23, 2010, 3:55:13 AM8/23/10
to sage-notebook
Dear all,

I wonder if this guidelines work also for current Sage Version 4.5.2,
Release Date: 2010-08-05

I do not know why, but it does not work for me now.
I had no problems with all these steps in previous version of Sage.
Now the directory is local/lib/python/site-packages/sagenb-0.8.2-
py2.6.egg

I have slightly more than 50% of czech translation.

Robert
> default), but I don't know how to access this from i18n.py. Could

ma...@mendelu.cz

unread,
Aug 23, 2010, 3:26:22 PM8/23/10
to sage-notebook
On 3 čnc, 17:27, Luiz Aquino <aquino.luizclau...@gmail.com> wrote:
> Hi,
>
> Me and Dan Drake are working on a Full Sage Notebook
> Internationalization (i18n).

Hi, in the po file there is no record for the text "Typeset" which is
near the Typeset checkbox in the header.

Thanks

Robert

ma...@mendelu.cz

unread,
Aug 23, 2010, 4:49:21 PM8/23/10
to sage-notebook


On 23 srp, 09:55, "ma...@mendelu.cz" <ma...@mendelu.cz> wrote:
> Dear all,
>
> I wonder if this guidelines work also for current Sage Version 4.5.2,
> Release Date: 2010-08-05
>

Works for me already, sorry for the noise (forgot to create the
LC_MESSAGES directory).

Many many thanks for working on this. The Czech translation is almost
complete.

Robert

ma...@mendelu.cz

unread,
Aug 24, 2010, 2:25:25 AM8/24/10
to sage-notebook

On 3 čnc, 17:27, Luiz Aquino <aquino.luizclau...@gmail.com> wrote:
> Hi,
>
> Me and Dan Drake are working on a Full Sage Notebook
> Internationalization (i18n).

Hello again, I think that the following lines near line 1977 in the
file workshhet.py should be fixed:

def _saved_by_info(self, x):
try:
u = self.__saved_by_info[x]
return ' '+_('ago by %s')%u
except (KeyError,AttributeError):
return ' '+_('ago')

The current setting does not allow to translate phrase "X minutes ago"
to Czech, which is "pred X minutami". I suggest to replace it by
something like we have seen in

#: data/sage/html/worksheet/time_since_last_edited.html:6
%(t)s ago by %(le)s

But things seem to be nontrivial for me, since the time comes from
some other part of the code, than the phrase "ago by ....". Could this
be fixed?
Many thanks

Robert
Reply all
Reply to author
Forward
0 new messages