• Publicity: Public Only All

ref-language-procs.tcl

Library for managing language codes

Location:
packages/ref-language/tcl/ref-language-procs.tcl
Author:
Emmanuelle Raffenne <eraffenne@gmail.com>

Procedures in this file

Detailed information

ref_language::set_data (public)

 ref_language::set_data -label label [ -iso1 iso1 ] [ -iso2 iso2 ]

Add new ISO-639 language codes (3 chars and 2 chars) where they don't exist, update them otherwise.

Switches:
-label (required)
-iso1 (optional)
-iso2 (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_ref_language__set_data ref_language__set_data (test ref-language) ref_language::set_data ref_language::set_data test_ref_language__set_data->ref_language::set_data db_dml db_dml (public) ref_language::set_data->db_dml db_string db_string (public) ref_language::set_data->db_string ref_language::set_iso1 ref_language::set_iso1 (private) ref_language::set_data->ref_language::set_iso1 ref_language::apm::add_language_639_2_codes ref_language::apm::add_language_639_2_codes (private) ref_language::apm::add_language_639_2_codes->ref_language::set_data ref_language::apm::after_upgrade ref_language::apm::after_upgrade (private) ref_language::apm::after_upgrade->ref_language::set_data

Testcases:
ref_language__set_data
[ hide source ] | [ make this the default ]

Content File Source

ad_library {

    Library for managing language codes

    @author Emmanuelle Raffenne (eraffenne@gmail.com)
}

namespace eval ref_language {}

d_proc -public ref_language::set_data {
    -label:required
    {-iso1 ""}
    {-iso2 ""}
} {
    Add new ISO-639 language codes (3 chars and 2 chars) where they don't exist, 
    update them otherwise.
} {

    if { $iso1 eq "" && $iso2 eq "" } {

        error "you need to provide either a 2 chars or a 3 chars language code"

    } else {

        if { $iso2 ne "" } {
            set exists_p [db_string get_lang {} -default 0]

            if { $exists_p } {
                db_dml update_lang {}
            } else {
                db_dml insert_lang {}
            }
        }

        if { $iso1 ne "" } {
            ref_language::set_iso1 -code $iso1 -name $label
        }
    }

}

d_proc -private ref_language::set_iso1 {
    -code:required
    -name:required
} {
    Add a new ISO-639-1 language code (2 chars) if it doesn't exist, 
    update it otherwise
} {

    set exists_p [db_string get_lang {} -default 0]

    if { $exists_p } {
        db_dml update_lang {}
    } else {
        db_dml insert_lang {}
    }

}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: