lang::catalog::import (public)
lang::catalog::import [ -package_key package_key ] \ [ -locales locales ] [ -initialize ] [ -cache ]
Defined in packages/acs-lang/tcl/lang-catalog-procs.tcl
Import messages from catalog files to the database. By default all messages for enabled packages and enabled locales will be imported. Optionally, the import can be restricted to a certain package and/or a list of locales. Invokes the proc lang::catalog::import_messages that deals with multiple imports (upgrades).
- Switches:
- -package_key (optional)
- Restrict the import to the package with this key
- -locales (optional)
- A list of locales to restrict the import to
- -initialize (optional, boolean)
- Only load messages from packages that have never before had any message imported
- -cache (optional, boolean)
- Provide this switch if you want the proc to cache all the imported messages
- Returns:
- An array list containing the number of messages processed, number of messages added, number of messages updated, number of messages deleted by the import, and a list of errors produced. The keys of the array list are processed, added, updated, and deleted, and errors.
- Author:
- Peter Marklund
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- lang_test__lc_procs, locale_language_fallback, upgrade, test_catalog_import_export
Source code: set message_count(processed) 0 set message_count(added) 0 set message_count(updated) 0 set message_count(deleted) 0 set message_count(errors) [list] if { $package_key ne "" } { set package_key_list $package_key } else { set package_key_list [apm_enabled_packages] } if { $initialize_p } { set uninitialized_packages [uninitialized_packages] } foreach package_key $package_key_list { if {$initialize_p && $package_key ni $uninitialized_packages} { # The package is already initialized continue } # Skip the package if it has no catalog files at all if { ![file exists [package_catalog_dir $package_key]] } { continue } set catalog_files [get_catalog_paths_for_import -package_key $package_key -locales $locales] # Issue a warning and exit if there are no catalog files if { $catalog_files eq "" } { ns_log Warning "No catalog files found for package $package_key in locales: $locales" continue } foreach file_path $catalog_files { # Use an ad_try so that parse failure of one file doesn't # cause the import of all files to fail ad_try { set loop_message_count [lang::catalog::import_from_file $file_path] } on error {errorMsg} { ad_log Error "The import of file $file_path failed, error message is: $errorMsg" } on ok {r} { foreach {action count} $loop_message_count { if { $action ne "errors" } { set message_count($action) [expr {$message_count($action) + $count}] } } lappend message_count(errors) {*}[dict get $loop_message_count errors] } } } if { $cache_p } { lang::message::cache } 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