[PATCH V9 0/9] Issue #342: load i18n.html of the plugin

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> V7 -> V8: improve the commit message. improve the test case skip conditional expression, remove parenthesis V5 -> V6: skip test, when disable plugin. V4 -> V5: let autoconf generate sample.conf V3 -> V4: rebase V2 -> V3: change "enable-plugins" to "enable-sample" remove nls improve the Portuguese translation. V1 -> V2: The improvement concept here is to directly generate JSON on the server and assign it to the i18n variable, rather than inserting nodes into the DOM. Plugins would use a plugin1.i18n= structure to keep plugin strings from colliding with each other, or with the kimchi variables. ShaoHe Feng (8): Update root.py to make Cheetah render the JSON template. Update the i18n tmpl to produce JSON Add JS API for fetching i18n JSON Issue #342: load i18n.html of the plugin add an option to toggle the sample plugin generate the translation files for plugins/sample skip plugins test, when sample plugin is not enabled add some sample plugin generated files to .gitignore Zhou Zheng Sheng (1): Add Minimal UI Page for the Sample Plugin .gitignore | 2 + configure.ac | 19 ++++ plugins/sample/Makefile.am | 11 +- plugins/sample/__init__.py | 3 +- plugins/sample/config.status | 1 + plugins/sample/po/LINGUAS | 1 + plugins/sample/po/Makefile.in.in | 1 + plugins/sample/po/Makevars | 41 ++++++++ plugins/sample/po/POTFILES.in | 2 + plugins/sample/po/en_US.po | 21 ++++ plugins/sample/po/gen-pot | 9 ++ plugins/sample/po/pt_BR.po | 24 +++++ plugins/sample/po/sample.pot | 21 ++++ plugins/sample/po/zh_CN.po | 24 +++++ plugins/sample/sample.conf | 7 -- plugins/sample/sample.conf.in | 24 +++++ plugins/sample/ui/Makefile.am | 2 +- plugins/sample/ui/config/tab-ext.xml | 8 +- plugins/sample/ui/js/Makefile.am | 21 ++++ plugins/sample/ui/js/util.js | 33 ++++++ plugins/sample/ui/pages/Makefile.am | 21 ++++ plugins/sample/ui/pages/i18n.json.tmpl | 9 ++ plugins/sample/ui/pages/tab.html.tmpl | 30 ++++++ src/kimchi/root.py | 5 + src/kimchi/template.py | 34 ++++--- tests/test_plugin.py | 4 + ui/js/src/kimchi.api.js | 18 +++- ui/js/src/kimchi.main.js | 24 ++++- ui/pages/i18n.html.tmpl | 179 --------------------------------- ui/pages/i18n.json.tmpl | 166 ++++++++++++++++++++++++++++++ 30 files changed, 550 insertions(+), 215 deletions(-) create mode 120000 plugins/sample/config.status create mode 120000 plugins/sample/po/LINGUAS create mode 120000 plugins/sample/po/Makefile.in.in create mode 100644 plugins/sample/po/Makevars create mode 100644 plugins/sample/po/POTFILES.in create mode 100644 plugins/sample/po/en_US.po create mode 100755 plugins/sample/po/gen-pot create mode 100644 plugins/sample/po/pt_BR.po create mode 100644 plugins/sample/po/sample.pot create mode 100644 plugins/sample/po/zh_CN.po delete mode 100644 plugins/sample/sample.conf create mode 100644 plugins/sample/sample.conf.in create mode 100644 plugins/sample/ui/js/Makefile.am create mode 100644 plugins/sample/ui/js/util.js create mode 100644 plugins/sample/ui/pages/Makefile.am create mode 100644 plugins/sample/ui/pages/i18n.json.tmpl create mode 100644 plugins/sample/ui/pages/tab.html.tmpl delete mode 100644 ui/pages/i18n.html.tmpl create mode 100644 ui/pages/i18n.json.tmpl -- 1.9.3

From: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Add minimal UI just enough to re-produce issue 342. https://github.com/kimchi-project/kimchi/issues/342 Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- configure.ac | 2 ++ plugins/sample/__init__.py | 3 ++- plugins/sample/sample.conf | 17 +++++++++++++++++ plugins/sample/ui/Makefile.am | 2 +- plugins/sample/ui/config/tab-ext.xml | 8 ++++---- plugins/sample/ui/js/Makefile.am | 21 +++++++++++++++++++++ plugins/sample/ui/js/util.js | 33 +++++++++++++++++++++++++++++++++ plugins/sample/ui/pages/Makefile.am | 21 +++++++++++++++++++++ plugins/sample/ui/pages/i18n.json.tmpl | 9 +++++++++ plugins/sample/ui/pages/tab.html.tmpl | 30 ++++++++++++++++++++++++++++++ 10 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 plugins/sample/ui/js/Makefile.am create mode 100644 plugins/sample/ui/js/util.js create mode 100644 plugins/sample/ui/pages/Makefile.am create mode 100644 plugins/sample/ui/pages/i18n.json.tmpl create mode 100644 plugins/sample/ui/pages/tab.html.tmpl diff --git a/configure.ac b/configure.ac index cc971e8..db87060 100644 --- a/configure.ac +++ b/configure.ac @@ -64,6 +64,8 @@ AC_CONFIG_FILES([ plugins/sample/Makefile plugins/sample/ui/Makefile plugins/sample/ui/config/Makefile + plugins/sample/ui/js/Makefile + plugins/sample/ui/pages/Makefile ui/Makefile ui/css/Makefile ui/css/novnc/Makefile diff --git a/plugins/sample/__init__.py b/plugins/sample/__init__.py index 3183898..2101aed 100644 --- a/plugins/sample/__init__.py +++ b/plugins/sample/__init__.py @@ -26,6 +26,7 @@ from kimchi.config import PluginPaths from kimchi.control.base import Collection, Resource +from kimchi.root import Root from plugins.sample.i18n import messages from plugins.sample.model import Model @@ -33,7 +34,7 @@ model = Model() -class Drawings(Resource): +class Drawings(Root): def __init__(self): Resource.__init__(self, model) self.description = Description(model) diff --git a/plugins/sample/sample.conf b/plugins/sample/sample.conf index c4e80f7..d4994e5 100644 --- a/plugins/sample/sample.conf +++ b/plugins/sample/sample.conf @@ -4,4 +4,21 @@ plugin_class = "Drawings" uri = "/plugins/sample" [/] +tools.nocache.on = True tools.trailing_slash.on = False +tools.sessions.on = True +tools.sessions.name = 'kimchi' +tools.sessions.httponly = True +tools.sessions.locking = 'explicit' +tools.sessions.storage_type = 'ram' + +[/description] +tools.kimchiauth.on = True + +[/rectangles] +tools.kimchiauth.on = True +tools.kimchiauth.admin_methods = ['POST', 'PUT'] + +[/circles] +tools.kimchiauth.on = True +tools.kimchiauth.admin_methods = ['POST', 'PUT'] diff --git a/plugins/sample/ui/Makefile.am b/plugins/sample/ui/Makefile.am index 0ee244f..37fec98 100644 --- a/plugins/sample/ui/Makefile.am +++ b/plugins/sample/ui/Makefile.am @@ -17,6 +17,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SUBDIRS = config +SUBDIRS = config js pages diff --git a/plugins/sample/ui/config/tab-ext.xml b/plugins/sample/ui/config/tab-ext.xml index 948fa07..8e0b3d3 100644 --- a/plugins/sample/ui/config/tab-ext.xml +++ b/plugins/sample/ui/config/tab-ext.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> -<!--<tabs-ext> +<tabs-ext> <tab> - <title>Test</title> - <filePath>plugins/sample/ui/tab.html</filePath> + <title>SampleTab</title> + <path>plugins/sample/tab.html</path> </tab> -</tabs-ext>--> \ No newline at end of file +</tabs-ext> diff --git a/plugins/sample/ui/js/Makefile.am b/plugins/sample/ui/js/Makefile.am new file mode 100644 index 0000000..c484049 --- /dev/null +++ b/plugins/sample/ui/js/Makefile.am @@ -0,0 +1,21 @@ +# +# Kimchi +# +# Copyright IBM Corp, 2014 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +EXTRA_DIST = util.js + diff --git a/plugins/sample/ui/js/util.js b/plugins/sample/ui/js/util.js new file mode 100644 index 0000000..157ddde --- /dev/null +++ b/plugins/sample/ui/js/util.js @@ -0,0 +1,33 @@ +/* + * Project Kimchi + * + * Copyright IBM, Corp. 2014 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +sample = {}; + +sample.description = function(suc, err){ + kimchi.requestJSON({ + url : kimchi.url + 'plugins/sample/description', + type : 'GET', + contentType : 'application/json', + dataType : 'json', + resend : true, + success : suc, + error : err || function(data) { + kimchi.message.error(data.responseJSON.reason); + } + }); +}; diff --git a/plugins/sample/ui/pages/Makefile.am b/plugins/sample/ui/pages/Makefile.am new file mode 100644 index 0000000..f7a5c3c --- /dev/null +++ b/plugins/sample/ui/pages/Makefile.am @@ -0,0 +1,21 @@ +# +# Kimchi +# +# Copyright IBM Corp, 2014 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +EXTRA_DIST = i18n.json.tmpl tab.html.tmpl + diff --git a/plugins/sample/ui/pages/i18n.json.tmpl b/plugins/sample/ui/pages/i18n.json.tmpl new file mode 100644 index 0000000..a153e2d --- /dev/null +++ b/plugins/sample/ui/pages/i18n.json.tmpl @@ -0,0 +1,9 @@ +#unicode UTF-8 +#import gettext +#from kimchi.cachebust import href +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) +#silent _ = t.gettext +#silent _t = t.gettext +{ + "SampleTab": "$_("SampleTab")" +} diff --git a/plugins/sample/ui/pages/tab.html.tmpl b/plugins/sample/ui/pages/tab.html.tmpl new file mode 100644 index 0000000..4354d81 --- /dev/null +++ b/plugins/sample/ui/pages/tab.html.tmpl @@ -0,0 +1,30 @@ +#* + * Project Kimchi + * + * Copyright IBM, Corp. 2014 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *# +#unicode UTF-8 +<!DOCTYPE html> +<html> +<script type="text/javascript" src="plugins/sample/js/util.js"></script> +<body> + <div id="samplebody"/> +</body> +<script> + sample.description(function(r){ + \$("#samplebody").html("name: " + r.name + " version: " + r.version); + }); +</script> +</html> -- 1.9.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> when the request are json files, set the Content-Type as application/json. Signed-off-by: Adam King <rak@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/root.py | 5 +++++ src/kimchi/template.py | 34 +++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/kimchi/root.py b/src/kimchi/root.py index 9186486..48a1f87 100644 --- a/src/kimchi/root.py +++ b/src/kimchi/root.py @@ -82,6 +82,11 @@ def get(self): def default(self, page, **kwargs): if page.endswith('.html'): return template.render(page, kwargs) + if page.endswith('.json'): + cherrypy.response.headers['Content-Type'] = \ + 'application/json;charset=utf-8' + context = template.render_cheetah_file(page, None) + return context.encode("utf-8") raise cherrypy.HTTPError(404) @cherrypy.expose diff --git a/src/kimchi/template.py b/src/kimchi/template.py index 60cd818..146e735 100644 --- a/src/kimchi/template.py +++ b/src/kimchi/template.py @@ -82,26 +82,30 @@ def can_accept_html(): can_accept('*/*') +def render_cheetah_file(resource, data): + paths = cherrypy.request.app.root.paths + filename = paths.get_template_path(resource) + try: + params = {'data': data} + lang = validate_language(get_lang()) + gettext_conf = {'domain': 'kimchi', + 'localedir': paths.mo_dir, + 'lang': [lang]} + params['lang'] = gettext_conf + return Template(file=filename, searchList=params).respond() + except OSError, e: + if e.errno == errno.ENOENT: + raise cherrypy.HTTPError(404) + else: + raise + + def render(resource, data): if can_accept('application/json'): cherrypy.response.headers['Content-Type'] = \ 'application/json;charset=utf-8' return json.dumps(data, indent=2, separators=(',', ':')) elif can_accept_html(): - paths = cherrypy.request.app.root.paths - filename = paths.get_template_path(resource) - try: - params = {'data': data} - lang = validate_language(get_lang()) - gettext_conf = {'domain': 'kimchi', - 'localedir': paths.mo_dir, - 'lang': [lang]} - params['lang'] = gettext_conf - return Template(file=filename, searchList=params).respond() - except OSError, e: - if e.errno == errno.ENOENT: - raise cherrypy.HTTPError(404) - else: - raise + return render_cheetah_file(resource, data) else: raise cherrypy.HTTPError(406) -- 1.9.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Remove html tags from i18n as they are not valid Correct object definition from acceptable JS to valid JSON replacing ' with " in attribute names. Signed-off-by: Adam King <rak@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Conflicts: ui/pages/i18n.html.tmpl --- ui/pages/i18n.html.tmpl | 179 ------------------------------------------------ ui/pages/i18n.json.tmpl | 166 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 179 deletions(-) delete mode 100644 ui/pages/i18n.html.tmpl create mode 100644 ui/pages/i18n.json.tmpl diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl deleted file mode 100644 index 375a37a..0000000 --- a/ui/pages/i18n.html.tmpl +++ /dev/null @@ -1,179 +0,0 @@ -#* - * Project Kimchi - * - * Copyright IBM, Corp. 2013 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *# -#unicode UTF-8 -#import gettext -#from kimchi.cachebust import href -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) -#silent _ = t.gettext -#silent _t = t.gettext - -<!DOCTYPE html> -<html class="no-js" lang=$lang.lang[0]> -<head> - <meta charset="utf-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> - <title>language</title> -</head> -<body> -<script> -var i18n = { - 'KCHAUTH6001E': "$_("The username or password you entered is incorrect. Please try again.")", - 'KCHAUTH6002E': "$_("This field is required.")", - - 'KCHAUTH6001M': "$_("Log in")", - 'KCHAUTH6002M': "$_("Logging in...")", - - 'Host': "$_("Host")", - 'Guests': "$_("Guests")", - 'Templates': "$_("Templates")", - 'Storage': "$_("Storage")", - 'Network': "$_("Network")", - - 'KCHAPI6001E': "$_("Invalid URL. Redireced to home page.")", - 'KCHAPI6002E': "$_("Failed to get application configuration")", - 'KCHAPI6003E': "$_("This is not a valid Linux path")", - 'KCHAPI6004E': "$_("This is not a valid URL.")", - 'KCHAPI6005E': "$_("No such data available.")", - 'KCHAPI6006E': "$_("options needed.")", - 'KCHAPI6007E': "$_("Can not contact the host system. Verify the host system is up and that you have network connectivity to it. HTTP request response %1. ")", - - 'KCHAPI6001M': "$_("Delete Confirmation")", - 'KCHAPI6002M': "$_("OK")", - 'KCHAPI6003M': "$_("Cancel")", - 'KCHAPI6004M': "$_("Confirm")", - 'KCHAPI6005M': "$_("Create")", - 'KCHAPI6006M': "$_("Warning")", - 'KCHAPI6007M': "$_("Save")", - - 'KCHGRD6001M': "$_("Loading...")", - 'KCHGRD6002M': "$_("An error occurs while checking for packages update.")", - 'KCHGRD6003M': "$_("Retry")", - 'KCHGRD6004M': "$_("Detailed message:")", - - 'KCHTMPL6001W': "$_("No iso found")", - - 'KCHTMPL6002E': "$_("This is not a valid ISO file.")", - - 'KCHTMPL6002M': "$_("It will take long time. Do you want to continue?")", - 'KCHTMPL6003M': "$_("This will permanently delete the template. Would you like to continue?")", - - 'KCHHOST6001E': "$_("Unable to shut down system as there are some virtual machines running!")", - - 'KCHHOST6001M': "$_("Max:")", - 'KCHHOST6002M': "$_("Utilization")", - 'KCHHOST6003M': "$_("Available")", - 'KCHHOST6004M': "$_("Read Rate")", - 'KCHHOST6005M': "$_("Write Rate")", - 'KCHHOST6006M': "$_("Received")", - 'KCHHOST6007M': "$_("Sent")", - 'KCHHOST6008M': "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")", - - - 'KCHREPO6001M': "$_("Confirm")", - 'KCHREPO6002M': "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", - 'KCHREPO6003M': "$_("Repositories")", - 'KCHREPO6004M': "$_("ID")", - 'KCHREPO6005M': "$_("Name")", - 'KCHREPO6006M': "$_("Base URL")", - 'KCHREPO6007M': "$_("Is Mirror")", - 'KCHREPO6008M': "$_("URL Args")", - 'KCHREPO6009M': "$_("Enabled")", - 'KCHREPO6010M': "$_("GPG Check")", - 'KCHREPO6011M': "$_("GPG Key")", - 'KCHREPO6012M': "$_("Add")", - 'KCHREPO6013M': "$_("Edit")", - 'KCHREPO6014M': "$_("Remove")", - 'KCHREPO6015M': "$_("Failed.")", - 'KCHREPO6016M': "$_("Enable")", - 'KCHREPO6017M': "$_("Disable")", - - - 'KCHUPD6001M': "$_("Software Updates")", - 'KCHUPD6002M': "$_("Package Name")", - 'KCHUPD6003M': "$_("Version")", - 'KCHUPD6004M': "$_("Architecture")", - 'KCHUPD6005M': "$_("Repository")", - 'KCHUPD6006M': "$_("Update All")", - 'KCHUPD6007M': "$_("Updating...")", - 'KCHUPD6008M': "$_("Failed to retrieve updates.")", - 'KCHUPD6009M': "$_("Failed to update package(s).")", - - - 'KCHDR6001M': "$_("Debug report will be removed permanently and can't be recovered. Do you want to continue?")", - 'KCHDR6002M': "$_("Debug Reports")", - 'KCHDR6003M': "$_("Name")", - 'KCHDR6005M': "$_("Generated Time")", - 'KCHDR6006M': "$_("Generate")", - 'KCHDR6007M': "$_("Generating...")", - 'KCHDR6008M': "$_("Rename")", - 'KCHDR6009M': "$_("Remove")", - 'KCHDR6010M': "$_("Download")", - 'KCHDR6011M': "$_("Report name should contain only letters, digits and/or hyphen ('-').")", - 'KCHDR6012M': "$_("Pending...")", - - 'KCHVM6001M': "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")", - 'KCHVM6002M': "$_("Power off Confirmation")", - 'KCHVM6003M': "$_("This action may produce undesirable results, " - "for example unflushed disk cache in the guest. " - "Would you like to continue?")", - 'KCHVM6004M': "$_("Reset Confirmation")", - 'KCHVM6005M': "$_("There is a risk of data loss caused by reset without" - " the guest OS shutdown. Would you like to continue?")", - 'KCHVM6006M': "$_("Shut Down Confirmation")", - 'KCHVM6007M': "$_("Note the guest OS may ignore this request. Would you like to continue?")", - 'KCHVM6008M': "$_("VM Delete Confirmation")", - - 'KCHVMCD6001M': "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", - 'KCHVMCD6002M': "$_("Attach")", - 'KCHVMCD6003M': "$_("Attaching...")", - 'KCHVMCD6004M': "$_("Replace")", - 'KCHVMCD6005M': "$_("Replacing...")", - 'KCHVMCD6006M': "$_("Successfully attached!")", - 'KCHVMCD6007M': "$_("Successfully replaced!")", - 'KCHVMCD6008M': "$_("Successfully detached!")", - - - 'KCHNET6001E': "$_("The VLAN id must be between 1 and 4094.")", - - 'KCHNET6001M': "$_("unavailable")", - 'KCHNET6002M': "$_("This action will interrupt network connectivity for any virtual machine that depend on this network.")", - 'KCHNET6003M': "$_("Create a network")", - 'KCHNET6004M': "$_("This network is not persistent. Instead of stop, this action will permanently delete it. Would you like to continue?")", - - 'KCHPOOL6001M': "$_("This will permanently delete the storage pool. Would you like to continue?")", - 'KCHPOOL6002M': "$_("This storage pool is empty.")", - 'KCHPOOL6003M': "$_("It will format your disk and you will loose any data in there, are you sure to continue? ")", - 'KCHPOOL6004M': "$_("SCSI Fibre Channel")", - 'KCHPOOL6005M': "$_("No SCSI adapters found.")", - - 'KCHPOOL6001E': "$_("The storage pool name can not be blank.")", - 'KCHPOOL6002E': "$_("The storage pool path can not be blank.")", - 'KCHPOOL6003E': "$_("NFS server mount path can not be blank.")", - 'KCHPOOL6004E': "$_("Invalid storage pool name. It should not contain '/'.")", - 'KCHPOOL6005E': "$_("Invalid NFS mount path.")", - 'KCHPOOL6006E': "$_("No logical device selected.")", - 'KCHPOOL6007E': "$_("The iSCSI target can not be blank.")", - 'KCHPOOL6008E': "$_("Server name can not be blank.")", - 'KCHPOOL6009E': "$_("This is not a valid Server Name or IP. please, modify it.")", - 'KCHPOOL6010M': "$_("Looking for available partitions ...")", - 'KCHPOOL6011M': "$_("No available partitions found.")", - 'KCHPOOL6012M': "$_("This storage pool is not persistent. Instead of deactivate, this action will permanently delete it. Would you like to continue?")" -}; -</script> -</body> -</html> diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl new file mode 100644 index 0000000..ce23bc4 --- /dev/null +++ b/ui/pages/i18n.json.tmpl @@ -0,0 +1,166 @@ +#* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *# +#unicode UTF-8 +#import gettext +#from kimchi.cachebust import href +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) +#silent _ = t.gettext +#silent _t = t.gettext +{ + "KCHAUTH6001E": "$_("The username or password you entered is incorrect. Please try again.")", + "KCHAUTH6002E": "$_("This field is required.")", + + "KCHAUTH6001M": "$_("Log in")", + "KCHAUTH6002M": "$_("Logging in...")", + + "Host": "$_("Host")", + "Guests": "$_("Guests")", + "Templates": "$_("Templates")", + "Storage": "$_("Storage")", + "Network": "$_("Network")", + + "KCHAPI6001E": "$_("Invalid URL. Redireced to home page.")", + "KCHAPI6002E": "$_("Failed to get application configuration")", + "KCHAPI6003E": "$_("This is not a valid Linux path")", + "KCHAPI6004E": "$_("This is not a valid URL.")", + "KCHAPI6005E": "$_("No such data available.")", + "KCHAPI6006E": "$_("options needed.")", + "KCHAPI6007E": "$_("Can not contact the host system. Verify the host system is up and that you have network connectivity to it. HTTP request response %1. ")", + + "KCHAPI6001M": "$_("Delete Confirmation")", + "KCHAPI6002M": "$_("OK")", + "KCHAPI6003M": "$_("Cancel")", + "KCHAPI6004M": "$_("Confirm")", + "KCHAPI6005M": "$_("Create")", + "KCHAPI6006M": "$_("Warning")", + "KCHAPI6007M": "$_("Save")", + + "KCHGRD6001M": "$_("Loading...")", + "KCHGRD6002M": "$_("An error occurs while checking for packages update.")", + "KCHGRD6003M": "$_("Retry")", + "KCHGRD6004M": "$_("Detailed message:")", + + "KCHTMPL6001W": "$_("No iso found")", + + "KCHTMPL6002E": "$_("This is not a valid ISO file.")", + + "KCHTMPL6002M": "$_("It will take long time. Do you want to continue?")", + "KCHTMPL6003M": "$_("This will permanently delete the template. Would you like to continue?")", + + "KCHHOST6001E": "$_("Unable to shut down system as there are some virtual machines running!")", + + "KCHHOST6001M": "$_("Max:")", + "KCHHOST6002M": "$_("Utilization")", + "KCHHOST6003M": "$_("Available")", + "KCHHOST6004M": "$_("Read Rate")", + "KCHHOST6005M": "$_("Write Rate")", + "KCHHOST6006M": "$_("Received")", + "KCHHOST6007M": "$_("Sent")", + "KCHHOST6008M": "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")", + + + "KCHREPO6001M": "$_("Confirm")", + "KCHREPO6002M": "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", + "KCHREPO6003M": "$_("Repositories")", + "KCHREPO6004M": "$_("ID")", + "KCHREPO6005M": "$_("Name")", + "KCHREPO6006M": "$_("Base URL")", + "KCHREPO6007M": "$_("Is Mirror")", + "KCHREPO6008M": "$_("URL Args")", + "KCHREPO6009M": "$_("Enabled")", + "KCHREPO6010M": "$_("GPG Check")", + "KCHREPO6011M": "$_("GPG Key")", + "KCHREPO6012M": "$_("Add")", + "KCHREPO6013M": "$_("Edit")", + "KCHREPO6014M": "$_("Remove")", + "KCHREPO6015M": "$_("Failed.")", + "KCHREPO6016M": "$_("Enable")", + "KCHREPO6017M": "$_("Disable")", + + + "KCHUPD6001M": "$_("Software Updates")", + "KCHUPD6002M": "$_("Package Name")", + "KCHUPD6003M": "$_("Version")", + "KCHUPD6004M": "$_("Architecture")", + "KCHUPD6005M": "$_("Repository")", + "KCHUPD6006M": "$_("Update All")", + "KCHUPD6007M": "$_("Updating...")", + "KCHUPD6008M": "$_("Failed to retrieve updates.")", + "KCHUPD6009M": "$_("Failed to update package(s).")", + + + "KCHDR6001M": "$_("Debug report will be removed permanently and can't be recovered. Do you want to continue?")", + "KCHDR6002M": "$_("Debug Reports")", + "KCHDR6003M": "$_("Name")", + "KCHDR6005M": "$_("Generated Time")", + "KCHDR6006M": "$_("Generate")", + "KCHDR6007M": "$_("Generating...")", + "KCHDR6008M": "$_("Rename")", + "KCHDR6009M": "$_("Remove")", + "KCHDR6010M": "$_("Download")", + "KCHDR6011M": "$_("Report name should contain only letters, digits and/or hyphen ('-').")", + "KCHDR6012M": "$_("Pending...")", + + "KCHVM6001M": "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")", + "KCHVM6002M": "$_("Power off Confirmation")", + "KCHVM6003M": "$_("This action may produce undesirable results, " + "for example unflushed disk cache in the guest. " + "Would you like to continue?")", + "KCHVM6004M": "$_("Reset Confirmation")", + "KCHVM6005M": "$_("There is a risk of data loss caused by reset without" + " the guest OS shutdown. Would you like to continue?")", + "KCHVM6006M": "$_("Shut Down Confirmation")", + "KCHVM6007M": "$_("Note the guest OS may ignore this request. Would you like to continue?")", + "KCHVM6008M": "$_("VM Delete Confirmation")", + + "KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", + "KCHVMCD6002M": "$_("Attach")", + "KCHVMCD6003M": "$_("Attaching...")", + "KCHVMCD6004M": "$_("Replace")", + "KCHVMCD6005M": "$_("Replacing...")", + "KCHVMCD6006M": "$_("Successfully attached!")", + "KCHVMCD6007M": "$_("Successfully replaced!")", + "KCHVMCD6008M": "$_("Successfully detached!")", + + + "KCHNET6001E": "$_("The VLAN id must be between 1 and 4094.")", + + "KCHNET6001M": "$_("unavailable")", + "KCHNET6002M": "$_("This action will interrupt network connectivity for any virtual machine that depend on this network.")", + "KCHNET6003M": "$_("Create a network")", + "KCHNET6004M": "$_("This network is not persistent. Instead of stop, this action will permanently delete it. Would you like to continue?")", + + "KCHPOOL6001M": "$_("This will permanently delete the storage pool. Would you like to continue?")", + "KCHPOOL6002M": "$_("This storage pool is empty.")", + "KCHPOOL6003M": "$_("It will format your disk and you will loose any data in there, are you sure to continue? ")", + "KCHPOOL6004M": "$_("SCSI Fibre Channel")", + "KCHPOOL6005M": "$_("No SCSI adapters found.")", + + "KCHPOOL6001E": "$_("The storage pool name can not be blank.")", + "KCHPOOL6002E": "$_("The storage pool path can not be blank.")", + "KCHPOOL6003E": "$_("NFS server mount path can not be blank.")", + "KCHPOOL6004E": "$_("Invalid storage pool name. It should not contain '/'.")", + "KCHPOOL6005E": "$_("Invalid NFS mount path.")", + "KCHPOOL6006E": "$_("No logical device selected.")", + "KCHPOOL6007E": "$_("The iSCSI target can not be blank.")", + "KCHPOOL6008E": "$_("Server name can not be blank.")", + "KCHPOOL6009E": "$_("This is not a valid Server Name or IP. please, modify it.")", + "KCHPOOL6010M": "$_("Looking for available partitions ...")", + "KCHPOOL6011M": "$_("No available partitions found.")", + "KCHPOOL6012M": "$_("This storage pool is not persistent. Instead of deactivate, this action will permanently delete it. Would you like to continue?")" +} \ No newline at end of file -- 1.9.3

