def get_interface_locale(self): context = ExecutionContext.get_context() if not hasattr(context, 'request'): return 'en_gb' url = Url.get_current_url() possible_locale, path = url.get_locale_split_path() supported_locales = ReahlEgg.get_languages_supported_by_all(context.config.reahlsystem.root_egg) if possible_locale: if possible_locale in supported_locales: return possible_locale return context.config.web.default_url_locale
def with_languages(self): """Populates this Menu with a MenuItem for each available language. Answers the same Menu. .. versionadded:: 3.2 """ context = ExecutionContext.get_context() supported_locales = ReahlEgg.get_languages_supported_by_all( context.config.reahlsystem.root_egg) for locale in supported_locales: try: language_name = Locale.parse(locale).display_name except UnknownLocaleError: language_name = locale bookmark = self.view.as_bookmark(description=language_name, locale=locale) bookmark.exact = True self.add_bookmark(bookmark) return self