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
(boolean) (optional)
Only load messages from packages that have never before had any message imported
-cache
(boolean) (optional)
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):
%3 test_lang_test__lc_procs lang_test__lc_procs (test acs-lang) lang::catalog::import lang::catalog::import test_lang_test__lc_procs->lang::catalog::import test_locale_language_fallback locale_language_fallback (test acs-lang) test_locale_language_fallback->lang::catalog::import test_test_catalog_import_export test_catalog_import_export (test acs-lang) test_test_catalog_import_export->lang::catalog::import test_upgrade upgrade (test acs-lang) test_upgrade->lang::catalog::import ad_log ad_log (public) lang::catalog::import->ad_log ad_try ad_try (public) lang::catalog::import->ad_try apm_enabled_packages apm_enabled_packages (public) lang::catalog::import->apm_enabled_packages lang::catalog::get_catalog_paths_for_import lang::catalog::get_catalog_paths_for_import (private) lang::catalog::import->lang::catalog::get_catalog_paths_for_import lang::catalog::import_from_file lang::catalog::import_from_file (private) lang::catalog::import->lang::catalog::import_from_file apm_load_catalog_files apm_load_catalog_files (private) apm_load_catalog_files->lang::catalog::import lang::test::execute_upgrade lang::test::execute_upgrade (private) lang::test::execute_upgrade->lang::catalog::import packages/acs-admin/www/apm/version-i18n-import.tcl packages/acs-admin/ www/apm/version-i18n-import.tcl packages/acs-admin/www/apm/version-i18n-import.tcl->lang::catalog::import packages/acs-lang/www/admin/import-locale-from-files.tcl packages/acs-lang/ www/admin/import-locale-from-files.tcl packages/acs-lang/www/admin/import-locale-from-files.tcl->lang::catalog::import packages/acs-lang/www/admin/import-messages.tcl packages/acs-lang/ www/admin/import-messages.tcl packages/acs-lang/www/admin/import-messages.tcl->lang::catalog::import

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
            array unset loop_message_count
            ad_try {
                array 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 [array names loop_message_count] {
                    if { $action ne "errors" } {
                        set message_count($action) [expr {$message_count($action) + $loop_message_count($action)}]
                    }
                }
                lappend message_count(errors) {*}$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

[ hide source ] | [ make this the default ]
Show another procedure: