Internationalization
[squirrelmail.git] / plugins / squirrelspell / modules / lang_change.mod.php
CommitLineData
849bdf42 1<?php
2b5a7157 2
3 /**
4 ** LANG_CHANGE.MOD.PHP -- Squirrelspell module
5 **
6 ** Copyright (c) 1999-2001 The SquirrelMail development team
7 ** Licensed under the GNU GPL. For full terms see the file COPYING.
8 **
9 ** This module changes the international dictionaries selection
10 ** for the user. Called after LANG_SETUP module.
11 **
12 ** $Id$
13 **/
14
15 // For poor wretched souls with E_ALL.
16 global $use_langs, $lang_default, $SQSPELL_APP_DEFAULT;
17
18 $words = sqspell_getWords();
19 if (!$words) {
20 $words = sqspell_makeDummy();
21 }
22 $langs = sqspell_getSettings($words);
23 if (sizeof($use_langs)){
24 // See if the user clicked any options on the previous page.
25 if (sizeof($use_langs)>1){
26 // See if s/he wants more than one dictionary.
27 if ($use_langs[0]!=$lang_default){
28 // See if we need to juggle the order of the dictionaries
29 // to make the default dictionary first in line.
30 if (in_array($lang_default, $use_langs)){
31 // see if the user was dumb and chose a default dictionary
32 // to be something other than the ones he selected.
33 $hold = array_shift($use_langs);
34 $lang_string = join(", ", $use_langs);
35 $lang_string = str_replace("$lang_default", "$hold", $lang_string);
36 $lang_string = $lang_default . ", " . $lang_string;
37 } else {
38 // Yes, he is dumb.
39 $lang_string = join(', ', $use_langs);
40 }
41 } else {
42 // No need to juggle the order -- preferred is already first.
43 $lang_string = join(', ', $use_langs);
44 }
45 } else {
46 // Just one dictionary, please.
47 $lang_string = $use_langs[0];
48 }
49 $lang_array = explode( ',', $lang_string );
50 $dsp_string = '';
51 foreach( $lang_array as $a) {
52 $dsp_string .= _(trim($a)) . ', ';
53 }
54 $dsp_string = substr( $dsp_string, 0, -2 );
55 $msg = '<p>'.
56 sprintf( _("Settings adjusted to: <strong>%s</strong> with <strong>%s</strong> as default dictionary."), $dsp_string, _($lang_default) ) .
57 '</p>';
849bdf42 58 } else {
2b5a7157 59 // No dictionaries selected. Use system default.
60 $msg = '<p>'.
61 sprintf( _("Using <strong>%s</strong> dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT ) .
62 '</p>';
63 $lang_string = $SQSPELL_APP_DEFAULT;
849bdf42 64 }
2b5a7157 65 $old_lang_string = join(", ", $langs);
66 $words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string", $words);
67 // write it down where the sun don't shine.
68 sqspell_writeWords($words);
69 sqspell_makePage(_("International Dictionaries Preferences Updated"), null, $msg);
70
71?>