1. mohammad Efazati
  2. wtforms

Commits

James Crasta  committed fdb26b2

Add in i18n package with basic utilities to help localization implementors, a messages template and an en_US messages file.

  • Participants
  • Parent commits 903cad6
  • Branches default

Comments (0)

Files changed (5)

File .hgignore

View file
 ^docs/html
 ^dist/
 ^MANIFEST$
+wtforms/ext/i18n/.*\.mo$

File wtforms/ext/i18n/__init__.py

View file
+

File wtforms/ext/i18n/messages/en_US/LC_MESSAGES/wtforms.po

View file
+# English (United States) translations for WTForms.
+# Copyright (C) 2012 WTForms Team
+# This file is distributed under the same license as the WTForms project.
+# James Crasta <james@simplecodes.com> 2012.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: WTForms 0.6.4dev\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2012-01-31 12:58-0700\n"
+"PO-Revision-Date: 2012-01-31 13:03-0700\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: en_US <LL@li.org>\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+#: wtforms/validators.py:51
+#, python-format
+msgid "Invalid field name '%s'."
+msgstr "Invalid field name '%s'."
+
+#: wtforms/validators.py:58
+#, python-format
+msgid "Field must be equal to %(other_name)s."
+msgstr "Field must be equal to %(other_name)s."
+
+#: wtforms/validators.py:90
+#, python-format
+msgid "Field must be at least %(min)d character long."
+msgid_plural "Field must be at least %(min)d characters long."
+msgstr[0] "Field must be at least %(min)d character long."
+msgstr[1] "Field must be at least %(min)d characters long."
+
+#: wtforms/validators.py:93
+#, python-format
+msgid "Field cannot be longer than %(max)d character."
+msgid_plural "Field cannot be longer than %(max)d characters."
+msgstr[0] "Field cannot be longer than %(max)d character."
+msgstr[1] "Field cannot be longer than %(max)d characters."
+
+#: wtforms/validators.py:96
+#, python-format
+msgid "Field must be between %(min)d and %(max)d characters long."
+msgstr "Field must be between %(min)d and %(max)d characters long."
+
+#: wtforms/validators.py:131
+#, python-format
+msgid "Number must be greater than %(min)s."
+msgstr "Number must be greater than %(min)s."
+
+#: wtforms/validators.py:133
+#, python-format
+msgid "Number must be less than %(max)s."
+msgstr "Number must be less than %(max)s."
+
+#: wtforms/validators.py:135
+#, python-format
+msgid "Number must be between %(min)s and %(max)s."
+msgstr "Number must be between %(min)s and %(max)s."
+
+#: wtforms/validators.py:171
+msgid "This field is required."
+msgstr "This field is required." 
+
+#: wtforms/validators.py:199
+msgid "Invalid input."
+msgstr "Invalid input."
+
+#: wtforms/validators.py:218
+msgid "Invalid email address."
+msgstr "Invalid email address."
+
+#: wtforms/validators.py:235
+msgid "Invalid IP address."
+msgstr "Invalid IP address."
+
+#: wtforms/validators.py:253
+msgid "Invalid Mac address."
+msgstr "Invalid MAC address."
+
+#: wtforms/validators.py:278
+msgid "Invalid URL."
+msgstr "Invalid URL."
+
+#: wtforms/validators.py:296
+msgid "Invalid UUID."
+msgstr "Invalid UUID."
+
+#: wtforms/validators.py:323
+#, python-format
+msgid "Invalid value, must be one of: %(values)s."
+msgstr "Invalid value, must be one of: %(values)s."
+
+#: wtforms/validators.py:350
+#, python-format
+msgid "Invalid value, can't be any of: %(values)s."
+msgstr "Invalid value, can't be any of: %(values)s."
+
+#: wtforms/ext/appengine/fields.py:74 wtforms/ext/django/fields.py:90
+#: wtforms/ext/sqlalchemy/fields.py:122 wtforms/ext/sqlalchemy/fields.py:172
+#: wtforms/ext/sqlalchemy/fields.py:177 wtforms/fields/core.py:413
+msgid "Not a valid choice"
+msgstr "Not a valid choice"
+
+#: wtforms/ext/appengine/fields.py:93
+msgid "Not a valid list"
+msgstr "Not a valid list"
+
+#: wtforms/ext/csrf/form.py:45
+msgid "Invalid CSRF Token"
+msgstr "Invalid CSRF Token"
+
+#: wtforms/ext/csrf/session.py:56
+msgid "CSRF token missing"
+msgstr "CSRF token missing"
+
+#: wtforms/ext/csrf/session.py:64
+msgid "CSRF failed"
+msgstr "CSRF failed"
+
+#: wtforms/ext/csrf/session.py:69
+msgid "CSRF token expired"
+msgstr "CSRF token expired"
+
+#: wtforms/ext/dateutil/fields.py:48
+msgid "Please input a date/time value"
+msgstr "Please input a date/time value"
+
+#: wtforms/ext/dateutil/fields.py:60
+msgid "Invalid date/time input"
+msgstr "Invalid date/time input"
+
+#: wtforms/fields/core.py:406
+msgid "Invalid Choice: could not coerce"
+msgstr "Invalid Choice: could not coerce"
+
+#: wtforms/fields/core.py:439
+msgid "Invalid choice(s): one or more data inputs could not be coerced"
+msgstr "Invalid choice(s): one or more data inputs could not be coerced"
+
+#: wtforms/fields/core.py:446
+#, python-format
+msgid "'%(value)s' is not a valid choice for this field"
+msgstr "'%(value)s' is not a valid choice for this field"
+
+#: wtforms/fields/core.py:500
+msgid "Not a valid integer value"
+msgstr "Not a valid integer value"
+
+#: wtforms/fields/core.py:546
+msgid "Not a valid decimal value"
+msgstr "Not a valid decimal value"
+
+#: wtforms/fields/core.py:572
+msgid "Not a valid float value"
+msgstr "Not a valid float value"
+

