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

Aline Manera alinefm at linux.vnet.ibm.com
Mon Nov 17 17:53:50 UTC 2014


On 11/17/2014 06:04 AM, Cedric Bosdonnat wrote:
> Hi Aline,
>
> On Fri, 2014-11-14 at 16:12 -0200, Aline Manera wrote:
>> 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?
> I got the problem by setting up a kimchi instance as done by this
> package (minus the patched I sent)
>
> https://build.opensuse.org/package/show/home:cbosdonnat/kimchi
>
> Connecting with a en_GB client. I got the following exception in the
> logs:
>
> [14/Nov/2014:06:00:06] HTTP Traceback (most recent call last):
>    File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond
>      response.body = self.handler()
>    File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 212, in __call__
>      self.body = self.oldhandler(*args, **kwargs)
>    File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 61, in __call__
>      return self.callable(*self.args, **self.kwargs)
>    File "/usr/lib/python2.7/site-packages/kimchi/root.py", line 92, in default
>      return template.render(page, kwargs)
>    File "/usr/lib/python2.7/site-packages/kimchi/template.py", line 109, in render
>      return render_cheetah_file(resource, data)
>    File "/usr/lib/python2.7/site-packages/kimchi/template.py", line 95, in render_cheetah_file
>      return Template(file=filename, searchList=params).respond()
>    File "_usr_share_kimchi_ui_pages_login_html_tmpl.py", line 107, in respond
>    File "/usr/lib64/python2.7/gettext.py", line 475, in translation
>      raise IOError(ENOENT, 'No translation file found for domain', domain)
> IOError: [Errno 2] No translation file found for domain: 'kimchi'

Weird! I've just generated a package on openSUSE 13.1 from source code:

1) git clone https://github.com/kimchi-project/kimchi.git
2) Install all the dependencies
3) sudo ./autogen.sh --with-spice-html5 && sudo make && sudo make rpm
4) Start kimchid service: sudo service kimchid start
5) Access Kimchi on a Firefox 33 which has just one language set: Arabic 
[ar]
6) Kimchi loads in English without any error.

Could you provide me a package where the error happens? And how did you 
generate it?

>
> Regards,
> --
> Cedric
>
>> 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