[Kimchi-devel] [PATCH 2/8] refactor exception: Add messages to be translated on backend
Leonardo Augusto Guimarães Garcia
lagarcia at linux.vnet.ibm.com
Tue Feb 11 17:21:23 UTC 2014
On 02/11/2014 10:14 AM, Aline Manera wrote:
> On 02/11/2014 01:08 AM, Leonardo Augusto Guimarães Garcia wrote:
>> On 02/09/2014 08:47 PM, Aline Manera wrote:
>>> From: Aline Manera <alinefm at br.ibm.com>
>>>
>>> src/kimchi/i18n.py and plugins/sample/i18n.py contain all messages used
>>> in backend to report error to the user
>>>
>>> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
>>> ---
>>> plugins/sample/i18n.py | 15 +++++
>>> src/kimchi/i18n.py | 144
>>> ++++++++++++++++++++++++++++++++++++++++++++++++
>>> 2 files changed, 159 insertions(+)
>>>
>>> diff --git a/plugins/sample/i18n.py b/plugins/sample/i18n.py
>>> index 204460c..b4cd5cb 100644
>>> --- a/plugins/sample/i18n.py
>>> +++ b/plugins/sample/i18n.py
>>> @@ -26,4 +26,19 @@ _ = gettext.gettext
>>>
>>>
>>> messages = {
>>> + "SPAPI0001E": _("Unkown parameter specified %(value)s"),
>>> + "SPAPI0002E": _("The specified value %(value)s is not a
>>> positive number"),
>>> +
>>> + "SPCIRC0001E": _("Circle %(name)s already exists"),
>>> + "SPCIRC0002E": _("Circle %(name)s does not exist"),
>>> + "SPCIRC0003E": _("Specify name and radius to create a Circle"),
>>> + "SPCIRC0004E": _("Circle name must be a string"),
>>> + "SPCIRC0005E": _("Circle radius must be a positive number"),
>>> +
>>> + "SPRET0001E": _("Rectangle %(name)s already exists"),
>>> + "SPRET0002E": _("Rectangle %(name)s does not exist"),
>>> + "SPRET0003E": _("Specify name, length and width to create a
>>> Rectangle"),
>>> + "SPRET0004E": _("Rectangle name must be a string"),
>>> + "SPRET0005E": _("Rectangle length must be a positive number"),
>>> + "SPRET0006E": _("Rectangle width must be a positive number"),
>> From where does these key values come? Are they just randomly chosen?
>> Randomly or not, there should be a comment on how they were chosen in
>> the commit message.
>
> I have explained about them on RFC.
> But of course, it needs to be in commit message. I will add it on V2.
>
>> Also, IIRC, I heard that we were using the English version of the
>> message as the key instead of these crypt keys. Has this changed?
>
> There are 2 different things - the code and the key.
>
> This file is built like:
> <code>: _(<key>)
>
> The key is an English text which represents the text to be translated
> and recognized by gettext.
>
> The code I am introducing now so we can identify the error message
> independent of the language
> used by the user.
> For example, an user running Kimchi in Japanese can report a bug with
> the errors messages he got
> and we can identify the error by the code as we probably don't know
> Japanese.
>
> The error message will be shown to the user like:
> <code>: <translated-message>
>
> For example:
> KCHASYNC0001E: Datastore is not initiated in the model object.
Ok, understood, thanks. I think this needs to be in the commit message
as well.
Best regards,
Leonardo Garcia
>
>> Best regards,
>>
>> Leonardo Garcia
>>> }
>>> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
>>> index 204460c..1a8fb5b 100644
>>> --- a/src/kimchi/i18n.py
>>> +++ b/src/kimchi/i18n.py
>>> @@ -26,4 +26,148 @@ _ = gettext.gettext
>>>
>>>
>>> messages = {
>>> + "KCHAPI0001E": _("Unkown parameter specified %(value)s"),
>>> +
>>> + "KCHASYNC0001E": _("Datastore is not initiated in the model
>>> object."),
>>> +
>>> + "KCHAUTH0001E": _("Authentication failed for user '%(userid)s'.
>>> [Error code: %(code)s]"),
>>> +
>>> + "KCHDISKS0001E": _("Error while getting block devices. Details:
>>> %(err)s"),
>>> + "KCHDISKS0002E": _("Error while getting block device
>>> information for %(device)s."),
>>> +
>>> + "KCHDL0001E": _("Unable to find distro file: %(filename)s"),
>>> + "KCHDL0002E": _("Unable to parse distro file: %(filename)s.Make
>>> sure, it is a json file."),
>>> +
>>> + "KCHISCSI0001E": _("Unable to login to iSCSI host target
>>> %(portal)s. Details: %(err)s"),
>>> + "KCHISCSI0002E": _("Unable to login to iSCSI host %(host)s
>>> target %(target)s"),
>>> +
>>> + "KCHISO0001E": _("Unable to find ISO file ISO %(filename)s"),
>>> + "KCHISO0002E": _("The ISO file %(filename)s is not bootable"),
>>> + "KCHISO0003E": _("The ISO file %(filename)s does not have a
>>> valid El Torito boot record"),
>>> + "KCHISO0004E": _("Invalid El Torito validation entry in ISO
>>> %(filename)s"),
>>> + "KCHISO0005E": _("Invalid El Torito boot indicator in ISO
>>> %(filename)s"),
>>> + "KCHISO0006E": _("Unexpected volume type for primary volume in
>>> ISO %(filename)s"),
>>> + "KCHISO0007E": _("Bad format while reading volume descriptor in
>>> ISO %(filename)s"),
>>> +
>>> + "KCHVM0001E": _("Virtual machine $(name)s already exists"),
>>> + "KCHVM0002E": _("Virtual machine %(name)s does not exist"),
>>> + "KCHVM0003E": _("Unable to rename virtual machine %(name)s. The
>>> name %(new_name)s already exists or it is not powered off."),
>>> + "KCHVM0004E": _("Unable to retrieve screenshot for stopped
>>> virtual machine %(name)s"),
>>> + "KCHVM0005E": _("Remote ISO image is not supported by this
>>> server."),
>>> + "KCHVM0006E": _("Screenshot not supported for virtual machine
>>> %(name)s"),
>>> + "KCHVM0007E": _("Unable to create virtual machine %(name)s.
>>> Details: %(err)s"),
>>> + "KCHVM0008E": _("Unable to rename virtual machine %(name)s.
>>> Details: %(err)s"),
>>> + "KCHVM0009E": _("Unable to retrieve virtual machine %(name)s.
>>> Details: %(err)"),
>>> + "KCHVM0010E": _("Unable to connect to powered off machine
>>> %(name)s."),
>>> + "KCHVM0011E": _("Virtual machine name must be a string"),
>>> + "KCHVM0012E": _("Invalid template URI: %(value)s specified for
>>> virtual machine"),
>>> + "KCHVM0013E": _("Invalid storage pool URI: %(value)s specified
>>> for virtual machine"),
>>> + "KCHVM0014E": _("Supported virtual machine graphics are spice
>>> or vnc"),
>>> + "KCHVM0015E": _("Graphics address to listen on must be IPv4 or
>>> IPv6"),
>>> + "KCHVM0016E": _("Specify a template to create a Virtual Machine
>>> from"),
>>> +
>>> + "KCHVMIF0001E": _("Interface %(iface)s does not exist in
>>> virtual machine %(name)s"),
>>> + "KCHVMIF0002E": _("Network %(network)s specified for virtual
>>> machine %(name)s does not exist"),
>>> + "KCHVMIF0003E": _("Do not support guest interface hot plug
>>> attachment"),
>>> + "KCHVMIF0004E": _("Supported virtual machine interfaces type is
>>> only network"),
>>> + "KCHVMIF0005E": _("Network name for virtual machine interface
>>> must be a string"),
>>> + "KCHVMIF0006E": _("Invalid network model card specified for
>>> virtual machine interface"),
>>> + "KCHVMIF0007E": _("Specify type and network to add a new
>>> virtual machine interface"),
>>> +
>>> + "KCHTMPL0001E": _("Template %(name)s already exists"),
>>> + "KCHTMPL0002E": _("Template %(name)s does not exist"),
>>> + "KCHTMPL0003E": _("Network '%(network)s' specified for template
>>> %(template)s does not exist"),
>>> + "KCHTMPL0004E": _("Storage Pool %(pool)s specified for template
>>> %(template)s does not exist"),
>>> + "KCHTMPL0005E": _("Storage Pool %(pool)s specified for template
>>> %(template)s is not active"),
>>> + "KCHTMPL0006E": _("Invalid parameter '%(param)s' specified for
>>> cdrom."),
>>> + "KCHTMPL0007E": _("Network %(network)s specified for template
>>> %(template)s is not active"),
>>> + "KCHTMPL0008E": _("Template name must be a string"),
>>> + "KCHTMPL0009E": _("Template icon must be a path to the image"),
>>> + "KCHTMPL0010E": _("Template distribution must be a string"),
>>> + "KCHTMPL0011E": _("Template distribution version must be a
>>> string"),
>>> + "KCHTMPL0012E": _("The number of CPUs must be a integer"),
>>> + "KCHTMPL0013E": _("Amount of memory (MB) must be an integer
>>> greater than 512"),
>>> + "KCHTMPL0014E": _("Template CDROM must be a local or remote ISO
>>> file"),
>>> + "KCHTMPL0015E": _("Invalid storage pool URI %(value)s specified
>>> for Template"),
>>> + "KCHTMPL0016E": _("Specify an ISO image as CDROM to create a
>>> Template"),
>>> + "KCHTMPL0017E": _("All networks for the Template must be
>>> specified in a list."),
>>> +
>>> + "KCHPOOL0001E": _("Storage Pool %(name)s already exists"),
>>> + "KCHPOOL0002E": _("Storage Pool %(name)s does not exist"),
>>> + "KCHPOOL0003E": _("Autostart flag must be true or false"),
>>> + "KCHPOOL0004E": _("Specify %(item)s in order to create the
>>> Storage Pool %(name)s"),
>>> + "KCHPOOL0005E": _("Unable to delete active Storage Pool
>>> %(name)s"),
>>> + "KCHPOOL0006E": _("Unable to list Storage Pools. Details:
>>> %(err)s"),
>>> + "KCHPOOL0007E": _("Unable to create Storage Pool %(name)s.
>>> Details: %(err)s"),
>>> + "KCHPOOL0008E": _("Unable to get number of Storage Volumes in
>>> Storage Pool %(name)s. Details: %(err)s"),
>>> + "KCHPOOL0009E": _("Unable to activate Storage Pool %(name)s.
>>> Details: %(err)s"),
>>> + "KCHPOOL0010E": _("Unable to deactivate Storage Pool %(name)s.
>>> Details: %(err)s"),
>>> + "KCHPOOL0011E": _("Unable to delete Storage Pool %(name)s.
>>> Details: %(err)s"),
>>> + "KCHPOOL0012E": _("Unable to create NFS Pool as export path
>>> %(path)s may block during mount"),
>>> + "KCHPOOL0013E": _("Unable to create NFS Pool as export path
>>> %(path)s mount failed"),
>>> + "KCHPOOL0014E": _("Unsupported Storage Pool type: %(type)s"),
>>> + "KCHPOOL0015E": _("Error while getting xml for Storage Pool
>>> %(pool)s"),
>>> + "KCHPOOL0016E": _("Storage Pool name must be a string"),
>>> + "KCHPOOL0017E": _("Supported Storage Pool types are dir, netfs,
>>> logical and kimchi-iso"),
>>> + "KCHPOOL0018E": _("Storage Pool path must be a string"),
>>> + "KCHPOOL0019E": _("Storage Pool host must be a IP or hostname"),
>>> + "KCHPOOL0020E": _("Storage Pool devices must be the full path
>>> to the block device"),
>>> + "KCHPOOL0021E": _("Storage Pool devices parameter must be a
>>> list"),
>>> + "KCHPOOL0022E": _("Target IQN of an iSCSI pool must be a string"),
>>> + "KCHPOOL0023E": _("Port of a remote storage server must be an
>>> integer between 1 and 65535"),
>>> + "KCHPOOL0024E": _("Login username of the iSCSI target must be a
>>> string"),
>>> + "KCHPOOL0025E": _("Login password of the iSCSI target must be a
>>> string"),
>>> + "KCHPOOL0026E": _("Specify name and type to create a Storage
>>> Pool"),
>>> +
>>> + "KCHVOL0001E": _("Storage Volume %(name)s already exists"),
>>> + "KCHVOL0002E": _("Storage Volume %(name)s does not exist in
>>> Storage Pool %(pool)s"),
>>> + "KCHVOL0003E": _("Unable to create Storage Volume %(volume)s
>>> becuase Storage Pool %(pool)s is not active"),
>>> + "KCHVOL0004E": _("Specify %(item)s in order to create Storage
>>> Volume %(volume)s"),
>>> + "KCHVOL0005E": _("Unable to retrieve Storage Volume %(volume)s
>>> because Storage Pool %(pool)s is not active"),
>>> + "KCHVOL0006E": _("Unable to list Storage Volumes because
>>> Storage Pool %(pool)s is not active"),
>>> + "KCHVOL0007E": _("Unable to create Storage Volume %(name)s in
>>> Storage Pool %(pool)s. Details: %(err)s"),
>>> + "KCHVOL0008E": _("Unable to list Storage Volumes in Storage
>>> Pool %(pool)s. Details: %(err)s"),
>>> + "KCHVOL0009E": _("Unable to wipe Storage Volumes %(name)s.
>>> Details: %(err)s"),
>>> + "KCHVOL0010E": _("Unable to delete Storage Volume %(name)s.
>>> Details: %(err)s"),
>>> + "KCHVOL0011E": _("Unable to resize Storage Volume %(name)s.
>>> Details: %(err)s"),
>>> +
>>> + "KCHIFACE0001E": _("Interface %(name)s does not exist"),
>>> +
>>> + "KCHNET0001E": _("Network %(name)s already exists"),
>>> + "KCHNET0002E": _("Network %(name)s does not exist"),
>>> + "KCHNET0003E": _("Subnet %(subnet)s specified for network
>>> %(network)s is not valid."),
>>> + "KCHNET0004E": _("Specify a network interface to create bridged
>>> network %(name)s"),
>>> + "KCHNET0005E": _("Unable to delete active network %(name)s"),
>>> + "KCHNET0006E": _("Interface %(iface)s specified for network
>>> %(network)s is already in use"),
>>> + "KCHNET0007E": _("Interface should be bare nic, bonding or
>>> bridge device."),
>>> + "KCHNET0008E": _("Unable to create network %(name)s. Details:
>>> %(err)s"),
>>> + "KCHNET0009E": _("Unable to find a free IP address for network
>>> '%(name)s'"),
>>> + "KCHNET0010E": _("Unable to create VLAN tagged bridge using
>>> interface %(iface)s. Details: %(err)"),
>>> + "KCHNET0011E": _("Network name must be a string"),
>>> + "KCHNET0012E": _("Supported network types are isolated, nat and
>>> bridge"),
>>> + "KCHNET0013E": _("Network subnet must be a string with ip
>>> address and prefix or netmask"),
>>> + "KCHNET0014E": _("Network interface must be a string"),
>>> + "KCHNET0015E": _("Network VLAN ID must be an integer between 1
>>> and 4094"),
>>> + "KCHNET0016E": _("Specify name and type to create a Network"),
>>> +
>>> + "KCHDR0001E": _("Debug report %(name)s does not exist"),
>>> + "KCHDR0002E": _("Debug report tool not found in system"),
>>> + "KCHDR0003E": _("Unable to create debug report %(name)s.
>>> Details: %(err)s."),
>>> + "KCHDR0004E": _("Can not find generated debug report named
>>> %(name)s"),
>>> + "KCHDR0005E": _("Unable to generate debug report %(name)s.
>>> Details: %(err)s"),
>>> +
>>> + "KCHSR0001E": _("Storage server %(server)s was not used by
>>> Kimchi"),
>>> +
>>> + "KCHDISTRO0001E": _("Distro '%(name)s' does not exist"),
>>> +
>>> + "KCHPART0001E": _("Partition %(name)s does not exist in the
>>> host"),
>>> +
>>> + "KCHHOST0001E": _("Unable to shutdown host machine as there are
>>> running virtual machines"),
>>> + "KCHHOST0002E": _("Unable to reboot host machine as there are
>>> running virtual machines"),
>>> +
>>> + "KCHOBJST0001E": _("Unable to find %(item)s in datastore"),
>>> +
>>> + "KCHUTILS0001E": _("Invalid URI %(uri)s"),
>>> + "KCHUTILS0002E": _("Timeout while running command '%(cmd)s'
>>> after %(seconds)s seconds"),
>>> + "KCHUTILS0003E": _("Unable to choose a virutal machine name"),
>>> }
>
More information about the Kimchi-devel
mailing list