Skip to content

Commit cc56bd9

Browse files
authored
Merge pull request #189 from ThiefMaster/fixes
Fix check for presence of .mo file in translation directories
2 parents 917cd9a + cea183c commit cc56bd9

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

flask_babel/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
flaskext.babel
3-
~~~~~~~~~~~~~~
2+
flask_babel
3+
~~~~~~~~~~~
44
55
Implements i18n/l10n support for Flask applications based on Babel.
66
@@ -151,7 +151,7 @@ def list_translations(self):
151151
if not os.path.isdir(locale_dir):
152152
continue
153153

154-
if filter(lambda x: x.endswith('.mo'), os.listdir(locale_dir)):
154+
if any(x.endswith('.mo') for x in os.listdir(locale_dir)):
155155
result.append(Locale.parse(folder))
156156

157157
# If not other translations are found, add the default locale.

tests/test_integration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ def test_no_request_context():
2222
def test_multiple_directories():
2323
"""
2424
Ensure we can load translations from multiple directories.
25+
26+
This also ensures that directories without any translation files
27+
are not taken into account.
2528
"""
2629
b = babel.Babel()
2730
app = flask.Flask(__name__)

tests/translations/fr/LC_MESSAGES/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)