[Kimchi-devel] [PATCH] Don't fail if no translation can be found

Aline Manera alinefm at linux.vnet.ibm.com
Fri Nov 14 18:12:51 UTC 2014


Hmm...if Kimchi does not recognize a language it falls back to English 
(en_US).
So you shouldn't have problems with it.
Could you explain what is the real problem and how I could reproduce it?

On 11/14/2014 01:10 PM, Cédric Bosdonnat wrote:
> If a translation file for a locale can't be found, the user gets an
> HTTP 50x. Use fallback=True in the translation calls to avoid this and
> use the fallback strings instead.
> ---
>   ui/pages/error.html.tmpl                  | 2 +-
>   ui/pages/guest-add.html.tmpl              | 2 +-
>   ui/pages/guest-edit.html.tmpl             | 2 +-
>   ui/pages/guest-storage-add.html.tmpl      | 2 +-
>   ui/pages/guest.html.tmpl                  | 2 +-
>   ui/pages/i18n.json.tmpl                   | 2 +-
>   ui/pages/kimchi-ui.html.tmpl              | 2 +-
>   ui/pages/login.html.tmpl                  | 2 +-
>   ui/pages/report-add.html.tmpl             | 2 +-
>   ui/pages/report-rename.html.tmpl          | 2 +-
>   ui/pages/repository-add.html.tmpl         | 2 +-
>   ui/pages/repository-edit.html.tmpl        | 2 +-
>   ui/pages/storagepool-add-volume.html.tmpl | 2 +-
>   ui/pages/storagepool-add.html.tmpl        | 2 +-
>   ui/pages/tabs/guests.html.tmpl            | 2 +-
>   ui/pages/tabs/host.html.tmpl              | 2 +-
>   ui/pages/tabs/network.html.tmpl           | 2 +-
>   ui/pages/tabs/storage.html.tmpl           | 2 +-
>   ui/pages/tabs/templates.html.tmpl         | 2 +-
>   ui/pages/template-add.html.tmpl           | 2 +-
>   ui/pages/template-edit.html.tmpl          | 2 +-
>   21 files changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/ui/pages/error.html.tmpl b/ui/pages/error.html.tmpl
> index 98566c5..d8e16e6 100644
> --- a/ui/pages/error.html.tmpl
> +++ b/ui/pages/error.html.tmpl
> @@ -19,7 +19,7 @@
>   #encoding UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!doctype html>
> diff --git a/ui/pages/guest-add.html.tmpl b/ui/pages/guest-add.html.tmpl
> index 3ccafe2..e3270fb 100644
> --- a/ui/pages/guest-add.html.tmpl
> +++ b/ui/pages/guest-add.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
> index 512909a..62965eb 100644
> --- a/ui/pages/guest-edit.html.tmpl
> +++ b/ui/pages/guest-edit.html.tmpl
> @@ -17,7 +17,7 @@
>    *#
>   #unicode UTF-8
>   #import gettext
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>
> diff --git a/ui/pages/guest-storage-add.html.tmpl b/ui/pages/guest-storage-add.html.tmpl
> index c991f42..504316c 100644
> --- a/ui/pages/guest-storage-add.html.tmpl
> +++ b/ui/pages/guest-storage-add.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <div id="guest-storage-add-window" class="window">
> diff --git a/ui/pages/guest.html.tmpl b/ui/pages/guest.html.tmpl
> index 74206fd..ebb5e86 100644
> --- a/ui/pages/guest.html.tmpl
> +++ b/ui/pages/guest.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>           <li name="guest" class="guest">
> diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl
> index 959b7be..1edbc19 100644
> --- a/ui/pages/i18n.json.tmpl
> +++ b/ui/pages/i18n.json.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   {
> diff --git a/ui/pages/kimchi-ui.html.tmpl b/ui/pages/kimchi-ui.html.tmpl
> index 2f592a6..844234d 100644
> --- a/ui/pages/kimchi-ui.html.tmpl
> +++ b/ui/pages/kimchi-ui.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   #from kimchi.config import get_version
> diff --git a/ui/pages/login.html.tmpl b/ui/pages/login.html.tmpl
> index f289af5..e2f6855 100644
> --- a/ui/pages/login.html.tmpl
> +++ b/ui/pages/login.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   #silent next = "?next=%s" % $getVar('data.next', '') if $getVar('data.next', '') else ""
> diff --git a/ui/pages/report-add.html.tmpl b/ui/pages/report-add.html.tmpl
> index 2d0c510..e63da44 100644
> --- a/ui/pages/report-add.html.tmpl
> +++ b/ui/pages/report-add.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/report-rename.html.tmpl b/ui/pages/report-rename.html.tmpl
> index 2164af8..5bc91d3 100644
> --- a/ui/pages/report-rename.html.tmpl
> +++ b/ui/pages/report-rename.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/repository-add.html.tmpl b/ui/pages/repository-add.html.tmpl
> index ecd0152..6de4f76 100644
> --- a/ui/pages/repository-add.html.tmpl
> +++ b/ui/pages/repository-add.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <div id="repository-add-window" class="window">
> diff --git a/ui/pages/repository-edit.html.tmpl b/ui/pages/repository-edit.html.tmpl
> index 56449f7..f13cb90 100644
> --- a/ui/pages/repository-edit.html.tmpl
> +++ b/ui/pages/repository-edit.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>
> diff --git a/ui/pages/storagepool-add-volume.html.tmpl b/ui/pages/storagepool-add-volume.html.tmpl
> index 573a764..c0d68f6 100644
> --- a/ui/pages/storagepool-add-volume.html.tmpl
> +++ b/ui/pages/storagepool-add-volume.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <div id="sp-add-volume-window" class="window">
> diff --git a/ui/pages/storagepool-add.html.tmpl b/ui/pages/storagepool-add.html.tmpl
> index 6f1861b..081805b 100644
> --- a/ui/pages/storagepool-add.html.tmpl
> +++ b/ui/pages/storagepool-add.html.tmpl
> @@ -17,7 +17,7 @@
>    *#
>   #unicode UTF-8
>   #import gettext
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/tabs/guests.html.tmpl b/ui/pages/tabs/guests.html.tmpl
> index 90d98e5..7bbf570 100644
> --- a/ui/pages/tabs/guests.html.tmpl
> +++ b/ui/pages/tabs/guests.html.tmpl
> @@ -20,7 +20,7 @@
>   #import gettext
>   #from Cheetah.Template import Template
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>
> diff --git a/ui/pages/tabs/host.html.tmpl b/ui/pages/tabs/host.html.tmpl
> index 81266ce..d5a9b1d 100644
> --- a/ui/pages/tabs/host.html.tmpl
> +++ b/ui/pages/tabs/host.html.tmpl
> @@ -19,7 +19,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <div id="host-root-container">
> diff --git a/ui/pages/tabs/network.html.tmpl b/ui/pages/tabs/network.html.tmpl
> index 6a6e5f7..6eaa4b3 100644
> --- a/ui/pages/tabs/network.html.tmpl
> +++ b/ui/pages/tabs/network.html.tmpl
> @@ -19,7 +19,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/tabs/storage.html.tmpl b/ui/pages/tabs/storage.html.tmpl
> index 523f480..dbbaef9 100644
> --- a/ui/pages/tabs/storage.html.tmpl
> +++ b/ui/pages/tabs/storage.html.tmpl
> @@ -18,7 +18,7 @@
>
>   #unicode UTF-8
>   #import gettext
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/tabs/templates.html.tmpl b/ui/pages/tabs/templates.html.tmpl
> index 7cf7fcd..4f91254 100644
> --- a/ui/pages/tabs/templates.html.tmpl
> +++ b/ui/pages/tabs/templates.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/template-add.html.tmpl b/ui/pages/template-add.html.tmpl
> index 75bb0ed..eaafaa7 100644
> --- a/ui/pages/template-add.html.tmpl
> +++ b/ui/pages/template-add.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>   <!DOCTYPE html>
> diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
> index 5a71d91..d315391 100644
> --- a/ui/pages/template-edit.html.tmpl
> +++ b/ui/pages/template-edit.html.tmpl
> @@ -18,7 +18,7 @@
>   #unicode UTF-8
>   #import gettext
>   #from kimchi.cachebust import href
> -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang)
> +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang, fallback=True)
>   #silent _ = t.gettext
>   #silent _t = t.gettext
>




More information about the Kimchi-devel mailing list