lang::catalog::import_from_file (private)
lang::catalog::import_from_file file_path
Defined in packages/acs-lang/tcl/lang-catalog-procs.tcl
Import messages for a certain locale and package from a given XML catalog file to the database. This procedure invokes lang::catalog::parse to read the catalog file and lang::message::register to register the messages with the system (updates database and cache).
The import should be considered an upgrade if the package has had messages imported before. In this case the proc lang::catalog::import_messages will be used to register the new messages with the system and handle the upgrade logic (a merge with what's in the database).
- Parameters:
- file_path (required)
- The absolute path of the XML file to import messages from. The path must be on valid format, see apm_is_catalog_file
- Returns:
- An array list containing the number of messages processed, number of messages added, number of messages updated, and the number of messages deleted by the import. The keys of the array list are processed, added, updated, and deleted.
- Author:
- Peter Marklund
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # Check arguments assert_catalog_file $file_path # Parse the catalog file and put the information in an array # LARS NOTE: Change parse to take three array-names, catalog, messages, descriptions, and use upvar array set catalog_array [parse [read_file $file_path]] # Extract package_key, locale, and charset from the file path array set filename_info [apm_parse_catalog_path $file_path] # Setting these variables to improve readability of code in this proc set package_key $filename_info(package_key) set locale $filename_info(locale) set charset $filename_info(charset) # Compare xml package_key with file path package_key - abort if there is a mismatch if { $package_key ne $catalog_array(package_key) } { error "the package_key $catalog_array(package_key) in the file $file_path does not match the package_key $package_key in the filesystem" } # Get the messages array, and the list of message keys to iterate over array set messages_array $catalog_array(messages) set messages_array_names [array names messages_array] # Get the descriptions array array set descriptions_array $catalog_array(descriptions) ns_log Notice "Loading messages in file $file_path" # Register messages array set message_count [lang::catalog::import_messages -file_messages_list [array get messages_array] -package_key $package_key -locale $locale] # Register descriptions foreach message_key $messages_array_names { if { [info exists descriptions_array($message_key)] } { ad_try { lang::message::update_description -package_key $catalog_array(package_key) -message_key $message_key -description $descriptions_array($message_key) } on error {errorMsg} { ad_log Error "Registering description for key ${package_key}.${message_key} in locale $locale failed with: $errorMsg" } } } return [array get message_count]Generic XQL file: packages/acs-lang/tcl/lang-catalog-procs.xql
PostgreSQL XQL file: packages/acs-lang/tcl/lang-catalog-procs-postgresql.xql
Oracle XQL file: packages/acs-lang/tcl/lang-catalog-procs-oracle.xql