|
@@ -6,9 +6,21 @@ from flaskbb.utils.translations import FlaskBBDomain
|
|
|
from flaskbb.extensions import plugin_manager
|
|
|
|
|
|
|
|
|
+def _remove_compiled_translations():
|
|
|
+ translations_folder = os.path.join(current_app.root_path, "translations")
|
|
|
+
|
|
|
+ # walks through the translations folder and deletes all files
|
|
|
+ # ending with .mo
|
|
|
+ for root, dirs, files in os.walk(translations_folder):
|
|
|
+ for name in files:
|
|
|
+ if name.endswith(".mo"):
|
|
|
+ os.unlink(os.path.join(root, name))
|
|
|
+
|
|
|
+
|
|
|
def _compile_translations():
|
|
|
PLUGINS_FOLDER = os.path.join(current_app.root_path, "plugins")
|
|
|
translations_folder = os.path.join(current_app.root_path, "translations")
|
|
|
+
|
|
|
subprocess.call(["pybabel", "compile", "-d", translations_folder])
|
|
|
|
|
|
for plugin in plugin_manager.all_plugins:
|
|
@@ -23,6 +35,9 @@ def test_flaskbbdomain_translations(default_settings):
|
|
|
with current_app.test_request_context():
|
|
|
assert domain.get_translations_cache() == {}
|
|
|
|
|
|
+ # just to be on the safe side that there are really no compiled
|
|
|
+ # translations available
|
|
|
+ _remove_compiled_translations()
|
|
|
# no compiled translations are available
|
|
|
assert isinstance(domain.get_translations(), NullTranslations)
|
|
|
|