-
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.
- Loading branch information
1 parent
e30b04d
commit 1df8118
Showing
6 changed files
with
50 additions
and
20 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,5 +1,4 @@ | ||
from collections import defaultdict | ||
from functools import reduce | ||
import warnings | ||
import os | ||
|
||
|
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,14 +1,35 @@ | ||
from langpack.contrib.django import trans, trans_lazy | ||
from langpack.contrib.django import trans, localize, trans_lazy | ||
from nose import tools as test | ||
from datetime import datetime | ||
|
||
from .cases import AppTestCase | ||
|
||
|
||
class TestShortcuts(AppTestCase): | ||
def setup(self): | ||
def test_trans(self): | ||
translator = self.get_translator() | ||
translator.add_translations('en', {'foo': 'bar'}) | ||
|
||
def test_trans(self): | ||
test.assert_equal(trans('foo'), 'bar') | ||
test.assert_equal(trans_lazy('foo'), 'bar') | ||
|
||
def test_localize(self): | ||
translator = self.get_translator() | ||
|
||
translator.add_translations('en', { | ||
'datetime': { | ||
'formats': { | ||
'short': '%d.%M.%Y', | ||
}, | ||
}, | ||
}) | ||
|
||
translator.add_formatter(self.format_datetime, ['datetime']) | ||
now = datetime.now() | ||
|
||
assert localize(now, 'short') == now.strftime('%d.%M.%Y') | ||
assert localize(now, '%d.%M.%Y') == now.strftime('%d.%M.%Y') | ||
|
||
@staticmethod | ||
def format_datetime(value, format, translator): | ||
format = translator.get_template('datetime.formats.' + format, default=format) | ||
return value.strftime(format) |
File renamed without changes.
Empty file.
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