On Jul 23, 8:32 am, William Stein <
wst...@gmail.com> wrote:
> (1) What is gettext? I've never heard of it?
Good describe of gettext we can find in
http://docs.python.org/library/gettext.html
(23.1.3. Internationalizing your programs and modules). The main
advantage of such
way is an ability to change languages on the fly.
> (2) Thanks for making the list below. Now we need to figure out how
> to get this into Sage in an incremental way.
I did some steps:
1. First step: simply add
# -*- coding: utf-8 -*-
at first line of every .py-file. In run_notebook.py additionally
encoding
must be at lines 170-172:
config.write(_("""
# -*- coding: utf-8 -*-
####################################################################
Then I rewrite convert_seconds_to_meaningful_time_span (as described
in
first messages).
2. Next step: every string constant, which can be translated, was
converted
from
raise ValueError, 'invalid failure type'
to
raise ValueError, _('invalid failure type')
Before begin of the string add underscore and open bracket, after end
-
close bracket.
Changed files at step 1, 2, please, download from
http://semerikov.googlepages.com/notebook_modify.tar.bz2
3. Then we need to define function "_" as described in 23.1.3.1
in every module (I don't do it yet):
import gettext
t = gettext.translation('modulename', '/usr/local/sage/....../locale')
_ = t.lgettext
all.py (or some main module) must contain
import gettext
gettext.install('applicationname', '/usr/local/sage/....../locale',
unicode=1)
4. For every changed file running xgettext or Tools/i18n/pygettext.py:
python pygettext.py *.py
Resulting file (
http://semerikov.googlepages.com/messages.pot) is an
template for any notebook translation. To do new translation you must
rename messages.pot at LANG_CODE.po (e.g., for Korean - kr.po) and
write translation in msgstr (empty in template):
#: avatars.py:65
msgid "invalid failure type"
msgstr ""
> (3) Somebody else just popped up on the sage list a few days ago who
> is moving all the html generation code to jinja templates.
Thanks, I don't touch html-templates.
> I don't have a lot of time to work on the notebook now, but will in Sept - Dec.
Steps 1-4 will produce only minor (cosmetic) code changes. I hope,
it
can be done quickly (the main reason - easy and fast translation: for
example,
try Korean/English notebook at
http://math1.skku.ac.kr/).