|
@@ -1,7 +1,6 @@
|
|
import os
|
|
import os
|
|
|
|
|
|
import babel
|
|
import babel
|
|
-from flask import _request_ctx_stack
|
|
|
|
|
|
|
|
from flask_babelex import Domain, get_locale
|
|
from flask_babelex import Domain, get_locale
|
|
from flask_plugins import get_plugins_list
|
|
from flask_plugins import get_plugins_list
|
|
@@ -20,6 +19,7 @@ class FlaskBBDomain(Domain):
|
|
self.flaskbb_translations = os.path.join(
|
|
self.flaskbb_translations = os.path.join(
|
|
self.app.root_path, "translations"
|
|
self.app.root_path, "translations"
|
|
)
|
|
)
|
|
|
|
+
|
|
|
|
|
|
with self.app.app_context():
|
|
with self.app.app_context():
|
|
self.plugin_translations = [
|
|
self.plugin_translations = [
|
|
@@ -33,12 +33,7 @@ class FlaskBBDomain(Domain):
|
|
object if used outside of the request or if a translation cannot be
|
|
object if used outside of the request or if a translation cannot be
|
|
found.
|
|
found.
|
|
"""
|
|
"""
|
|
- ctx = _request_ctx_stack.top
|
|
|
|
- if ctx is None:
|
|
|
|
- return babel.support.NullTranslations()
|
|
|
|
-
|
|
|
|
locale = get_locale()
|
|
locale = get_locale()
|
|
-
|
|
|
|
cache = self.get_translations_cache()
|
|
cache = self.get_translations_cache()
|
|
|
|
|
|
translations = cache.get(str(locale))
|
|
translations = cache.get(str(locale))
|
|
@@ -50,6 +45,11 @@ class FlaskBBDomain(Domain):
|
|
domain="messages"
|
|
domain="messages"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if not isinstance(translations, babel.support.Translations):
|
|
|
|
+ return translations
|
|
|
|
+
|
|
|
|
|
|
for plugin in self.plugin_translations:
|
|
for plugin in self.plugin_translations:
|
|
plugin_translation = babel.support.Translations.load(
|
|
plugin_translation = babel.support.Translations.load(
|