def get_alternate_languages(self): """Cache relative urls only. If we have multilingual sites and multi domain site caching absolute urls will result in very inefficient caching. Build absolute url in template. """ tm = ITranslationManager(self.context) catalog = getToolByName(self.context, 'portal_catalog') results = catalog(TranslationGroup=tm.query_canonical()) alternates = [] for item in results: url = item.getURL() alternates.append({ 'lang': item.Language, 'url': url, }) return alternates
def get_alternate_languages(self): """Cache relative urls only. If we have multilingual sites and multi domain site caching absolute urls will result in very inefficient caching. Build absolute url in template. """ tm = ITranslationManager(self.context) catalog = getToolByName(self.context, 'portal_catalog') results = catalog(TranslationGroup=tm.query_canonical()) alternates = [] for item in results: url = item.getURL() alternates.append({ 'lang': item.Language, 'url': url, }) return alternates
def get_alternate_languages(self): """Cache relative urls only. If we have multilingual sites and multi domain site caching absolute urls will result in very inefficient caching. Build absolute url in template. """ tm = ITranslationManager(self.context) catalog = getToolByName(self.context, 'portal_catalog') results = catalog(TranslationGroup=tm.query_canonical()) plone_site = getUtility(IPloneSiteRoot) portal_path = '/'.join(plone_site.getPhysicalPath()) portal_path_len = len(portal_path) alternates = [] for item in results: path_len = portal_path_len + len('{0:s}/'.format(item.Language)) url = item.getURL(relative=1)[path_len:] alternates.append({ 'lang': item.Language, 'url': url.strip('/'), }) return alternates