BabelKit Code Set Methods

Sometimes we need access to a full code data set.


$rows = $babelkit->lang_set($code_set, $code_lang);

The lang_set() method returns an array of code row arrays for the code and language specified. Missing language translations for the language requested will result in missing rows.

Each row consists of the code_code, code_desc, code_order and code_flag fields sorted by code_order and code_code.

The code_order and code_flag values for each code are stored in the native language code rows only. So if you ask lang_set() for a non-native language the rows will not be sorted by the code_order field or include the 'd' deprecated flags in the code_flag field.


$rows = $babelkit->full_set($code_set, $code_lang);

The full_set() method is exactly like the lang_set() method except that any missing translations are filled in with the native language descriptions, the sort is by code_order, code_code and code_flag will include the 'd' deprecated flags.

Here are some examples that print out the non-deprecated month codes and their descriptions:

print "<pre>\n";
$set_list = $babelkit->full_set('month', $lang);
foreach ( $set_list as $row ) {
    list( $code_code, $code_desc, $code_order, $code_flag ) = $row;
    if ($code_flag == 'd') continue;
    printf("%2d - %s\n", $code_code, $code_desc);
print "</pre>\n";
# Perl
print "<pre>\n";
my $set_list = $babelkit->full_set('month', $lang);
for my $row ( @$set_list ) {
    my ( $code_code, $code_desc, $code_order, $code_flag ) = @$row;
    next if $code_flag eq 'd';
    printf("%2d - %s\n", $code_code, $code_desc);
print "</pre>\n";