File wtforms/ext/i18n/messages/wtforms.pot

View file
+# Translations template for WTForms.
+# Copyright (C) 2012 WTForms Team
+# This file is distributed under the same license as the WTForms project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: WTForms 0.6.4dev\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2012-01-31 12:58-0700\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"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.6\n"
+
+#: wtforms/validators.py:51
+#, python-format
+msgid "Invalid field name '%s'."
+msgstr ""
+
+#: wtforms/validators.py:58
+#, python-format
+msgid "Field must be equal to %(other_name)s."
+msgstr ""
+
+#: wtforms/validators.py:90
+#, python-format
+msgid "Field must be at least %(min)d character long."
+msgid_plural "Field must be at least %(min)d characters long."
+msgstr[0] ""
+msgstr[1] ""
+
+#: wtforms/validators.py:93
+#, python-format
+msgid "Field cannot be longer than %(max)d character."
+msgid_plural "Field cannot be longer than %(max)d characters."
+msgstr[0] ""
+msgstr[1] ""
+
+#: wtforms/validators.py:96
+#, python-format
+msgid "Field must be between %(min)d and %(max)d characters long."
+msgstr ""
+
+#: wtforms/validators.py:131
+#, python-format
+msgid "Number must be greater than %(min)s."
+msgstr ""
+
+#: wtforms/validators.py:133
+#, python-format
+msgid "Number must be less than %(max)s."
+msgstr ""
+
+#: wtforms/validators.py:135
+#, python-format
+msgid "Number must be between %(min)s and %(max)s."
+msgstr ""
+
+#: wtforms/validators.py:171
+msgid "This field is required."
+msgstr ""
+
+#: wtforms/validators.py:199
+msgid "Invalid input."
+msgstr ""
+
+#: wtforms/validators.py:218
+msgid "Invalid email address."
+msgstr ""
+
+#: wtforms/validators.py:235
+msgid "Invalid IP address."
+msgstr ""
+
+#: wtforms/validators.py:253
+msgid "Invalid Mac address."
+msgstr ""
+
+#: wtforms/validators.py:278
+msgid "Invalid URL."
+msgstr ""
+
+#: wtforms/validators.py:296
+msgid "Invalid UUID."
+msgstr ""
+
+#: wtforms/validators.py:323
+#, python-format
+msgid "Invalid value, must be one of: %(values)s."
+msgstr ""
+
+#: wtforms/validators.py:350
+#, python-format
+msgid "Invalid value, can't be any of: %(values)s."
+msgstr ""
+
+#: wtforms/ext/appengine/fields.py:74 wtforms/ext/django/fields.py:90
+#: wtforms/ext/sqlalchemy/fields.py:122 wtforms/ext/sqlalchemy/fields.py:172
+#: wtforms/ext/sqlalchemy/fields.py:177 wtforms/fields/core.py:413
+msgid "Not a valid choice"
+msgstr ""
+
+#: wtforms/ext/appengine/fields.py:93
+msgid "Not a valid list"
+msgstr ""
+
+#: wtforms/ext/csrf/form.py:45
+msgid "Invalid CSRF Token"
+msgstr ""
+
+#: wtforms/ext/csrf/session.py:56
+msgid "CSRF token missing"
+msgstr ""
+
+#: wtforms/ext/csrf/session.py:64
+msgid "CSRF failed"
+msgstr ""
+
+#: wtforms/ext/csrf/session.py:69
+msgid "CSRF token expired"
+msgstr ""
+
+#: wtforms/ext/dateutil/fields.py:48
+msgid "Please input a date/time value"
+msgstr ""
+
+#: wtforms/ext/dateutil/fields.py:60
+msgid "Invalid date/time input"
+msgstr ""
+
+#: wtforms/fields/core.py:406
+msgid "Invalid Choice: could not coerce"
+msgstr ""
+
+#: wtforms/fields/core.py:439
+msgid "Invalid choice(s): one or more data inputs could not be coerced"
+msgstr ""
+
+#: wtforms/fields/core.py:446
+#, python-format
+msgid "'%(value)s' is not a valid choice for this field"
+msgstr ""
+
+#: wtforms/fields/core.py:500
+msgid "Not a valid integer value"
+msgstr ""
+
+#: wtforms/fields/core.py:546
+msgid "Not a valid decimal value"
+msgstr ""
+
+#: wtforms/fields/core.py:572
+msgid "Not a valid float value"
+msgstr ""
+

File wtforms/ext/i18n/utils.py

View file
+import os
+
+def messages_path():
+    """
+    Determine the path to the 'messages' directory as best possible.
+    """
+    module_path = os.path.abspath(__file__)
+    return os.path.join(os.path.dirname(module_path), 'messages')
+
+
+def get_builtin_gnu_translations(languages=None):
+    """
+    Get a gettext.GNUTranslations object pointing at the
+    included translation files.
+    """
+    import gettext
+    return gettext.translation('wtforms', messages_path(), languages)