#!/usr/bin/perl
# This script configures dictionaries-common (sarge version > 0.20)
use strict;
use warnings;

use vars qw($lang);

# If no locale is given as argument, quit
my $lang = $ARGV[0] or die "No language given";

# We use preseed() helper subroutine so we have to include
# its definition
require '/usr/lib/localization-config/common/preseed.pl';

# Define the package name
my $package = "dictionaries-common";

# We define an associative arrays with the debconf keys
# These will be used in combination with the values in the
# next array
my %keynames = ( DICT     => 'dictionaries-common/default-ispell'
               );

# The actual values available.
my %dict_map = (
                    # entries sorted alphabetically
                    'bg_BG'      => { DICT => 'bulgarian (Bulgarian)'},
                    'ca_ES@euro' => { DICT => 'catala8 (Catalan 8 bits)'},
                    'cs_CZ'      => { DICT => 'czech (Czech)'},
                    'da_DK'      => { DICT => 'dansk (Danish)'},
                    'de_BE@euro' => { DICT => 'deutsch (New German 8 bit)'},
                    'de_CH'      => { DICT => 'deutsch (Swiss German 8 bit)' },
                    'de_DE@euro' => { DICT => 'deutsch (New German 8 bit)'},
# Greek does not use ispell, use aspell instead, defaults to ibritish
                    'el_GR.UTF-8'=> { DICT => 'british (British English)'},
                    'en_AU'      => { DICT => 'british (British English)'},
                    'en_CA'      => { DICT => 'british (British English)'},
                    'en_IE@euro' => { DICT => 'british (British English)'},
                    'en_US'      => { DICT => 'american (American English)'},
                    'es_AR'      => { DICT => 'castellano8 (Spanish 8 bit)'},
                    'es_ES@euro' => { DICT => 'castellano8 (Spanish 8 bit)'},
                    'es_MX'      => { DICT => 'castellano8 (Spanish 8 bit)'},
                    'es_PE'      => { DICT => 'castellano8 (Spanish 8 bit)'},
# New entry for Faroe Islands                   
                    'fo_FO'      => { DICT => 'froyskt (Faroese)' },
                    'fi_FI@euro' => { DICT => 'suomi (Finnish Large)'},
                    'fr_BE@euro' => { DICT => 'francais GUTenberg (French GUTenberg)'},
                    'fr_CA'      => { DICT => 'francais GUTenberg (French GUTenberg)'},
                    'fr_CH'      => { DICT => 'francais GUTenberg (French GUTenberg)'},
                    'fr_FR@euro' => { DICT => 'francais GUTenberg (French GUTenberg)'},
# New entry for Irish
                    'ga_IE@euro' => { DICT => 'Gaeilge (Irish)' },
# New entry for Scots Gaelic
                    'gd_GB'      => { DICT => 'Gaidhlig (Scots Gaelic)' },
# New entry for Galician
                    'gl_ES@euro' => { DICT => 'galego-minimos (Galician-minimos)' },
# New entry for Manx Gaelic
                    'gv_GB'      => { DICT => 'Gaelg (Manx Gaelic)' },
# New entry for Hungarian
                    'hu_HU'      => { DICT => 'magyar (Hungarian)' },
                    'it_IT@euro' => { DICT => 'italiano (Italian)'},
# Japanese does not have ispell support
#                   'ja_JP'      => { DICT => ''},
# Korean does not have ispell support
#                   'ko_KR'      => { DICT => ''},
                    'lt_LT'      => { DICT => 'lietuvių (Lithuanian)' },
# Latvian does not have ispell support
#                   'lv_LV'      => { DICT => 'lv'},
                    'nb_NO'      => { DICT => 'bokmål (Bokmal Norwegian)'}, # Same as no_NO
# Unknown dictionary
#                   'nds_DE'     => { DICT => ''},
                    'nl_BE@euro' => { DICT => 'nederlands (Dutch)'},
                    'nl_NL@euro' => { DICT => 'nederlands (Dutch)'},
                    'nn_NO'      => { DICT => 'nynorsk (New Norwegian)'},
                    'no_NO'      => { DICT => 'bokmål (Bokmal Norwegian)'}, # Same as nb_NO
                    'pl_PL'      => { DICT => 'polish (Polish)' },
                    'pt_PT@euro' => { DICT => 'portugues europeu (European Portuguese)' },
                    'pt_BR'      => { DICT => 'portugues brasileiro (Brazilian Portuguese)'},
                    'ru_RU'      => { DICT => 'russian (Russian koi8-r)' },
# Northern Saami is not yet available
#                   'se_NO'      => { DICT => 'sapmi'},
                    'sv_SE'      => { DICT => 'svenska (Swedish)'},
                    'uk_UA'      => { DICT => 'ukrainian (Ukrainian)' }
                   );

# Print the supported locale entries.
if ("supported" eq $lang) {
    for $lang (sort keys %dict_map) {
        print "$lang\n";
    }
    exit 0;
}

# Call the preseed() subroutine to set the package debconf values.
preseed($package, $lang, \%dict_map, \%keynames);

1;
