Chinese menu in Zenoss

Source: Internet
Author: User

Recently, I am working on Zenoss in Chinese. I found that many menu contents are stored in souce \ trunk \ zenoss \ Products \ ZenModel \ migrate \ menus. in The py file, but no matter how you change this file, it does not take effect, and finally found the mystery in the zenoss development documentation.

Adding a new menu item is fairly straightforward. Because menu items are persistent objects, modifications must
Happen in a migrate script (or be encoded as XML in a ZenPack). The method ZenMenuable. buildMenus () accepts
A dictionary of menus, each of which is a list of dictionaries representing the attributes of menu items. Instructions
On writing migrate scripts can be found elsewhere in this guide

Finally, the following describes the steps of the Chinese menu:

1. Make sure that the format of the corresponding field in the menus. py file is _ t ('key ')
2. Make sure that zenoss. po has a corresponding Chinese version.
3. Make sure that the value of the version variable of the menus. py MenuRelations class is the current zenoss version, for example, 4.2.4.
4. Run zenmigrate -- dont-commit to ensure that INFO: zen. migrate: Installing MenuRelations (4.2.4) is output)
5. Execute zenmigrate.

Since menus. many menus in py are not in the _ t ("key") format. If you add one, it will be very troublesome. The following script can use the existing menus. py generates a new file. All the descriptions in this file comply with the _ t ("key") format to generate an esult.txt file. This file contains all empty implementations that do not exist in the po file.

_ Author _ = 'Eric. sunah' # list all menus that do not start with _ t and generate a new file. All the menus in the new file comply with the _ t ('key') format def i18NAllMenu (menusFile, newMenusFile): menus = open (menusFile) newmenus = open (newMenusFile, "w") DESC = 'description' no_i18N_key = [] for line in menus: if line. strip (). find ('\ 'description ')! =-1: # 'description': 'set Systems... ', new_line = line [len (DESC):] if new_line.find (' _ t ')! =-1: newmenus. write (line) else: new_key = new_line.strip () [16:-2] # print (new_key) no_i18N_key.append (new_key) newmenus. write ("'description': _ t ('" + new_key + "')," + "\ n") else: newmenus. write (line) print (len (no_i18N_key) print (no_i18N_key) return no_i18N_key # list all menus that do not start with _ t and are not in zenoss. keydef noI18NKeyInPO (i18Keys, poFile): f = open (poFile, encoding = 'utf-8') poKeys = [] for line in f: # msgid "Add to Graphs... "# msgstr" added to the chart... "if (line. strip (). startswith ('msgid'): poKeys. append (line [7:-2]) # print (poKeys) nokeyi18n = [] resultfile = open ('d: \ soucecode \ CorePython \ zenoss \ esult.txt ', 'w ') for no_i18key in i18Keys: if no_i18key not in poKeys: nokeyi18n. append (no_i18key) # print (no_i18key) resultfile. write ("msgid \" "+ no_i18key +" \ "" + "\ n") resultfile. write ("msgstr \" \ "") resultfile. write ("\ n") resultfile. write ("\ n") print (nokeyi18n) print (len (nokeyi18n) if _ name _ = "_ main __": no_i18N_key = i18NAllMenu ('d: \ soucecode \ CorePython \ zenoss \ menus. py', 'd: \ soucecode \ CorePython \ zenoss \ ewmenus. py ') noI18NKeyInPO (no_i18N_key, 'd: \ soucecode \ CorePython \ zenoss. po ');


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.