Skip to content

Commit 840efdf

Browse files
committed
Fix support for files without namespace.
1 parent d11eb2c commit 840efdf

4 files changed

Lines changed: 9 additions & 1 deletion

File tree

i18n/resource_loader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def load_directory(directory, locale=config.get('locale')):
7373
for f in os.listdir(directory):
7474
path = os.path.join(directory, f)
7575
if os.path.isfile(path) and path.endswith(config.get('file_format')):
76+
if '{locale}' in config.get('filename_format') and not locale in f:
77+
continue
7678
load_translation_file(f, directory, locale)
7779

7880

i18n/tests/loader_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def setUp(self):
1818
translations.container = {}
1919
config.set('load_path', [os.path.join(RESOURCE_FOLDER, 'translations')])
2020
config.set('filename_format', '{namespace}.{locale}.{format}')
21+
config.set("encoding", "utf-8")
2122

2223
def test_load_unavailable_extension(self):
2324
with self.assertRaisesRegexp(I18nFileLoadError, "no loader .*"):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ja": {
3+
"foo": "ふぉお"
4+
}
5+
}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='python-i18n',
5-
version='0.2.0',
5+
version='0.2.1',
66
description='Translation library for Python',
77
long_description=open('README.md').read(),
88
author='Daniel Perez',

0 commit comments

Comments
 (0)