-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged and deconflicted with gae-init-babel of 2013-12-15
- Loading branch information
Showing
66 changed files
with
804 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import sys | ||
|
||
sys.path.insert(0, 'lib.zip') | ||
sys.path.insert(0, 'libx') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
|
||
from babel import support | ||
from flask import _request_ctx_stack | ||
from flask.ext import babel | ||
from flask.ext import wtf | ||
|
||
|
||
def _get_translations(): | ||
ctx = _request_ctx_stack.top | ||
root = os.path.dirname(os.path.abspath(__file__)) | ||
translations_path = os.path.join(root, 'translations') | ||
translations = support.Translations.load( | ||
translations_path, [babel.get_locale()], domain='messages' | ||
) | ||
ctx.wtforms_translations = translations | ||
return translations | ||
|
||
|
||
class Translations(object): | ||
def gettext(self, string): | ||
t = _get_translations() | ||
return string if t is None else t.ugettext(string) | ||
|
||
def ngettext(self, singular, plural, n): | ||
t = _get_translations() | ||
if t is None: | ||
return singular if n == 1 else plural | ||
return t.ungettext(singular, plural, n) | ||
|
||
|
||
translations = Translations() | ||
|
||
|
||
class Form(wtf.Form): | ||
def _get_translations(self): | ||
return translations |
Oops, something went wrong.