Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Apr 1, 2017
2 parents 8082a0e + cf7eb88 commit a4999cb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Vitaliy Ivanov <https://github.com/vit-ivanov>
Sergey Maranchuk <https://github.com/slav0nic>
Martey Dodoo <https://github.com/martey>
Michał Suszko <https://github.com/msuszko>
Piter Vergara <https://github.com/pitervergara>


Translators
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ django-sitetree changelog
=========================


Unreleased
----------
+ IMPORTANT: i18n trees now support lang variations (e.g. de-ch, pt-br), update your i18n trees aliases.


v1.7.0
------
* IMPORTANT: Caching reworked.
Expand Down Expand Up @@ -284,4 +289,4 @@ v0.1.1

v0.1.0
------
+ Basic sitetree functionality.
+ Basic sitetree functionality.
4 changes: 2 additions & 2 deletions docs/source/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ Example:
register_i18n_trees(['my_tree', 'my_another_tree'])
# After that you need to create trees for languages supported
# in your project, e.g.: `my_tree_en`, `my_tree_ru`.
# in your project, e.g.: `my_tree_en`, `my_tree_ru`, `my_tree_pt-br`.
# Then when we address ``my_tree`` from a template django-sitetree will render
# an appropriate tree for locale currently active in your project.
# See ``activate`` function from ``django.utils.translation``
# and https://docs.djangoproject.com/en/dev/topics/i18n/internationalization
# and https://docs.djangoproject.com/en/dev/topics/i18n/
# for more information.
2 changes: 1 addition & 1 deletion sitetree/sitetreeapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def resolve_tree_i18n_alias(self, alias):
if alias not in _I18N_TREES:
return alias

current_language_code = self.current_lang.replace('_', '-').split('-')[0]
current_language_code = self.current_lang
i18n_tree_alias = '%s_%s' % (alias, current_language_code)
trees_count = self.cache.get_entry('tree_aliases', i18n_tree_alias)

Expand Down
20 changes: 20 additions & 0 deletions sitetree/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def test_i18n(build_tree, render_template_tag, mock_template_context):
{'alias': 'i18tree_ru'},
[{'title': 'Заголовок', 'url': '/url_ru/'}],
)
build_tree(
{'alias': 'i18tree_pt-br'},
[{'title': 'Meu Título', 'url': '/url_pt-br/'}],
)
build_tree(
{'alias': 'i18tree_zh-hans'},
[{'title': '我蒂特', 'url': '/url_zh-hans/'}],
)
register_i18n_trees(['i18tree'])

activate('en')
Expand All @@ -56,6 +64,18 @@ def test_i18n(build_tree, render_template_tag, mock_template_context):
assert '/url_ru/' in result
assert 'Заголовок' in result

activate('pt-br')
result = render_template_tag('sitetree', 'sitetree_tree from "i18tree"', mock_template_context())

assert '/url_pt-br/' in result
assert 'Meu Título' in result

activate('zh-hans')
result = render_template_tag('sitetree', 'sitetree_tree from "i18tree"', mock_template_context())

assert '/url_zh-hans/' in result
assert '我蒂特' in result

deactivate_all()


Expand Down

0 comments on commit a4999cb

Please sign in to comment.