示例#1
0
 def getMenuItems(self, context, request):
     """Return menu item entries in a TAL-friendly form."""
     _url = url.absoluteURL(context, request)
     if checkPermission("bungeni.translation.Add", context):
         language = get_language(context)
         available = get_available_translations(context)
         results = []
         for name, obj, is_pivot_lang in self.get_languages():
             title = obj["name"]
             # skip the current language
             if name == language:
                 continue
             action_url = "%s/translate?language=%s" % (_url, name)
             extra = {
                 "id": "translation-action-%s" % name,
                 "separator": None,
                 "class": "pivot_lang" if is_pivot_lang else ""
             }
             translation_id = available.get(name)
             results.append(
                 dict(title=title,
                      description=_("Pivot Language")
                      if is_pivot_lang else "",
                      action=action_url,
                      selected=translation_id is not None,
                      icon=None,
                      extra=extra,
                      submenu=None))
         return results
     else:
         return None
示例#2
0
 def getMenuItems(self, context, request):
     """Return menu item entries in a TAL-friendly form."""
     _url = url.absoluteURL(context, request)
     if checkPermission("bungeni.translation.Add", context):
         language = get_language(context)
         available = get_available_translations(context)
         results = []
         for name, obj, is_pivot_lang in self.get_languages():
             title = obj["name"]
             # skip the current language
             if name == language:
                 continue
             action_url = "%s/translate?language=%s" % (_url, name)
             extra = {
                 "id": "translation-action-%s" % name,
                 "separator": None,
                 "class": "pivot_lang" if is_pivot_lang else ""
             }
             translation_id = available.get(name)
             results.append(
                 dict(title=title,
                      description=_("Pivot Language") if is_pivot_lang else "",
                      action=action_url,
                      selected=translation_id is not None,
                      icon=None,
                      extra=extra,
                      submenu=None))
         return results
     else:
         return None
示例#3
0
 def extra(self):
     language = get_language(self.context)
     return {
         "id": self.id,
         "class": "language-%s" % language,
         "state": language,
         "stateTitle": language
     }
示例#4
0
 def extra(self):
     language = get_language(self.context)
     return {
         "id": self.id,
         "class": "language-%s" % language,
         "state": language,
         "stateTitle": language
     }