mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 20:26:48 +00:00
fix(locale): the VM page's and Settings page's messages show translated
The VM page's and the Settings page's views marked their messages with
gettext_noop, so every message they gave (a refused resize, a saved
setting, a QoS change, a busy VM) showed in English whatever the
language, though the catalogs translate them. They translate in the
request's language now; their module-level texts lazily. The Settings
page's group titles stay English in the view, as the page links them
by their slugs and translates them itself.
Two values went into translated messages as English codes: a job's
state ("... is running on this resource") and a QoS direction ("Remove
the inbound limit ..."). They are named as the pages name them.
This commit is contained in:
parent
763f1525ca
commit
9d57adc097
10 changed files with 412 additions and 380 deletions
|
|
@ -30,6 +30,12 @@ class AppSettingsTestCase(TestCase):
|
|||
choice = choice[:choice.index("</select>")]
|
||||
self.assertEqual(re.findall(r'<option value="([^"]+)"', choice), ["en", "tr", "zh-hans"])
|
||||
|
||||
def test_the_page_answers_in_the_users_language(self):
|
||||
response = self.client.post(reverse("appsettings"), {}, HTTP_ACCEPT_LANGUAGE="tr", follow=True)
|
||||
self.assertEqual([str(m) for m in get_messages(response.wsgi_request)], ["Hiçbir şey değişmedi"])
|
||||
# the groups' links stay the English slugs: the page translates only their titles
|
||||
self.assertContains(response, 'href="#new-vm-defaults"')
|
||||
|
||||
def test_appsettings_update_setting(self):
|
||||
setting = AppSettings.objects.get(key="SHOW_ACCESS_ROOT_PASSWORD")
|
||||
original_value = setting.value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue