-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use flatten dict for store translations, remove pluralize api
- Loading branch information
1 parent
3802d91
commit e30b04d
Showing
10 changed files
with
66 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .shortcuts import trans, trans_lazy, plural, localize # noqa | ||
from .shortcuts import trans, trans_lazy, localize # noqa | ||
|
||
default_app_config = 'langpack.contrib.django.apps.LangPackConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
from langpack.utils import safe_format | ||
from langpack.utils import safe_format, flatten_dict | ||
from nose import tools as test | ||
|
||
|
||
def test_safe_format(): | ||
test.assert_equal(safe_format('Hello {name}!', name='John'), 'Hello John!') | ||
test.assert_equal(safe_format('Hello {name}!'), 'Hello {name}!') | ||
test.assert_equal(safe_format('Hello', name='John'), 'Hello') | ||
|
||
|
||
def test_flatten_dict(): | ||
data_dict = { | ||
'a': { | ||
'b': { | ||
'c': 'value', | ||
}, | ||
}, | ||
'd': { | ||
'e': 'value', | ||
}, | ||
'f': 'value', | ||
} | ||
|
||
expected = { | ||
'a.b.c': 'value', | ||
'd.e': 'value', | ||
'f': 'value', | ||
} | ||
|
||
assert flatten_dict(data_dict) == expected |