def extract_preferences(filepath): # Replace the environment variable back into the file path to make it system independent reference_name = filepath.replace(os.environ.get('EIFFEL_SRC'), '$EIFFEL_SRC') dom = xml.dom.minidom.parse(filepath) for preference in dom.getElementsByTagName('PREF'): # Every preference tag has a "NAME" and "DESCRIPTION" attribute name_parts = extract_preference_name_parts(preference.attributes['NAME'].value) # Create a pretty printed path from the names to be used as comments in the po file full_name = ' > '.join(name_parts) # PO entries for parent name elements for name in name_parts[:-1]: # Generate an entry for each name along the path po.add_message( i18n.empty_message( name, 'preference/section', ['Section name of preference "' + full_name + '"'], reference_name)) # Get name of last path element which is the preference name itself name = name_parts[-1] descr = preference.attributes['DESCRIPTION'].value # PO entry for name po.add_message( i18n.empty_message( name, 'preference/name', ['Name of preference "' + name + '"', 'Path: ' + full_name, 'Description: ' + descr], reference_name)) # PO entry for description po.add_message( i18n.empty_message( descr, 'preference/description', ['Description of preference "' + name + "'", 'Path: ' + full_name], reference_name))
# extract error messages # ---------------------- po = i18n.PoFile(os.path.join (path_output, 'errors.pot')) # extract long error messages for filename in os.listdir (path_help_error): filepath = os.path.join (path_help_error, filename) if os.path.isfile(filepath): file = open(filepath, 'r') # Add whole file as entry to PO file po.add_message( i18n.empty_message( file.read(), 'help/error/long', 'Long description for error ' + filename, '$EIFFEL_SRC/Delivery/studio/help/errors/' + filename)) file.close() # extract short error messages for filename in os.listdir (path_help_error_short): filepath = os.path.join (path_help_error_short, filename) if os.path.isfile(filepath): file = open(filepath, 'r') # Add whole file as entry to PO file po.add_message( i18n.empty_message( file.read(), 'help/error/short',