Skip to content

Commit

Permalink
Always show "Clear..." and "This is a translation of..." menu items f…
Browse files Browse the repository at this point in the history
…or context, even if context is a default page.
  • Loading branch information
tmog committed Jan 16, 2013
1 parent 79a6ada commit 7231613
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Changes

In next release ...

- Always show "Clear..." and "This is a translation of..." menu items for context, even if context is a default page.
[tmog]

- check to make sure we do not add multiple translations for one language. Even if one is neutral and the other is not.
[tmog]

Expand Down
15 changes: 8 additions & 7 deletions src/collective/multilingual/browser/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ def getTranslationActionItems(context, request):
# default page. In this case, we compute the nearest translations
# of the parent folder, unless the parent is a navigation or site
# root.
use_parent = is_default_page and not INavigationRoot.providedBy(parent)

if use_parent:
graph = ITranslationGraph(parent)
else:
graph = ITranslationGraph(context)
use_parent = False

graph = ITranslationGraph(context)
parent_graph = ITranslationGraph(parent)

current_lang = getattr(aq_base(context), "language", "")
lt = getToolByName(context, 'portal_languages')
pt = getToolByName(context, name="portal_url")
Expand All @@ -52,7 +50,10 @@ def getTranslationActionItems(context, request):
site = pt.getPortalObject()
site_url = site.absolute_url()

lang_items = graph.getNearestTranslations()
if use_parent:
lang_items = parent_graph.getNearestTranslations()
else:
lang_items = graph.getNearestTranslations()

menu = []
for lang_id, item, distance in lang_items:
Expand Down

0 comments on commit 7231613

Please sign in to comment.