On 06/13/2014 07:28 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Remove html tags from i18n as they are not valid Correct object definition from acceptable JS to valid JSON replacing ' with " in attribute names.
Signed-off-by: Adam King <rak@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Conflicts: ui/pages/i18n.html.tmpl --- ui/pages/i18n.html.tmpl | 179 ------------------------------------------------ ui/pages/i18n.json.tmpl | 166 ++++++++++++++++++++++++++++++++++++++++++++
In the current ui/pages/Makefile.am we have: dist_html_DATA = $(wildcard *.html.tmpl) $(NULL) You need to include *.json.tmpl or replace *.html.tmpl to *.tmpl Otherwise, the i18n.json.tmpl will not be added to the rpm
2 files changed, 166 insertions(+), 179 deletions(-) delete mode 100644 ui/pages/i18n.html.tmpl create mode 100644 ui/pages/i18n.json.tmpl
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl deleted file mode 100644 index 375a37a..0000000 --- a/ui/pages/i18n.html.tmpl +++ /dev/null @@ -1,179 +0,0 @@ -#* - * Project Kimchi - * - * Copyright IBM, Corp. 2013 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *# -#unicode UTF-8 -#import gettext -#from kimchi.cachebust import href -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) -#silent _ = t.gettext -#silent _t = t.gettext - -<!DOCTYPE html> -<html class="no-js" lang=$lang.lang[0]> -<head> - <meta charset="utf-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> - <title>language</title> -</head> -<body> -<script> -var i18n = { - 'KCHAUTH6001E': "$_("The username or password you entered is incorrect. Please try again.")", - 'KCHAUTH6002E': "$_("This field is required.")", - - 'KCHAUTH6001M': "$_("Log in")", - 'KCHAUTH6002M': "$_("Logging in...")", - - 'Host': "$_("Host")", - 'Guests': "$_("Guests")", - 'Templates': "$_("Templates")", - 'Storage': "$_("Storage")", - 'Network': "$_("Network")", - - 'KCHAPI6001E': "$_("Invalid URL. Redireced to home page.")", - 'KCHAPI6002E': "$_("Failed to get application configuration")", - 'KCHAPI6003E': "$_("This is not a valid Linux path")", - 'KCHAPI6004E': "$_("This is not a valid URL.")", - 'KCHAPI6005E': "$_("No such data available.")", - 'KCHAPI6006E': "$_("options needed.")", - 'KCHAPI6007E': "$_("Can not contact the host system. Verify the host system is up and that you have network connectivity to it. HTTP request response %1. ")", - - 'KCHAPI6001M': "$_("Delete Confirmation")", - 'KCHAPI6002M': "$_("OK")", - 'KCHAPI6003M': "$_("Cancel")", - 'KCHAPI6004M': "$_("Confirm")", - 'KCHAPI6005M': "$_("Create")", - 'KCHAPI6006M': "$_("Warning")", - 'KCHAPI6007M': "$_("Save")", - - 'KCHGRD6001M': "$_("Loading...")", - 'KCHGRD6002M': "$_("An error occurs while checking for packages update.")", - 'KCHGRD6003M': "$_("Retry")", - 'KCHGRD6004M': "$_("Detailed message:")", - - 'KCHTMPL6001W': "$_("No iso found")", - - 'KCHTMPL6002E': "$_("This is not a valid ISO file.")", - - 'KCHTMPL6002M': "$_("It will take long time. Do you want to continue?")", - 'KCHTMPL6003M': "$_("This will permanently delete the template. Would you like to continue?")", - - 'KCHHOST6001E': "$_("Unable to shut down system as there are some virtual machines running!")", - - 'KCHHOST6001M': "$_("Max:")", - 'KCHHOST6002M': "$_("Utilization")", - 'KCHHOST6003M': "$_("Available")", - 'KCHHOST6004M': "$_("Read Rate")", - 'KCHHOST6005M': "$_("Write Rate")", - 'KCHHOST6006M': "$_("Received")", - 'KCHHOST6007M': "$_("Sent")", - 'KCHHOST6008M': "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")", - - - 'KCHREPO6001M': "$_("Confirm")", - 'KCHREPO6002M': "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", - 'KCHREPO6003M': "$_("Repositories")", - 'KCHREPO6004M': "$_("ID")", - 'KCHREPO6005M': "$_("Name")", - 'KCHREPO6006M': "$_("Base URL")", - 'KCHREPO6007M': "$_("Is Mirror")", - 'KCHREPO6008M': "$_("URL Args")", - 'KCHREPO6009M': "$_("Enabled")", - 'KCHREPO6010M': "$_("GPG Check")", - 'KCHREPO6011M': "$_("GPG Key")", - 'KCHREPO6012M': "$_("Add")", - 'KCHREPO6013M': "$_("Edit")", - 'KCHREPO6014M': "$_("Remove")", - 'KCHREPO6015M': "$_("Failed.")", - 'KCHREPO6016M': "$_("Enable")", - 'KCHREPO6017M': "$_("Disable")", - - - 'KCHUPD6001M': "$_("Software Updates")", - 'KCHUPD6002M': "$_("Package Name")", - 'KCHUPD6003M': "$_("Version")", - 'KCHUPD6004M': "$_("Architecture")", - 'KCHUPD6005M': "$_("Repository")", - 'KCHUPD6006M': "$_("Update All")", - 'KCHUPD6007M': "$_("Updating...")", - 'KCHUPD6008M': "$_("Failed to retrieve updates.")", - 'KCHUPD6009M': "$_("Failed to update package(s).")", - - - 'KCHDR6001M': "$_("Debug report will be removed permanently and can't be recovered. Do you want to continue?")", - 'KCHDR6002M': "$_("Debug Reports")", - 'KCHDR6003M': "$_("Name")", - 'KCHDR6005M': "$_("Generated Time")", - 'KCHDR6006M': "$_("Generate")", - 'KCHDR6007M': "$_("Generating...")", - 'KCHDR6008M': "$_("Rename")", - 'KCHDR6009M': "$_("Remove")", - 'KCHDR6010M': "$_("Download")", - 'KCHDR6011M': "$_("Report name should contain only letters, digits and/or hyphen ('-').")", - 'KCHDR6012M': "$_("Pending...")", - - 'KCHVM6001M': "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")", - 'KCHVM6002M': "$_("Power off Confirmation")", - 'KCHVM6003M': "$_("This action may produce undesirable results, " - "for example unflushed disk cache in the guest. " - "Would you like to continue?")", - 'KCHVM6004M': "$_("Reset Confirmation")", - 'KCHVM6005M': "$_("There is a risk of data loss caused by reset without" - " the guest OS shutdown. Would you like to continue?")", - 'KCHVM6006M': "$_("Shut Down Confirmation")", - 'KCHVM6007M': "$_("Note the guest OS may ignore this request. Would you like to continue?")", - 'KCHVM6008M': "$_("VM Delete Confirmation")", - - 'KCHVMCD6001M': "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", - 'KCHVMCD6002M': "$_("Attach")", - 'KCHVMCD6003M': "$_("Attaching...")", - 'KCHVMCD6004M': "$_("Replace")", - 'KCHVMCD6005M': "$_("Replacing...")", - 'KCHVMCD6006M': "$_("Successfully attached!")", - 'KCHVMCD6007M': "$_("Successfully replaced!")", - 'KCHVMCD6008M': "$_("Successfully detached!")", - - - 'KCHNET6001E': "$_("The VLAN id must be between 1 and 4094.")", - - 'KCHNET6001M': "$_("unavailable")", - 'KCHNET6002M': "$_("This action will interrupt network connectivity for any virtual machine that depend on this network.")", - 'KCHNET6003M': "$_("Create a network")", - 'KCHNET6004M': "$_("This network is not persistent. Instead of stop, this action will permanently delete it. Would you like to continue?")", - - 'KCHPOOL6001M': "$_("This will permanently delete the storage pool. Would you like to continue?")", - 'KCHPOOL6002M': "$_("This storage pool is empty.")", - 'KCHPOOL6003M': "$_("It will format your disk and you will loose any data in there, are you sure to continue? ")", - 'KCHPOOL6004M': "$_("SCSI Fibre Channel")", - 'KCHPOOL6005M': "$_("No SCSI adapters found.")", - - 'KCHPOOL6001E': "$_("The storage pool name can not be blank.")", - 'KCHPOOL6002E': "$_("The storage pool path can not be blank.")", - 'KCHPOOL6003E': "$_("NFS server mount path can not be blank.")", - 'KCHPOOL6004E': "$_("Invalid storage pool name. It should not contain '/'.")", - 'KCHPOOL6005E': "$_("Invalid NFS mount path.")", - 'KCHPOOL6006E': "$_("No logical device selected.")", - 'KCHPOOL6007E': "$_("The iSCSI target can not be blank.")", - 'KCHPOOL6008E': "$_("Server name can not be blank.")", - 'KCHPOOL6009E': "$_("This is not a valid Server Name or IP. please, modify it.")", - 'KCHPOOL6010M': "$_("Looking for available partitions ...")", - 'KCHPOOL6011M': "$_("No available partitions found.")", - 'KCHPOOL6012M': "$_("This storage pool is not persistent. Instead of deactivate, this action will permanently delete it. Would you like to continue?")" -}; -</script> -</body> -</html> diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl new file mode 100644 index 0000000..ce23bc4 --- /dev/null +++ b/ui/pages/i18n.json.tmpl @@ -0,0 +1,166 @@ +#* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *# +#unicode UTF-8 +#import gettext +#from kimchi.cachebust import href +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) +#silent _ = t.gettext +#silent _t = t.gettext +{ + "KCHAUTH6001E": "$_("The username or password you entered is incorrect. Please try again.")", + "KCHAUTH6002E": "$_("This field is required.")", + + "KCHAUTH6001M": "$_("Log in")", + "KCHAUTH6002M": "$_("Logging in...")", + + "Host": "$_("Host")", + "Guests": "$_("Guests")", + "Templates": "$_("Templates")", + "Storage": "$_("Storage")", + "Network": "$_("Network")", + + "KCHAPI6001E": "$_("Invalid URL. Redireced to home page.")", + "KCHAPI6002E": "$_("Failed to get application configuration")", + "KCHAPI6003E": "$_("This is not a valid Linux path")", + "KCHAPI6004E": "$_("This is not a valid URL.")", + "KCHAPI6005E": "$_("No such data available.")", + "KCHAPI6006E": "$_("options needed.")", + "KCHAPI6007E": "$_("Can not contact the host system. Verify the host system is up and that you have network connectivity to it. HTTP request response %1. ")", + + "KCHAPI6001M": "$_("Delete Confirmation")", + "KCHAPI6002M": "$_("OK")", + "KCHAPI6003M": "$_("Cancel")", + "KCHAPI6004M": "$_("Confirm")", + "KCHAPI6005M": "$_("Create")", + "KCHAPI6006M": "$_("Warning")", + "KCHAPI6007M": "$_("Save")", + + "KCHGRD6001M": "$_("Loading...")", + "KCHGRD6002M": "$_("An error occurs while checking for packages update.")", + "KCHGRD6003M": "$_("Retry")", + "KCHGRD6004M": "$_("Detailed message:")", + + "KCHTMPL6001W": "$_("No iso found")", + + "KCHTMPL6002E": "$_("This is not a valid ISO file.")", + + "KCHTMPL6002M": "$_("It will take long time. Do you want to continue?")", + "KCHTMPL6003M": "$_("This will permanently delete the template. Would you like to continue?")", + + "KCHHOST6001E": "$_("Unable to shut down system as there are some virtual machines running!")", + + "KCHHOST6001M": "$_("Max:")", + "KCHHOST6002M": "$_("Utilization")", + "KCHHOST6003M": "$_("Available")", + "KCHHOST6004M": "$_("Read Rate")", + "KCHHOST6005M": "$_("Write Rate")", + "KCHHOST6006M": "$_("Received")", + "KCHHOST6007M": "$_("Sent")", + "KCHHOST6008M": "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")", + + + "KCHREPO6001M": "$_("Confirm")", + "KCHREPO6002M": "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", + "KCHREPO6003M": "$_("Repositories")", + "KCHREPO6004M": "$_("ID")", + "KCHREPO6005M": "$_("Name")", + "KCHREPO6006M": "$_("Base URL")", + "KCHREPO6007M": "$_("Is Mirror")", + "KCHREPO6008M": "$_("URL Args")", + "KCHREPO6009M": "$_("Enabled")", + "KCHREPO6010M": "$_("GPG Check")", + "KCHREPO6011M": "$_("GPG Key")", + "KCHREPO6012M": "$_("Add")", + "KCHREPO6013M": "$_("Edit")", + "KCHREPO6014M": "$_("Remove")", + "KCHREPO6015M": "$_("Failed.")", + "KCHREPO6016M": "$_("Enable")", + "KCHREPO6017M": "$_("Disable")", + + + "KCHUPD6001M": "$_("Software Updates")", + "KCHUPD6002M": "$_("Package Name")", + "KCHUPD6003M": "$_("Version")", + "KCHUPD6004M": "$_("Architecture")", + "KCHUPD6005M": "$_("Repository")", + "KCHUPD6006M": "$_("Update All")", + "KCHUPD6007M": "$_("Updating...")", + "KCHUPD6008M": "$_("Failed to retrieve updates.")", + "KCHUPD6009M": "$_("Failed to update package(s).")", + + + "KCHDR6001M": "$_("Debug report will be removed permanently and can't be recovered. Do you want to continue?")", + "KCHDR6002M": "$_("Debug Reports")", + "KCHDR6003M": "$_("Name")", + "KCHDR6005M": "$_("Generated Time")", + "KCHDR6006M": "$_("Generate")", + "KCHDR6007M": "$_("Generating...")", + "KCHDR6008M": "$_("Rename")", + "KCHDR6009M": "$_("Remove")", + "KCHDR6010M": "$_("Download")", + "KCHDR6011M": "$_("Report name should contain only letters, digits and/or hyphen ('-').")", + "KCHDR6012M": "$_("Pending...")", + + "KCHVM6001M": "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")", + "KCHVM6002M": "$_("Power off Confirmation")", + "KCHVM6003M": "$_("This action may produce undesirable results, " + "for example unflushed disk cache in the guest. " + "Would you like to continue?")", + "KCHVM6004M": "$_("Reset Confirmation")", + "KCHVM6005M": "$_("There is a risk of data loss caused by reset without" + " the guest OS shutdown. Would you like to continue?")", + "KCHVM6006M": "$_("Shut Down Confirmation")", + "KCHVM6007M": "$_("Note the guest OS may ignore this request. Would you like to continue?")", + "KCHVM6008M": "$_("VM Delete Confirmation")", + + "KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", + "KCHVMCD6002M": "$_("Attach")", + "KCHVMCD6003M": "$_("Attaching...")", + "KCHVMCD6004M": "$_("Replace")", + "KCHVMCD6005M": "$_("Replacing...")", + "KCHVMCD6006M": "$_("Successfully attached!")", + "KCHVMCD6007M": "$_("Successfully replaced!")", + "KCHVMCD6008M": "$_("Successfully detached!")", + + + "KCHNET6001E": "$_("The VLAN id must be between 1 and 4094.")", + + "KCHNET6001M": "$_("unavailable")", + "KCHNET6002M": "$_("This action will interrupt network connectivity for any virtual machine that depend on this network.")", + "KCHNET6003M": "$_("Create a network")", + "KCHNET6004M": "$_("This network is not persistent. Instead of stop, this action will permanently delete it. Would you like to continue?")", + + "KCHPOOL6001M": "$_("This will permanently delete the storage pool. Would you like to continue?")", + "KCHPOOL6002M": "$_("This storage pool is empty.")", + "KCHPOOL6003M": "$_("It will format your disk and you will loose any data in there, are you sure to continue? ")", + "KCHPOOL6004M": "$_("SCSI Fibre Channel")", + "KCHPOOL6005M": "$_("No SCSI adapters found.")", + + "KCHPOOL6001E": "$_("The storage pool name can not be blank.")", + "KCHPOOL6002E": "$_("The storage pool path can not be blank.")", + "KCHPOOL6003E": "$_("NFS server mount path can not be blank.")", + "KCHPOOL6004E": "$_("Invalid storage pool name. It should not contain '/'.")", + "KCHPOOL6005E": "$_("Invalid NFS mount path.")", + "KCHPOOL6006E": "$_("No logical device selected.")", + "KCHPOOL6007E": "$_("The iSCSI target can not be blank.")", + "KCHPOOL6008E": "$_("Server name can not be blank.")", + "KCHPOOL6009E": "$_("This is not a valid Server Name or IP. please, modify it.")", + "KCHPOOL6010M": "$_("Looking for available partitions ...")", + "KCHPOOL6011M": "$_("No available partitions found.")", + "KCHPOOL6012M": "$_("This storage pool is not persistent. Instead of deactivate, this action will permanently delete it. Would you like to continue?")" +} \ No newline at end of file

On 06/13/2014 09:07 AM, Aline Manera wrote:
On 06/13/2014 07:28 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Remove html tags from i18n as they are not valid Correct object definition from acceptable JS to valid JSON replacing ' with " in attribute names.
Signed-off-by: Adam King <rak@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Conflicts: ui/pages/i18n.html.tmpl --- ui/pages/i18n.html.tmpl | 179 ------------------------------------------------ ui/pages/i18n.json.tmpl | 166 ++++++++++++++++++++++++++++++++++++++++++++
In the current ui/pages/Makefile.am we have:
dist_html_DATA = $(wildcard *.html.tmpl) $(NULL)
You need to include *.json.tmpl or replace *.html.tmpl to *.tmpl Otherwise, the i18n.json.tmpl will not be added to the rpm
Fixing it, the patch is ready to be merged IMO
2 files changed, 166 insertions(+), 179 deletions(-) delete mode 100644 ui/pages/i18n.html.tmpl create mode 100644 ui/pages/i18n.json.tmpl
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl deleted file mode 100644 index 375a37a..0000000 --- a/ui/pages/i18n.html.tmpl +++ /dev/null @@ -1,179 +0,0 @@ -#* - * Project Kimchi - * - * Copyright IBM, Corp. 2013 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *# -#unicode UTF-8 -#import gettext -#from kimchi.cachebust import href -#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) -#silent _ = t.gettext -#silent _t = t.gettext - -<!DOCTYPE html> -<html class="no-js" lang=$lang.lang[0]> -<head> - <meta charset="utf-8"> - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> - <title>language</title> -</head> -<body> -<script> -var i18n = { - 'KCHAUTH6001E': "$_("The username or password you entered is incorrect. Please try again.")", - 'KCHAUTH6002E': "$_("This field is required.")", - - 'KCHAUTH6001M': "$_("Log in")", - 'KCHAUTH6002M': "$_("Logging in...")", - - 'Host': "$_("Host")", - 'Guests': "$_("Guests")", - 'Templates': "$_("Templates")", - 'Storage': "$_("Storage")", - 'Network': "$_("Network")", - - 'KCHAPI6001E': "$_("Invalid URL. Redireced to home page.")", - 'KCHAPI6002E': "$_("Failed to get application configuration")", - 'KCHAPI6003E': "$_("This is not a valid Linux path")", - 'KCHAPI6004E': "$_("This is not a valid URL.")", - 'KCHAPI6005E': "$_("No such data available.")", - 'KCHAPI6006E': "$_("options needed.")", - 'KCHAPI6007E': "$_("Can not contact the host system. Verify the host system is up and that you have network connectivity to it. HTTP request response %1. ")", - - 'KCHAPI6001M': "$_("Delete Confirmation")", - 'KCHAPI6002M': "$_("OK")", - 'KCHAPI6003M': "$_("Cancel")", - 'KCHAPI6004M': "$_("Confirm")", - 'KCHAPI6005M': "$_("Create")", - 'KCHAPI6006M': "$_("Warning")", - 'KCHAPI6007M': "$_("Save")", - - 'KCHGRD6001M': "$_("Loading...")", - 'KCHGRD6002M': "$_("An error occurs while checking for packages update.")", - 'KCHGRD6003M': "$_("Retry")", - 'KCHGRD6004M': "$_("Detailed message:")", - - 'KCHTMPL6001W': "$_("No iso found")", - - 'KCHTMPL6002E': "$_("This is not a valid ISO file.")", - - 'KCHTMPL6002M': "$_("It will take long time. Do you want to continue?")", - 'KCHTMPL6003M': "$_("This will permanently delete the template. Would you like to continue?")", - - 'KCHHOST6001E': "$_("Unable to shut down system as there are some virtual machines running!")", - - 'KCHHOST6001M': "$_("Max:")", - 'KCHHOST6002M': "$_("Utilization")", - 'KCHHOST6003M': "$_("Available")", - 'KCHHOST6004M': "$_("Read Rate")", - 'KCHHOST6005M': "$_("Write Rate")", - 'KCHHOST6006M': "$_("Received")", - 'KCHHOST6007M': "$_("Sent")", - 'KCHHOST6008M': "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")", - - - 'KCHREPO6001M': "$_("Confirm")", - 'KCHREPO6002M': "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", - 'KCHREPO6003M': "$_("Repositories")", - 'KCHREPO6004M': "$_("ID")", - 'KCHREPO6005M': "$_("Name")", - 'KCHREPO6006M': "$_("Base URL")", - 'KCHREPO6007M': "$_("Is Mirror")", - 'KCHREPO6008M': "$_("URL Args")", - 'KCHREPO6009M': "$_("Enabled")", - 'KCHREPO6010M': "$_("GPG Check")", - 'KCHREPO6011M': "$_("GPG Key")", - 'KCHREPO6012M': "$_("Add")", - 'KCHREPO6013M': "$_("Edit")", - 'KCHREPO6014M': "$_("Remove")", - 'KCHREPO6015M': "$_("Failed.")", - 'KCHREPO6016M': "$_("Enable")", - 'KCHREPO6017M': "$_("Disable")", - - - 'KCHUPD6001M': "$_("Software Updates")", - 'KCHUPD6002M': "$_("Package Name")", - 'KCHUPD6003M': "$_("Version")", - 'KCHUPD6004M': "$_("Architecture")", - 'KCHUPD6005M': "$_("Repository")", - 'KCHUPD6006M': "$_("Update All")", - 'KCHUPD6007M': "$_("Updating...")", - 'KCHUPD6008M': "$_("Failed to retrieve updates.")", - 'KCHUPD6009M': "$_("Failed to update package(s).")", - - - 'KCHDR6001M': "$_("Debug report will be removed permanently and can't be recovered. Do you want to continue?")", - 'KCHDR6002M': "$_("Debug Reports")", - 'KCHDR6003M': "$_("Name")", - 'KCHDR6005M': "$_("Generated Time")", - 'KCHDR6006M': "$_("Generate")", - 'KCHDR6007M': "$_("Generating...")", - 'KCHDR6008M': "$_("Rename")", - 'KCHDR6009M': "$_("Remove")", - 'KCHDR6010M': "$_("Download")", - 'KCHDR6011M': "$_("Report name should contain only letters, digits and/or hyphen ('-').")", - 'KCHDR6012M': "$_("Pending...")", - - 'KCHVM6001M': "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")", - 'KCHVM6002M': "$_("Power off Confirmation")", - 'KCHVM6003M': "$_("This action may produce undesirable results, " - "for example unflushed disk cache in the guest. " - "Would you like to continue?")", - 'KCHVM6004M': "$_("Reset Confirmation")", - 'KCHVM6005M': "$_("There is a risk of data loss caused by reset without" - " the guest OS shutdown. Would you like to continue?")", - 'KCHVM6006M': "$_("Shut Down Confirmation")", - 'KCHVM6007M': "$_("Note the guest OS may ignore this request. Would you like to continue?")", - 'KCHVM6008M': "$_("VM Delete Confirmation")", - - 'KCHVMCD6001M': "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", - 'KCHVMCD6002M': "$_("Attach")", - 'KCHVMCD6003M': "$_("Attaching...")", - 'KCHVMCD6004M': "$_("Replace")", - 'KCHVMCD6005M': "$_("Replacing...")", - 'KCHVMCD6006M': "$_("Successfully attached!")", - 'KCHVMCD6007M': "$_("Successfully replaced!")", - 'KCHVMCD6008M': "$_("Successfully detached!")", - - - 'KCHNET6001E': "$_("The VLAN id must be between 1 and 4094.")", - - 'KCHNET6001M': "$_("unavailable")", - 'KCHNET6002M': "$_("This action will interrupt network connectivity for any virtual machine that depend on this network.")", - 'KCHNET6003M': "$_("Create a network")", - 'KCHNET6004M': "$_("This network is not persistent. Instead of stop, this action will permanently delete it. Would you like to continue?")", - - 'KCHPOOL6001M': "$_("This will permanently delete the storage pool. Would you like to continue?")", - 'KCHPOOL6002M': "$_("This storage pool is empty.")", - 'KCHPOOL6003M': "$_("It will format your disk and you will loose any data in there, are you sure to continue? ")", - 'KCHPOOL6004M': "$_("SCSI Fibre Channel")", - 'KCHPOOL6005M': "$_("No SCSI adapters found.")", - - 'KCHPOOL6001E': "$_("The storage pool name can not be blank.")", - 'KCHPOOL6002E': "$_("The storage pool path can not be blank.")", - 'KCHPOOL6003E': "$_("NFS server mount path can not be blank.")", - 'KCHPOOL6004E': "$_("Invalid storage pool name. It should not contain '/'.")", - 'KCHPOOL6005E': "$_("Invalid NFS mount path.")", - 'KCHPOOL6006E': "$_("No logical device selected.")", - 'KCHPOOL6007E': "$_("The iSCSI target can not be blank.")", - 'KCHPOOL6008E': "$_("Server name can not be blank.")", - 'KCHPOOL6009E': "$_("This is not a valid Server Name or IP. please, modify it.")", - 'KCHPOOL6010M': "$_("Looking for available partitions ...")", - 'KCHPOOL6011M': "$_("No available partitions found.")", - 'KCHPOOL6012M': "$_("This storage pool is not persistent. Instead of deactivate, this action will permanently delete it. Would you like to continue?")" -}; -</script> -</body> -</html> diff --git a/ui/pages/i18n.json.tmpl b/ui/pages/i18n.json.tmpl new file mode 100644 index 0000000..ce23bc4 --- /dev/null +++ b/ui/pages/i18n.json.tmpl @@ -0,0 +1,166 @@ +#* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *# +#unicode UTF-8 +#import gettext +#from kimchi.cachebust import href +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) +#silent _ = t.gettext +#silent _t = t.gettext +{ + "KCHAUTH6001E": "$_("The username or password you entered is incorrect. Please try again.")", + "KCHAUTH6002E": "$_("This field is required.")", + + "KCHAUTH6001M": "$_("Log in")", + "KCHAUTH6002M": "$_("Logging in...")", + + "Host": "$_("Host")", + "Guests": "$_("Guests")", + "Templates": "$_("Templates")", + "Storage": "$_("Storage")", + "Network": "$_("Network")", + + "KCHAPI6001E": "$_("Invalid URL. Redireced to home page.")", + "KCHAPI6002E": "$_("Failed to get application configuration")", + "KCHAPI6003E": "$_("This is not a valid Linux path")", + "KCHAPI6004E": "$_("This is not a valid URL.")", + "KCHAPI6005E": "$_("No such data available.")", + "KCHAPI6006E": "$_("options needed.")", + "KCHAPI6007E": "$_("Can not contact the host system. Verify the host system is up and that you have network connectivity to it. HTTP request response %1. ")", + + "KCHAPI6001M": "$_("Delete Confirmation")", + "KCHAPI6002M": "$_("OK")", + "KCHAPI6003M": "$_("Cancel")", + "KCHAPI6004M": "$_("Confirm")", + "KCHAPI6005M": "$_("Create")", + "KCHAPI6006M": "$_("Warning")", + "KCHAPI6007M": "$_("Save")", + + "KCHGRD6001M": "$_("Loading...")", + "KCHGRD6002M": "$_("An error occurs while checking for packages update.")", + "KCHGRD6003M": "$_("Retry")", + "KCHGRD6004M": "$_("Detailed message:")", + + "KCHTMPL6001W": "$_("No iso found")", + + "KCHTMPL6002E": "$_("This is not a valid ISO file.")", + + "KCHTMPL6002M": "$_("It will take long time. Do you want to continue?")", + "KCHTMPL6003M": "$_("This will permanently delete the template. Would you like to continue?")", + + "KCHHOST6001E": "$_("Unable to shut down system as there are some virtual machines running!")", + + "KCHHOST6001M": "$_("Max:")", + "KCHHOST6002M": "$_("Utilization")", + "KCHHOST6003M": "$_("Available")", + "KCHHOST6004M": "$_("Read Rate")", + "KCHHOST6005M": "$_("Write Rate")", + "KCHHOST6006M": "$_("Received")", + "KCHHOST6007M": "$_("Sent")", + "KCHHOST6008M": "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")", + + + "KCHREPO6001M": "$_("Confirm")", + "KCHREPO6002M": "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", + "KCHREPO6003M": "$_("Repositories")", + "KCHREPO6004M": "$_("ID")", + "KCHREPO6005M": "$_("Name")", + "KCHREPO6006M": "$_("Base URL")", + "KCHREPO6007M": "$_("Is Mirror")", + "KCHREPO6008M": "$_("URL Args")", + "KCHREPO6009M": "$_("Enabled")", + "KCHREPO6010M": "$_("GPG Check")", + "KCHREPO6011M": "$_("GPG Key")", + "KCHREPO6012M": "$_("Add")", + "KCHREPO6013M": "$_("Edit")", + "KCHREPO6014M": "$_("Remove")", + "KCHREPO6015M": "$_("Failed.")", + "KCHREPO6016M": "$_("Enable")", + "KCHREPO6017M": "$_("Disable")", + + + "KCHUPD6001M": "$_("Software Updates")", + "KCHUPD6002M": "$_("Package Name")", + "KCHUPD6003M": "$_("Version")", + "KCHUPD6004M": "$_("Architecture")", + "KCHUPD6005M": "$_("Repository")", + "KCHUPD6006M": "$_("Update All")", + "KCHUPD6007M": "$_("Updating...")", + "KCHUPD6008M": "$_("Failed to retrieve updates.")", + "KCHUPD6009M": "$_("Failed to update package(s).")", + + + "KCHDR6001M": "$_("Debug report will be removed permanently and can't be recovered. Do you want to continue?")", + "KCHDR6002M": "$_("Debug Reports")", + "KCHDR6003M": "$_("Name")", + "KCHDR6005M": "$_("Generated Time")", + "KCHDR6006M": "$_("Generate")", + "KCHDR6007M": "$_("Generating...")", + "KCHDR6008M": "$_("Rename")", + "KCHDR6009M": "$_("Remove")", + "KCHDR6010M": "$_("Download")", + "KCHDR6011M": "$_("Report name should contain only letters, digits and/or hyphen ('-').")", + "KCHDR6012M": "$_("Pending...")", + + "KCHVM6001M": "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")", + "KCHVM6002M": "$_("Power off Confirmation")", + "KCHVM6003M": "$_("This action may produce undesirable results, " + "for example unflushed disk cache in the guest. " + "Would you like to continue?")", + "KCHVM6004M": "$_("Reset Confirmation")", + "KCHVM6005M": "$_("There is a risk of data loss caused by reset without" + " the guest OS shutdown. Would you like to continue?")", + "KCHVM6006M": "$_("Shut Down Confirmation")", + "KCHVM6007M": "$_("Note the guest OS may ignore this request. Would you like to continue?")", + "KCHVM6008M": "$_("VM Delete Confirmation")", + + "KCHVMCD6001M": "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")", + "KCHVMCD6002M": "$_("Attach")", + "KCHVMCD6003M": "$_("Attaching...")", + "KCHVMCD6004M": "$_("Replace")", + "KCHVMCD6005M": "$_("Replacing...")", + "KCHVMCD6006M": "$_("Successfully attached!")", + "KCHVMCD6007M": "$_("Successfully replaced!")", + "KCHVMCD6008M": "$_("Successfully detached!")", + + + "KCHNET6001E": "$_("The VLAN id must be between 1 and 4094.")", + + "KCHNET6001M": "$_("unavailable")", + "KCHNET6002M": "$_("This action will interrupt network connectivity for any virtual machine that depend on this network.")", + "KCHNET6003M": "$_("Create a network")", + "KCHNET6004M": "$_("This network is not persistent. Instead of stop, this action will permanently delete it. Would you like to continue?")", + + "KCHPOOL6001M": "$_("This will permanently delete the storage pool. Would you like to continue?")", + "KCHPOOL6002M": "$_("This storage pool is empty.")", + "KCHPOOL6003M": "$_("It will format your disk and you will loose any data in there, are you sure to continue? ")", + "KCHPOOL6004M": "$_("SCSI Fibre Channel")", + "KCHPOOL6005M": "$_("No SCSI adapters found.")", + + "KCHPOOL6001E": "$_("The storage pool name can not be blank.")", + "KCHPOOL6002E": "$_("The storage pool path can not be blank.")", + "KCHPOOL6003E": "$_("NFS server mount path can not be blank.")", + "KCHPOOL6004E": "$_("Invalid storage pool name. It should not contain '/'.")", + "KCHPOOL6005E": "$_("Invalid NFS mount path.")", + "KCHPOOL6006E": "$_("No logical device selected.")", + "KCHPOOL6007E": "$_("The iSCSI target can not be blank.")", + "KCHPOOL6008E": "$_("Server name can not be blank.")", + "KCHPOOL6009E": "$_("This is not a valid Server Name or IP. please, modify it.")", + "KCHPOOL6010M": "$_("Looking for available partitions ...")", + "KCHPOOL6011M": "$_("No available partitions found.")", + "KCHPOOL6012M": "$_("This storage pool is not persistent. Instead of deactivate, this action will permanently delete it. Would you like to continue?")" +} \ No newline at end of file
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Create an API for fetching the i18n JSON. Use the API to load the kimchi UI strings. API will need to be simplified after convincing CherryPy to respond to the reque st for JSON. Signed-off-by: Adam King <rak@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- ui/js/src/kimchi.api.js | 14 ++++++++++++++ ui/js/src/kimchi.main.js | 11 ++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index 072d127..ad89880 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -63,6 +63,20 @@ var kimchi = { }, /** + * Get the i18 strings. + */ + getI18n: function(suc, err, url, sync) { + kimchi.requestJSON({ + url : url ? url : kimchi.url + 'i18n.json', + type : 'GET', + resend: true, + dataType : 'json', + success : suc, + error: err + }); + }, + + /** * Get the host static information. */ getHost: function(suc, err) { diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js index 4dc57e5..3ac8d7c 100644 --- a/ui/js/src/kimchi.main.js +++ b/ui/js/src/kimchi.main.js @@ -251,9 +251,14 @@ kimchi.main = function() { }; // Load i18n translation strings first and then render the page. - $('#main').load('i18n.html', function() { - buildTabs(initUI); - }); + kimchi.getI18n( + function(i18nStrings){ //success + i18n = i18nStrings; + buildTabs(initUI); + }, + function(data){ //error + kimchi.message.error(data.responseJSON.reason); + }); }; kimchi.getHelp = function(e) { -- 1.9.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Apparently, in plugin code there is no way to insert new entries into Kimchi ./ui/pages/i18n.json.tmpl, so every plugin should provide its own i18n.json.tmpl. each plugin provides a "plugins/plugin-name/ui/pages/i18n.json.tmpl", and maps it to the URI "plugins/plugin-name/i18n.json". This is already supported by the kimchi back-end. What we have to do is just to load "plugins/plugin-name/i18n.json" in the front-end code. Signed-off-by: Adam King <rak@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- ui/js/src/kimchi.api.js | 4 +++- ui/js/src/kimchi.main.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index ad89880..0d96d07 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -71,6 +71,7 @@ var kimchi = { type : 'GET', resend: true, dataType : 'json', + async : !sync, success : suc, error: err }); @@ -560,13 +561,14 @@ var kimchi = { }); }, - listPlugins : function(suc, err) { + listPlugins : function(suc, err, sync) { kimchi.requestJSON({ url : kimchi.url + 'plugins', type : 'GET', contentType : 'application/json', dataType : 'json', resend: true, + async : !sync, success : suc, error : err }); diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js index 3ac8d7c..8eb4d73 100644 --- a/ui/js/src/kimchi.main.js +++ b/ui/js/src/kimchi.main.js @@ -39,7 +39,7 @@ kimchi.main = function() { $(xmlData).find('tab').each(function() { var $tab = $(this); var titleKey = $tab.find('title').text(); - var title = i18n[titleKey]; + var title = i18n[titleKey] ? i18n[titleKey] : titleKey; var path = $tab.find('path').text(); tabs.push({ title: title, @@ -64,6 +64,7 @@ kimchi.main = function() { var tabConfigUrl = '/config/ui/tabs.xml'; var pluginConfigUrl = '/plugins/{plugin}/ui/config/tab-ext.xml'; + var pluginI18nUrl = 'plugins/{plugin}/i18n.json'; var DEFAULT_HASH; var buildTabs = function(callback) { var tabs = retrieveTabs(tabConfigUrl); @@ -72,6 +73,12 @@ kimchi.main = function() { var url = kimchi.substitute(pluginConfigUrl, { plugin: p }); + var i18nUrl = kimchi.substitute(pluginI18nUrl, { + plugin: p + }); + kimchi.getI18n(function(i18nObj){ $.extend(i18n, i18nObj)}, + function(i18nObj){ //i18n is not define by plugin + }, i18nUrl, true); tabs.push.apply(tabs, retrieveTabs(url)); }); @@ -85,7 +92,9 @@ kimchi.main = function() { $('#nav-menu').append(genTabs(tabs)); callback && callback(); - }); + }, function(data) { + kimchi.message.error(data.responseJSON.reason); + }, true); }; var onLanguageChanged = function(lang) { -- 1.9.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> sample plugin is used to test as a plugin demo. we disable it by default. use this command to enable sample plugin $ ./autogen.sh --enable-sample Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- configure.ac | 16 ++++++++++++++++ plugins/sample/Makefile.am | 2 +- plugins/sample/{sample.conf => sample.conf.in} | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) rename plugins/sample/{sample.conf => sample.conf.in} (95%) diff --git a/configure.ac b/configure.ac index db87060..c7da29b 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,21 @@ if test "x$PYFLAKES" = "x"; then AC_MSG_WARN([pyflakes not found]) fi +AC_ARG_ENABLE( + [sample], + [AS_HELP_STRING( + [--enable-sample], + [enable sample plugin @<:@default=no@:>@] + )], + , + [enable_sample="no"] +) + +if test "${enable_sample}" = "yes"; then +AC_SUBST([ENABLE_SAMPLE], [True]) +else +AC_SUBST([ENABLE_SAMPLE], [False]) +fi AC_CONFIG_FILES([ po/Makefile.in @@ -62,6 +77,7 @@ AC_CONFIG_FILES([ src/kimchi/model/Makefile plugins/Makefile plugins/sample/Makefile + plugins/sample/sample.conf plugins/sample/ui/Makefile plugins/sample/ui/config/Makefile plugins/sample/ui/js/Makefile diff --git a/plugins/sample/Makefile.am b/plugins/sample/Makefile.am index e03a4c0..a229244 100644 --- a/plugins/sample/Makefile.am +++ b/plugins/sample/Makefile.am @@ -19,4 +19,4 @@ SUBDIRS = ui -EXTRA_DIST = API.json sample.conf $(wildcard *.py) +EXTRA_DIST = API.json sample.conf.in $(wildcard *.py) diff --git a/plugins/sample/sample.conf b/plugins/sample/sample.conf.in similarity index 95% rename from plugins/sample/sample.conf rename to plugins/sample/sample.conf.in index d4994e5..6e0908b 100644 --- a/plugins/sample/sample.conf +++ b/plugins/sample/sample.conf.in @@ -1,5 +1,5 @@ [kimchi] -enable = True +enable = @ENABLE_SAMPLE@ plugin_class = "Drawings" uri = "/plugins/sample" -- 1.9.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> please use this command to generate the translation files for plugins/sample $ make -C plugins/sample/po/ update-po Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- configure.ac | 1 + plugins/sample/Makefile.am | 9 ++++++++- plugins/sample/config.status | 1 + plugins/sample/po/LINGUAS | 1 + plugins/sample/po/Makefile.in.in | 1 + plugins/sample/po/Makevars | 41 ++++++++++++++++++++++++++++++++++++++++ plugins/sample/po/POTFILES.in | 2 ++ plugins/sample/po/en_US.po | 21 ++++++++++++++++++++ plugins/sample/po/gen-pot | 9 +++++++++ plugins/sample/po/pt_BR.po | 24 +++++++++++++++++++++++ plugins/sample/po/sample.pot | 21 ++++++++++++++++++++ plugins/sample/po/zh_CN.po | 24 +++++++++++++++++++++++ src/kimchi/template.py | 2 +- 13 files changed, 155 insertions(+), 2 deletions(-) create mode 120000 plugins/sample/config.status create mode 120000 plugins/sample/po/LINGUAS create mode 120000 plugins/sample/po/Makefile.in.in create mode 100644 plugins/sample/po/Makevars create mode 100644 plugins/sample/po/POTFILES.in create mode 100644 plugins/sample/po/en_US.po create mode 100755 plugins/sample/po/gen-pot create mode 100644 plugins/sample/po/pt_BR.po create mode 100644 plugins/sample/po/sample.pot create mode 100644 plugins/sample/po/zh_CN.po diff --git a/configure.ac b/configure.ac index c7da29b..e5e6441 100644 --- a/configure.ac +++ b/configure.ac @@ -77,6 +77,7 @@ AC_CONFIG_FILES([ src/kimchi/model/Makefile plugins/Makefile plugins/sample/Makefile + plugins/sample/po/Makefile.in plugins/sample/sample.conf plugins/sample/ui/Makefile plugins/sample/ui/config/Makefile diff --git a/plugins/sample/Makefile.am b/plugins/sample/Makefile.am index a229244..d753ac9 100644 --- a/plugins/sample/Makefile.am +++ b/plugins/sample/Makefile.am @@ -17,6 +17,13 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -SUBDIRS = ui +SUBDIRS = ui po EXTRA_DIST = API.json sample.conf.in $(wildcard *.py) + +all-local: + while read L && test -n "$$L"; do \ + dir=mo/$$L/LC_MESSAGES ; \ + $(MKDIR_P) $$dir ; \ + ln -sf ../../../po/$$L.gmo $$dir/sample.mo ; \ + done < po/LINGUAS diff --git a/plugins/sample/config.status b/plugins/sample/config.status new file mode 120000 index 0000000..6cd6b4f --- /dev/null +++ b/plugins/sample/config.status @@ -0,0 +1 @@ +../../config.status \ No newline at end of file diff --git a/plugins/sample/po/LINGUAS b/plugins/sample/po/LINGUAS new file mode 120000 index 0000000..4fb83a5 --- /dev/null +++ b/plugins/sample/po/LINGUAS @@ -0,0 +1 @@ +../../../po/LINGUAS \ No newline at end of file diff --git a/plugins/sample/po/Makefile.in.in b/plugins/sample/po/Makefile.in.in new file mode 120000 index 0000000..44028c0 --- /dev/null +++ b/plugins/sample/po/Makefile.in.in @@ -0,0 +1 @@ +../../../po/Makefile.in.in \ No newline at end of file diff --git a/plugins/sample/po/Makevars b/plugins/sample/po/Makevars new file mode 100644 index 0000000..60de3f1 --- /dev/null +++ b/plugins/sample/po/Makevars @@ -0,0 +1,41 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = sample + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = kimchi-devel@ovirt.org + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = diff --git a/plugins/sample/po/POTFILES.in b/plugins/sample/po/POTFILES.in new file mode 100644 index 0000000..7dbfb6c --- /dev/null +++ b/plugins/sample/po/POTFILES.in @@ -0,0 +1,2 @@ +# List of source files which contain translatable strings. +plugins/sample/ui/pages/*.tmpl diff --git a/plugins/sample/po/en_US.po b/plugins/sample/po/en_US.po new file mode 100644 index 0000000..1889845 --- /dev/null +++ b/plugins/sample/po/en_US.po @@ -0,0 +1,21 @@ +# English translations for kimchi package. +# Copyright (C) 2014 THE kimchi'S COPYRIGHT HOLDER +# This file is distributed under the same license as the kimchi package. +# shhfeng <shaohef@linux.vnet.ibm.com>, 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: kimchi 1.2.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-17 02:13+0800\n" +"PO-Revision-Date: 2014-05-17 02:08+0800\n" +"Last-Translator: shhfeng <shaohef@linux.vnet.ibm.com>\n" +"Language-Team: English\n" +"Language: en_US\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" + +msgid "SampleTab" +msgstr "SampleTab" diff --git a/plugins/sample/po/gen-pot b/plugins/sample/po/gen-pot new file mode 100755 index 0000000..c1cfb8f --- /dev/null +++ b/plugins/sample/po/gen-pot @@ -0,0 +1,9 @@ +#!/bin/bash + +for src in $@; do + if [ ${src: -3} == ".py" ]; then + cat $src + else + cat $src | cheetah compile - + fi +done | xgettext --no-location -o sample.pot -L Python - diff --git a/plugins/sample/po/pt_BR.po b/plugins/sample/po/pt_BR.po new file mode 100644 index 0000000..0ff1d43 --- /dev/null +++ b/plugins/sample/po/pt_BR.po @@ -0,0 +1,24 @@ +# Portuguese translations for kimchi package +# Copyright (C) 2014 THE kimchi'S COPYRIGHT HOLDER +# This file is distributed under the same license as the kimchi package. +# shhfeng <shaohef@linux.vnet.ibm.com>, 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: kimchi 1.2.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-17 02:13+0800\n" +"PO-Revision-Date: 2014-05-17 02:09+0800\n" +"Last-Translator: Crístian Viana <vianac@linux.vnet.ibm.com>\n" +"Language-Team: Aline Manera <alinefm@br.ibm.com>\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" +"X-Poedit-Country: Brazil\n" +"X-Poedit-Language: Portuguese\n" +"X-Poedit-SourceCharset: utf-8\n" + +msgid "SampleTab" +msgstr "Tab de exemplo" diff --git a/plugins/sample/po/sample.pot b/plugins/sample/po/sample.pot new file mode 100644 index 0000000..32ef568 --- /dev/null +++ b/plugins/sample/po/sample.pot @@ -0,0 +1,21 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-12 15:25+0800\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "SampleTab" +msgstr "" diff --git a/plugins/sample/po/zh_CN.po b/plugins/sample/po/zh_CN.po new file mode 100644 index 0000000..bba53c3 --- /dev/null +++ b/plugins/sample/po/zh_CN.po @@ -0,0 +1,24 @@ +# Chinese translations for kimchi package +# Copyright (C) 2014 THE kimchi'S COPYRIGHT HOLDER +# This file is distributed under the same license as the kimchi package. +# shhfeng <shaohef@linux.vnet.ibm.com>, 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: kimchi 1.2.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-17 02:13+0800\n" +"PO-Revision-Date: 2014-05-17 02:10+0800\n" +"Last-Translator: shhfeng <shaohef@linux.vnet.ibm.com>\n" +"Language-Team: Chinese (simplified)\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" +"X-Poedit-Country: CHINA\n" +"X-Poedit-Language: Chinese\n" +"X-Poedit-SourceCharset: utf-8\n" + +msgid "SampleTab" +msgstr "示例标签" diff --git a/src/kimchi/template.py b/src/kimchi/template.py index 146e735..0bee8c4 100644 --- a/src/kimchi/template.py +++ b/src/kimchi/template.py @@ -88,7 +88,7 @@ def render_cheetah_file(resource, data): try: params = {'data': data} lang = validate_language(get_lang()) - gettext_conf = {'domain': 'kimchi', + gettext_conf = {'domain': cherrypy.request.app.root.domain, 'localedir': paths.mo_dir, 'lang': [lang]} params['lang'] = gettext_conf -- 1.9.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> The plugins tests base on the sample plugin. So we should skip the tests when disable sample plugin Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- tests/test_plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 7773a0e..4c7ff1e 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -27,6 +27,7 @@ import kimchi.mockmodel import kimchi.server +from kimchi.utils import get_enabled_plugins import utils @@ -53,6 +54,9 @@ def tearDownModule(): os.unlink('/tmp/obj-store-test') +@unittest.skipUnless( + 'sample' in [plugin for plugin, _config in get_enabled_plugins()], + 'sample plugin is not enabled, skip this test!') class PluginTests(unittest.TestCase): def setUp(self): -- 1.9.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> let git ignore these generated files. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a776cb0..a328ac0 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,8 @@ src/nginx_kimchi.conf src/kimchi/config.py tests/run_tests.sh tests/test_config.py +plugins/sample/po/POTFILES +plugins/sample/sample.conf po/POTFILES po/gen-pot *.orig -- 1.9.3

V8 -> V9 rebase. fix some commit message. On 06/13/2014 06:28 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
V7 -> V8: improve the commit message. improve the test case skip conditional expression, remove parenthesis
V5 -> V6: skip test, when disable plugin.
V4 -> V5: let autoconf generate sample.conf
V3 -> V4: rebase
V2 -> V3: change "enable-plugins" to "enable-sample" remove nls improve the Portuguese translation.
V1 -> V2: The improvement concept here is to directly generate JSON on the server and assign it to the i18n variable, rather than inserting nodes into the DOM. Plugins would use a plugin1.i18n= structure to keep plugin strings from colliding with each other, or with the kimchi variables.
ShaoHe Feng (8): Update root.py to make Cheetah render the JSON template. Update the i18n tmpl to produce JSON Add JS API for fetching i18n JSON Issue #342: load i18n.html of the plugin add an option to toggle the sample plugin generate the translation files for plugins/sample skip plugins test, when sample plugin is not enabled add some sample plugin generated files to .gitignore
Zhou Zheng Sheng (1): Add Minimal UI Page for the Sample Plugin
.gitignore | 2 + configure.ac | 19 ++++ plugins/sample/Makefile.am | 11 +- plugins/sample/__init__.py | 3 +- plugins/sample/config.status | 1 + plugins/sample/po/LINGUAS | 1 + plugins/sample/po/Makefile.in.in | 1 + plugins/sample/po/Makevars | 41 ++++++++ plugins/sample/po/POTFILES.in | 2 + plugins/sample/po/en_US.po | 21 ++++ plugins/sample/po/gen-pot | 9 ++ plugins/sample/po/pt_BR.po | 24 +++++ plugins/sample/po/sample.pot | 21 ++++ plugins/sample/po/zh_CN.po | 24 +++++ plugins/sample/sample.conf | 7 -- plugins/sample/sample.conf.in | 24 +++++ plugins/sample/ui/Makefile.am | 2 +- plugins/sample/ui/config/tab-ext.xml | 8 +- plugins/sample/ui/js/Makefile.am | 21 ++++ plugins/sample/ui/js/util.js | 33 ++++++ plugins/sample/ui/pages/Makefile.am | 21 ++++ plugins/sample/ui/pages/i18n.json.tmpl | 9 ++ plugins/sample/ui/pages/tab.html.tmpl | 30 ++++++ src/kimchi/root.py | 5 + src/kimchi/template.py | 34 ++++--- tests/test_plugin.py | 4 + ui/js/src/kimchi.api.js | 18 +++- ui/js/src/kimchi.main.js | 24 ++++- ui/pages/i18n.html.tmpl | 179 --------------------------------- ui/pages/i18n.json.tmpl | 166 ++++++++++++++++++++++++++++++ 30 files changed, 550 insertions(+), 215 deletions(-) create mode 120000 plugins/sample/config.status create mode 120000 plugins/sample/po/LINGUAS create mode 120000 plugins/sample/po/Makefile.in.in create mode 100644 plugins/sample/po/Makevars create mode 100644 plugins/sample/po/POTFILES.in create mode 100644 plugins/sample/po/en_US.po create mode 100755 plugins/sample/po/gen-pot create mode 100644 plugins/sample/po/pt_BR.po create mode 100644 plugins/sample/po/sample.pot create mode 100644 plugins/sample/po/zh_CN.po delete mode 100644 plugins/sample/sample.conf create mode 100644 plugins/sample/sample.conf.in create mode 100644 plugins/sample/ui/js/Makefile.am create mode 100644 plugins/sample/ui/js/util.js create mode 100644 plugins/sample/ui/pages/Makefile.am create mode 100644 plugins/sample/ui/pages/i18n.json.tmpl create mode 100644 plugins/sample/ui/pages/tab.html.tmpl delete mode 100644 ui/pages/i18n.html.tmpl create mode 100644 ui/pages/i18n.json.tmpl
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> replace *.html.tmpl to *.tmpl, then i18n.json.tmpl will be added to the package. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- ui/pages/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/Makefile.am b/ui/pages/Makefile.am index 7f11555..a22afc1 100644 --- a/ui/pages/Makefile.am +++ b/ui/pages/Makefile.am @@ -19,4 +19,4 @@ SUBDIRS = help tabs websockify htmldir = $(datadir)/kimchi/ui/pages -dist_html_DATA = $(wildcard *.html.tmpl) $(NULL) +dist_html_DATA = $(wildcard *.tmpl) $(NULL) -- 1.9.3

The tests are failing: [15/Jun/2014:08:58:21] ENGINE Bus STARTING [15/Jun/2014:08:58:21] ENGINE Started monitor thread 'Autoreloader'. [15/Jun/2014:08:58:21] ENGINE Started monitor thread '_TimeoutMonitor'. [15/Jun/2014:08:58:21] ENGINE Serving on 127.0.0.1:51118 [15/Jun/2014:08:58:21] ENGINE Bus STARTED [15/Jun/2014:08:58:21] ENGINE Started monitor thread 'Session cleanup'. [15/Jun/2014:08:58:23] Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 102, in run hook() File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 62, in __call__ return self.callback(**self.kwargs) File "/home/alinefm/kimchi/src/kimchi/auth.py", line 247, in kimchiauth if check_auth_httpba(): File "/home/alinefm/kimchi/src/kimchi/auth.py", line 194, in check_auth_httpba return login(username, password) File "/home/alinefm/kimchi/src/kimchi/auth.py", line 207, in login raise OperationFailed("KCHAUTH0001E", msg_args) OperationFailed: KCHAUTH0001E: KCHAUTH0001E [15/Jun/2014:08:58:23] HTTP Request Headers: AUTHORIZATION: Basic YWRtaW46bGV0bWVpbiE= Content-Length: 43 HOST: 127.0.0.1 CONNECTION: close Remote-Addr: 127.0.0.1 X-REAL-IP: 127.0.0.1 ACCEPT: application/json X-FORWARDED-FOR: 127.0.0.1 Content-Type: application/json ACCEPT-ENCODING: identity [15/Jun/2014:08:58:23] HTTP Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 653, in respond self.hooks.run('before_handler') File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 112, in run raise exc OperationFailed: KCHAUTH0001E: KCHAUTH0001E 127.0.0.1 - - [15/Jun/2014:08:58:23] "POST /plugins/sample/rectangles HTTP/1.0" 500 1105 "" "" F[15/Jun/2014:08:58:23] ENGINE Bus STOPPING [15/Jun/2014:08:58:23] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 51118)) shut down [15/Jun/2014:08:58:23] ENGINE Stopped thread '_TimeoutMonitor'. [15/Jun/2014:08:58:23] ENGINE Stopped thread 'Session cleanup'. [15/Jun/2014:08:58:23] ENGINE Stopped thread 'Autoreloader'. [15/Jun/2014:08:58:23] ENGINE Bus STOPPED [15/Jun/2014:08:58:23] ENGINE Bus EXITING [15/Jun/2014:08:58:23] ENGINE Waiting for child threads to terminate... [15/Jun/2014:08:58:23] ENGINE Waiting for thread MainThread. [15/Jun/2014:08:58:23] ENGINE Bus EXITED ====================================================================== FAIL: test_rectangles (test_plugin.PluginTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_plugin.py", line 91, in test_rectangles self._create_rectangle_and_assert('small', 10, 8) File "test_plugin.py", line 76, in _create_rectangle_and_assert self.assertEquals(201, resp.status) AssertionError: 201 != 500 ---------------------------------------------------------------------- Ran 1 test in 2.550s FAILED (failures=1) It is because you protected the plugins URLs: [/description] tools.kimchiauth.on = True [/rectangles] tools.kimchiauth.on = True tools.kimchiauth.admin_methods = ['POST', 'PUT'] [/circles] tools.kimchiauth.on = True tools.kimchiauth.admin_methods = ['POST', 'PUT'] So to tests work well you need to run patch_auth() in setupModule() - the same way we did for test_rest.py

On 06/15/2014 08:02 PM, Aline Manera wrote:
The tests are failing:
[15/Jun/2014:08:58:21] ENGINE Bus STARTING [15/Jun/2014:08:58:21] ENGINE Started monitor thread 'Autoreloader'. [15/Jun/2014:08:58:21] ENGINE Started monitor thread '_TimeoutMonitor'. [15/Jun/2014:08:58:21] ENGINE Serving on 127.0.0.1:51118 [15/Jun/2014:08:58:21] ENGINE Bus STARTED [15/Jun/2014:08:58:21] ENGINE Started monitor thread 'Session cleanup'. [15/Jun/2014:08:58:23] Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 102, in run hook() File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 62, in __call__ return self.callback(**self.kwargs) File "/home/alinefm/kimchi/src/kimchi/auth.py", line 247, in kimchiauth if check_auth_httpba(): File "/home/alinefm/kimchi/src/kimchi/auth.py", line 194, in check_auth_httpba return login(username, password) File "/home/alinefm/kimchi/src/kimchi/auth.py", line 207, in login raise OperationFailed("KCHAUTH0001E", msg_args) OperationFailed: KCHAUTH0001E: KCHAUTH0001E
[15/Jun/2014:08:58:23] HTTP Request Headers: AUTHORIZATION: Basic YWRtaW46bGV0bWVpbiE= Content-Length: 43 HOST: 127.0.0.1 CONNECTION: close Remote-Addr: 127.0.0.1 X-REAL-IP: 127.0.0.1 ACCEPT: application/json X-FORWARDED-FOR: 127.0.0.1 Content-Type: application/json ACCEPT-ENCODING: identity [15/Jun/2014:08:58:23] HTTP Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 653, in respond self.hooks.run('before_handler') File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 112, in run raise exc OperationFailed: KCHAUTH0001E: KCHAUTH0001E
127.0.0.1 - - [15/Jun/2014:08:58:23] "POST /plugins/sample/rectangles HTTP/1.0" 500 1105 "" "" F[15/Jun/2014:08:58:23] ENGINE Bus STOPPING [15/Jun/2014:08:58:23] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('127.0.0.1', 51118)) shut down [15/Jun/2014:08:58:23] ENGINE Stopped thread '_TimeoutMonitor'. [15/Jun/2014:08:58:23] ENGINE Stopped thread 'Session cleanup'. [15/Jun/2014:08:58:23] ENGINE Stopped thread 'Autoreloader'. [15/Jun/2014:08:58:23] ENGINE Bus STOPPED [15/Jun/2014:08:58:23] ENGINE Bus EXITING [15/Jun/2014:08:58:23] ENGINE Waiting for child threads to terminate... [15/Jun/2014:08:58:23] ENGINE Waiting for thread MainThread. [15/Jun/2014:08:58:23] ENGINE Bus EXITED
====================================================================== FAIL: test_rectangles (test_plugin.PluginTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_plugin.py", line 91, in test_rectangles self._create_rectangle_and_assert('small', 10, 8) File "test_plugin.py", line 76, in _create_rectangle_and_assert self.assertEquals(201, resp.status) AssertionError: 201 != 500
---------------------------------------------------------------------- Ran 1 test in 2.550s
FAILED (failures=1)
It is because you protected the plugins URLs:
[/description] tools.kimchiauth.on = True
[/rectangles] tools.kimchiauth.on = True tools.kimchiauth.admin_methods = ['POST', 'PUT']
[/circles] tools.kimchiauth.on = True tools.kimchiauth.admin_methods = ['POST', 'PUT']
So to tests work well you need to run patch_auth() in setupModule() - the same way we did for test_rest.py
yes. protected the plugins URLs to be able to logout when in the plugin tab last version. Forgot to update the test case. So sorry.
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center
participants (3)
-
Aline Manera
-
shaohef@linux.vnet.ibm.com
-
Sheldon