def test_find_localized_non_existing(self): config = Config() config.locale = "tlh_TLH" config.save() task = self.loop.create_task( Resources.find("sounds", "nabclockd/0/1.mp3")) path = self.loop.run_until_complete(task) self.assertEqual(path, None)
def post(self, request, *args, **kwargs): config = Config.load() config.locale = request.POST['locale'] config.save() locales = self.get_locales() return render(request, NabWebView.template_name, context={ 'current_locale': config.locale, 'locales': locales })
def post(self, request, *args, **kwargs): if "locale" in request.POST: config = Config.load() config.locale = request.POST["locale"] config.save() asyncio.run(self.notify_config_update("nabd", "locale")) user_language = to_language(config.locale) translation.activate(user_language) request.LANGUAGE_CODE = translation.get_language() context = self.get_context() return render(request, self.template_name(), context=context)
def get(self, request, *args, **kwargs): user_locale = Config.load().locale user_language = to_language(user_locale) translation.activate(user_language) self.request.session[translation.LANGUAGE_SESSION_KEY] = user_language locales = self.get_locales() return render(request, NabWebView.template_name, context={ 'current_locale': user_locale, 'locales': locales })
def test_find_localized_non_existing(self): config = Config() config.locale = 'tlh_TLH' path = Resources.find('sounds', 'nabclockd/0/1.mp3') self.assertEqual(None, None)
def get_context(self): user_locale = Config.load().locale locales = self.get_locales() return {"current_locale": user_locale, "locales": locales}
def get_locales(self): config = Config.load() return [(to_locale(lang), name, to_locale(lang) == config.locale) for (lang, name) in settings.LANGUAGES]
def process_request(self, request): user_locale = Config.load().locale user_language = to_language(user_locale) translation.activate(user_language) request.LANGUAGE_CODE = translation.get_language()