Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2007-11-30 11:02:19 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2007-11-30 11:02:19 (GMT)
commitcdc7cfd24f22245ed6b565f23db5717c88552b3b (patch)
treeee73ea7da7c53ed554243634a116270cef582c25
parent5acbca906319215efdd2b6d2a65760e22affcd9c (diff)
i18n of help functions; not the final solution!
-rw-r--r--calculate.py10
-rw-r--r--eqnparser.py5
-rw-r--r--eqnparserhelp.py114
-rw-r--r--mathlib.py15
-rw-r--r--po/Calculate.pot300
5 files changed, 298 insertions, 146 deletions
diff --git a/calculate.py b/calculate.py
index 240e1c3..0e1512f 100644
--- a/calculate.py
+++ b/calculate.py
@@ -521,23 +521,23 @@ class Calculate(activity.Activity):
def read_file(self, file_path):
"""Read journal entries, version 1.0"""
- _logger.info(_('Reading from journal (%s)'), file_path)
+ _logger.info('Reading from journal (%s)', file_path)
f = open(file_path, 'r')
str = f.readline().rstrip("\r\n") # chomp
l = str.split()
if len(l) != 2:
- _logger.error(_('Unable to determine version'))
+ _logger.error('Unable to determine version')
return False
version = l[1]
if len(version) > 1 and version[0:2] == "1.":
- _logger.info(_('Reading journal entry (version %s)'), version)
+ _logger.info('Reading journal entry (version %s)', version)
str = f.readline().rstrip("\r\n")
l = str.split(';')
if len(l) != 4:
- _logger.error(_('State line invalid (%s)'), str)
+ _logger.error('State line invalid (%s)', str)
return False
self.text_entry.set_text(l[0])
@@ -554,7 +554,7 @@ class Calculate(activity.Activity):
return True
else:
- _logger.error(_('Unable to read journal entry, unknown version (%s)'), version)
+ _logger.error('Unable to read journal entry, unknown version (%s)', version)
return False
##########################################
diff --git a/eqnparser.py b/eqnparser.py
index b53e41d..eb6e68e 100644
--- a/eqnparser.py
+++ b/eqnparser.py
@@ -234,10 +234,13 @@ class EqnParser:
self.register_operator('%', self.OP_DIADIC, 2, lambda x: self.ml.mod(x[0], x[1]))
- self.set_var('help', _('help_var'), parse=False)
+ self.set_var('help',
+ _("Use help(test) for help about 'test', or help(index) for the index"),
+ parse=False)
def register_function(self, name, f, opts):
self.functions[name] = (f, opts)
+ self.functions[_(name)] = (f, opts)
def register_operator(self, op, type, presedence, f):
self.operators.append((op, type, presedence, f))
diff --git a/eqnparserhelp.py b/eqnparserhelp.py
index a39167e..1c8be1c 100644
--- a/eqnparserhelp.py
+++ b/eqnparserhelp.py
@@ -33,42 +33,102 @@ class EqnParserHelp():
# Unfortunately gettext is not yet initialized at the time _() is called here.
# Still do it like this to make sure these strings show up in the POT-file
DICT = {
- # These are the help topics and should explain how things work
- "acos": _("help_acos"),
- "and": _("help_and"),
- "asin": _("help_asin"),
- "atan": _("help_atan"),
- "cos": _("help_cos"),
- "cosh": _("help_cosh"),
- "exp": _("help_exp"),
- "fac": _("help_fac"),
- "functions": _("help_functions"),
- "ln": _("help_ln"),
- "operators": _("help_operators"),
- "or": _("help_or"),
- "plot": _("help_plot"),
- "sin": _("help_sin"),
- "sinh": _("help_sinh"),
- "sqrt": _("help_sqrt"),
- "square": _("help_square"),
- "tan": _("help_tan"),
- "tanh": _("help_tanh"),
- "test": _("help_test"),
- "variables": _("help_variables"),
- "xor": _("help_xor"),
+ # TRANS: It is possible to translate commands. However, I would highly
+ # recommend NOT doing so for mathematical functions like cos(). help(),
+ # functions() etc should be translated.
+ _("acos"): _(
+"acos(x), return the arc cosine of x. This is the angle for which the cosine \
+is x. Defined for -1 <= x < 1"),
+
+ _("and"): _(
+"and(x, y), logical and. Returns True if x and y are True, else returns False"),
+
+ _("asin"): _(
+"asin(x), return the arc sine of x. This is the angle for which the sine is x. \
+Defined for -1 <= x <= 1"),
+
+ _("atan"): _(
+"atan(x), return the arc tangent of x. This is the angle for which the tangent \
+is x. Defined for all x"),
+
+ _("cos"): _(
+"cos(x), return the cosine of x. This is the x-coordinate on the unit circle \
+at the angle x"),
+
+ _("cosh"): _(
+"cosh(x), return the hyperbolic cosine of x. Given by (exp(x) + exp(-x)) / 2"),
+
+ _("exp"): _(
+"exp(x), return the natural exponent of x. Given by e^x"),
+
+ _("fac"): _(
+"fac(x), return the factorial of x. Given by x * (x - 1) * (x - 2) * ..."),
+
+ # TRANS: This command is descriptive, so can be translated
+ _("functions"): _(
+"functions(), return a list of all the functions that are defined"),
+
+ _("ln"): _(
+"ln(x), return the natural logarithm of x. This is the value for which the \
+exponent exp() equals x. Defined for x >= 0."),
+
+ # TRANS: This command is descriptive, so can be translated
+ _("operators"): _(
+"operators(), return a list of the operators that are defined"),
+
+ _("or"): _(
+"or(x, y), logical or. Returns True if x and/or y are True, else return False"),
+
+ _("plot"): _(
+"plot(eqn, var=-a..b), plot the equation 'eqn' with the variable 'var' in the \
+range from a to b"),
+
+ _("sin"): _(
+"sin(x), return the sine of x. This is the y-coordinate on the unit circle at \
+the angle x"),
+
+ _("sinh"): _(
+"sinh(x), return the hyperbolic sine of x. Given by (exp(x) - exp(-x)) / 2"),
+
+ _("sqrt"): _(
+"sqrt(x), return the square root of x. This is the value for which the square \
+equals x. Defined for x >= 0."),
+
+ _("square"): _(
+"square(x), return the square of x. Given by x * x"
+ ),
+
+ _("tan"): _(
+"tan(x), return the tangent of x. This is the slope of the line from the origin \
+of the unit circle to the point on the unit circle defined by the angle x. Given \
+by sin(x) / cos(x)"),
+
+ _("tanh"): _(
+"sinh(x), return the hyperbolic tangent of x. Given by sinh(x) / cosh(x)"),
+
+ _("test"): _(
+"This is just a test topic, use help(index) for the index"),
+
+ # TRANS: This command is descriptive, so can be translated
+ _("variables"): _(
+"variables(), return a list of the variables that are currently defined"),
+
+ _("xor"): _(
+"xor(x, y), logical xor. Returns True if either x is True (and y is False) \
+or y is True (and x is False), else returns False"),
+
}
def __init__(self):
pass
def help(about):
- _logger.debug('help about %r', about)
-
t = type(about)
if (t != types.StringType and t != types.UnicodeType) or len(about) == 0:
- return _("help_usage")
+ return _("Use help(test) for help about 'test', or help(index) for the index")
- if about == "index":
+ # TRANS: help(index), both 'index' and the translation will work
+ if about == "index" or about == _("index"):
ret = _("Topics") + ": "
for (key, val) in EqnParserHelp.DICT.iteritems():
ret += key + " "
diff --git a/mathlib.py b/mathlib.py
index 71deb65..1edeab0 100644
--- a/mathlib.py
+++ b/mathlib.py
@@ -27,6 +27,7 @@ import logging
_logger = logging.getLogger('MathLib')
from gettext import gettext as _
+import locale
class MathLib:
ANGLE_DEG = math.pi/180
@@ -55,22 +56,20 @@ class MathLib:
self.setup_i18n()
def setup_i18n(self):
+ loc = locale.localeconv()
+
# The separator to mark thousands (default: ',')
- self.thousand_sep = _('thousand_sep')
- if self.thousand_sep == 'thousand_sep':
- self.thousand_sep = ','
+ self.thousand_sep = loc['thousands_sep']
# The separator to mark fractions (default: '.')
- self.fraction_sep = _('fraction_sep')
- if self.fraction_sep == 'fraction_sep':
- self.fraction_sep = '.'
+ self.fraction_sep = loc['decimal_point']
- # The multiplication symbol (default: '*')
+ # TRANS: multiplication symbol (default: '*')
self.mul_sym = _('mul_sym')
if self.mul_sym == 'mul_sym':
self.mul_sym = '*'
- # The division symbol (default: '/')
+ # TRANS: division symbol (default: '/')
self.div_sym = _('div_sym')
if self.div_sym == 'div_sym':
self.div_sym = '/'
diff --git a/po/Calculate.pot b/po/Calculate.pot
index b33657b..dcb2506 100644
--- a/po/Calculate.pot
+++ b/po/Calculate.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-18 11:06+0100\n"
+"POT-Creation-Date: 2007-11-30 12:00+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -20,221 +20,317 @@ msgstr ""
msgid "Calculate"
msgstr ""
-#: calculate.py:79
+#: calculate.py:80
#, python-format
msgid "Equation.parse() string invalid (%s)"
msgstr ""
-#: calculate.py:208
+#: calculate.py:210
msgid "Available functions:"
msgstr ""
-#: calculate.py:502
+#: calculate.py:504
#, python-format
msgid "Writing to journal (%s)"
msgstr ""
-#: calculate.py:522
-#, python-format
-msgid "Reading from journal (%s)"
-msgstr ""
-
-#: calculate.py:528
-msgid "Unable to determine version"
-msgstr ""
-
-#: calculate.py:533
-#, python-format
-msgid "Reading journal entry (version %s)"
-msgstr ""
-
-#: calculate.py:538
-#, python-format
-msgid "State line invalid (%s)"
-msgstr ""
-
-#: calculate.py:555
-#, python-format
-msgid "Unable to read journal entry, unknown version (%s)"
-msgstr ""
-
-#: calculate.py:784
+#: calculate.py:788
msgid "button_pressed(): invalid type"
msgstr ""
-#: eqnparser.py:54
+#: eqnparser.py:56
#, python-format
msgid "level: %d, ofs %d"
msgstr ""
-#: eqnparser.py:110
+#: eqnparser.py:112
#, python-format
msgid "Error at %d"
msgstr ""
-#: eqnparser.py:235
-msgid "help_var"
+#: eqnparser.py:238 eqnparserhelp.py:128
+msgid "Use help(test) for help about 'test', or help(index) for the index"
msgstr ""
-#: eqnparser.py:337 eqnparser.py:338
+#: eqnparser.py:342 eqnparser.py:343
#, python-format
msgid "Function '%s' not defined"
msgstr ""
-#: eqnparser.py:343
+#: eqnparser.py:348
#, python-format
msgid "Invalid number of arguments (%d instead of %d)"
msgstr ""
-#: eqnparser.py:344
+#: eqnparser.py:349
#, python-format
msgid "function takes %d args"
msgstr ""
-#: eqnparser.py:354 eqnparser.py:355
+#: eqnparser.py:359 eqnparser.py:360
#, python-format
msgid "Unable to parse argument %d: '%s'"
msgstr ""
-#: eqnparser.py:364
+#: eqnparser.py:369
#, python-format
msgid "Function error: %s"
msgstr ""
-#: eqnparser.py:465
+#: eqnparser.py:470
#, python-format
msgid "Variable '%s' not defined"
msgstr ""
-#: eqnparser.py:495
+#: eqnparser.py:500
msgid "Parse error (right parenthesis)"
msgstr ""
-#: eqnparser.py:496 eqnparser.py:507 eqnparser.py:514 eqnparser.py:585
+#: eqnparser.py:501 eqnparser.py:512 eqnparser.py:519 eqnparser.py:590
msgid "Right parenthesis unexpected"
msgstr ""
-#: eqnparser.py:506
+#: eqnparser.py:511
msgid "Parse error (right parenthesis, no left_val)"
msgstr ""
-#: eqnparser.py:520 eqnparser.py:521
+#: eqnparser.py:525 eqnparser.py:526
msgid "Number not expected"
msgstr ""
-#: eqnparser.py:529
+#: eqnparser.py:534
msgid "Operator not expected"
msgstr ""
-#: eqnparser.py:571
+#: eqnparser.py:576
msgid "Invalid operator"
msgstr ""
-#: eqnparser.py:578
+#: eqnparser.py:583
msgid "Operator expected"
msgstr ""
-#: eqnparser.py:591
+#: eqnparser.py:596
msgid "_parse(): returning None"
msgstr ""
-#: eqnparserhelp.py:37
-msgid "help_acos"
+#. TRANS: It is possible to translate commands. However, I would highly
+#. recommend NOT doing so for mathematical functions like cos(). help(),
+#. functions() etc should be translated.
+#: eqnparserhelp.py:39
+msgid "acos"
msgstr ""
-#: eqnparserhelp.py:38
-msgid "help_and"
+#: eqnparserhelp.py:40
+msgid ""
+"acos(x), return the arc cosine of x. This is the angle for which the cosine "
+"is x. Defined for -1 <= x < 1"
msgstr ""
-#: eqnparserhelp.py:39
-msgid "help_asin"
+#: eqnparserhelp.py:43
+msgid "and"
msgstr ""
-#: eqnparserhelp.py:40
-msgid "help_atan"
+#: eqnparserhelp.py:44
+msgid ""
+"and(x, y), logical and. Returns True if x and y are True, else returns False"
msgstr ""
-#: eqnparserhelp.py:41
-msgid "help_cos"
+#: eqnparserhelp.py:46
+msgid "asin"
msgstr ""
-#: eqnparserhelp.py:42
-msgid "help_cosh"
+#: eqnparserhelp.py:47
+msgid ""
+"asin(x), return the arc sine of x. This is the angle for which the sine is "
+"x. Defined for -1 <= x <= 1"
msgstr ""
-#: eqnparserhelp.py:43
-msgid "help_exp"
+#: eqnparserhelp.py:50
+msgid "atan"
msgstr ""
-#: eqnparserhelp.py:44
-msgid "help_fac"
+#: eqnparserhelp.py:51
+msgid ""
+"atan(x), return the arc tangent of x. This is the angle for which the "
+"tangent is x. Defined for all x"
msgstr ""
-#: eqnparserhelp.py:45
-msgid "help_functions"
+#: eqnparserhelp.py:54
+msgid "cos"
msgstr ""
-#: eqnparserhelp.py:46
-msgid "help_ln"
+#: eqnparserhelp.py:55
+msgid ""
+"cos(x), return the cosine of x. This is the x-coordinate on the unit circle "
+"at the angle x"
msgstr ""
-#: eqnparserhelp.py:47
-msgid "help_operators"
+#: eqnparserhelp.py:58
+msgid "cosh"
msgstr ""
-#: eqnparserhelp.py:48
-msgid "help_or"
+#: eqnparserhelp.py:59
+msgid ""
+"cosh(x), return the hyperbolic cosine of x. Given by (exp(x) + exp(-x)) / 2"
msgstr ""
-#: eqnparserhelp.py:49
-msgid "help_plot"
+#: eqnparserhelp.py:61
+msgid "exp"
msgstr ""
-#: eqnparserhelp.py:50
-msgid "help_sin"
+#: eqnparserhelp.py:62
+msgid "exp(x), return the natural exponent of x. Given by e^x"
msgstr ""
-#: eqnparserhelp.py:51
-msgid "help_sinh"
+#: eqnparserhelp.py:64
+msgid "fac"
msgstr ""
-#: eqnparserhelp.py:52
-msgid "help_sqrt"
+#: eqnparserhelp.py:65
+msgid "fac(x), return the factorial of x. Given by x * (x - 1) * (x - 2) * ..."
msgstr ""
-#: eqnparserhelp.py:53
-msgid "help_square"
+#. TRANS: This command is descriptive, so can be translated
+#: eqnparserhelp.py:68
+msgid "functions"
msgstr ""
-#: eqnparserhelp.py:54
-msgid "help_tan"
+#: eqnparserhelp.py:69
+msgid "functions(), return a list of all the functions that are defined"
msgstr ""
-#: eqnparserhelp.py:55
-msgid "help_tanh"
+#: eqnparserhelp.py:71
+msgid "ln"
msgstr ""
-#: eqnparserhelp.py:56
-msgid "help_test"
+#: eqnparserhelp.py:72
+msgid ""
+"ln(x), return the natural logarithm of x. This is the value for which the "
+"exponent exp() equals x. Defined for x >= 0."
msgstr ""
-#: eqnparserhelp.py:57
-msgid "help_variables"
+#. TRANS: This command is descriptive, so can be translated
+#: eqnparserhelp.py:76
+msgid "operators"
msgstr ""
-#: eqnparserhelp.py:58
-msgid "help_xor"
+#: eqnparserhelp.py:77
+msgid "operators(), return a list of the operators that are defined"
msgstr ""
-#: eqnparserhelp.py:69
-msgid "help_usage"
+#: eqnparserhelp.py:79
+msgid "or"
msgstr ""
-#: eqnparserhelp.py:72
-msgid "Topics"
+#: eqnparserhelp.py:80
+msgid ""
+"or(x, y), logical or. Returns True if x and/or y are True, else return False"
+msgstr ""
+
+#: eqnparserhelp.py:82
+msgid "plot"
msgstr ""
#: eqnparserhelp.py:83
+msgid ""
+"plot(eqn, var=-a..b), plot the equation 'eqn' with the variable 'var' in the "
+"range from a to b"
+msgstr ""
+
+#: eqnparserhelp.py:86
+msgid "sin"
+msgstr ""
+
+#: eqnparserhelp.py:87
+msgid ""
+"sin(x), return the sine of x. This is the y-coordinate on the unit circle at "
+"the angle x"
+msgstr ""
+
+#: eqnparserhelp.py:90
+msgid "sinh"
+msgstr ""
+
+#: eqnparserhelp.py:91
+msgid ""
+"sinh(x), return the hyperbolic sine of x. Given by (exp(x) - exp(-x)) / 2"
+msgstr ""
+
+#: eqnparserhelp.py:93
+msgid "sqrt"
+msgstr ""
+
+#: eqnparserhelp.py:94
+msgid ""
+"sqrt(x), return the square root of x. This is the value for which the square "
+"equals x. Defined for x >= 0."
+msgstr ""
+
+#: eqnparserhelp.py:97
+msgid "square"
+msgstr ""
+
+#: eqnparserhelp.py:98
+msgid "square(x), return the square of x. Given by x * x"
+msgstr ""
+
+#: eqnparserhelp.py:101
+msgid "tan"
+msgstr ""
+
+#: eqnparserhelp.py:102
+msgid ""
+"tan(x), return the tangent of x. This is the slope of the line from the "
+"origin of the unit circle to the point on the unit circle defined by the "
+"angle x. Given by sin(x) / cos(x)"
+msgstr ""
+
+#: eqnparserhelp.py:106
+msgid "tanh"
+msgstr ""
+
+#: eqnparserhelp.py:107
+msgid "sinh(x), return the hyperbolic tangent of x. Given by sinh(x) / cosh(x)"
+msgstr ""
+
+#: eqnparserhelp.py:109
+msgid "test"
+msgstr ""
+
+#: eqnparserhelp.py:110
+msgid "This is just a test topic, use help(index) for the index"
+msgstr ""
+
+#. TRANS: This command is descriptive, so can be translated
+#: eqnparserhelp.py:113
+msgid "variables"
+msgstr ""
+
+#: eqnparserhelp.py:114
+msgid "variables(), return a list of the variables that are currently defined"
+msgstr ""
+
+#: eqnparserhelp.py:116
+msgid "xor"
+msgstr ""
+
+#: eqnparserhelp.py:117
+msgid ""
+"xor(x, y), logical xor. Returns True if either x is True (and y is False) or "
+"y is True (and x is False), else returns False"
+msgstr ""
+
+#. TRANS: help(index), both 'index' and the translation will work
+#: eqnparserhelp.py:131
+msgid "index"
+msgstr ""
+
+#: eqnparserhelp.py:132
+msgid "Topics"
+msgstr ""
+
+#: eqnparserhelp.py:143
#, python-format
msgid "No help about '%s' available, use help(index) for the index"
msgstr ""
@@ -283,27 +379,21 @@ msgstr ""
msgid "Show variables"
msgstr ""
-#: mathlib.py:58
-msgid "thousand_sep"
-msgstr ""
-
-#: mathlib.py:63
-msgid "fraction_sep"
-msgstr ""
-
+#. TRANS: multiplication symbol (default: '*')
#: mathlib.py:68
msgid "mul_sym"
msgstr ""
+#. TRANS: division symbol (default: '/')
#: mathlib.py:73
msgid "div_sym"
msgstr ""
-#: mathlib.py:113
+#: mathlib.py:124
msgid "Undefined"
msgstr ""
-#: mathlib.py:119
+#: mathlib.py:134
msgid "Error: unsupported type"
msgstr ""