Skip to content

Commit

Permalink
Fix support for files without namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
danhper committed Dec 9, 2013
1 parent d11eb2c commit 840efdf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions i18n/resource_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def load_directory(directory, locale=config.get('locale')):
for f in os.listdir(directory):
path = os.path.join(directory, f)
if os.path.isfile(path) and path.endswith(config.get('file_format')):
if '{locale}' in config.get('filename_format') and not locale in f:
continue
load_translation_file(f, directory, locale)


Expand Down
1 change: 1 addition & 0 deletions i18n/tests/loader_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def setUp(self):
translations.container = {}
config.set('load_path', [os.path.join(RESOURCE_FOLDER, 'translations')])
config.set('filename_format', '{namespace}.{locale}.{format}')
config.set("encoding", "utf-8")

def test_load_unavailable_extension(self):
with self.assertRaisesRegexp(I18nFileLoadError, "no loader .*"):
Expand Down
5 changes: 5 additions & 0 deletions i18n/tests/resources/translations/ja.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ja": {
"foo": "ふぉお"
}
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='python-i18n',
version='0.2.0',
version='0.2.1',
description='Translation library for Python',
long_description=open('README.md').read(),
author='Daniel Perez',
Expand Down

0 comments on commit 840efdf

Please sign in to comment.