| 1 | <?php |
| 2 | /** |
| 3 | * lang_change.mod |
| 4 | * ---------------- |
| 5 | * Squirrelspell module |
| 6 | * |
| 7 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
| 8 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 9 | * |
| 10 | * This module changes the international dictionaries selection |
| 11 | * for the user. Called after LANG_SETUP module. |
| 12 | * |
| 13 | * @author Konstantin Riabitsev <icon@duke.edu> |
| 14 | * @version $Id$ |
| 15 | * @package plugins |
| 16 | * @subpackage squirrelspell |
| 17 | */ |
| 18 | |
| 19 | global $SQSPELL_APP_DEFAULT; |
| 20 | |
| 21 | if (! sqgetGlobalVar('use_langs',$use_langs,SQ_POST)) { |
| 22 | $use_langs = array($SQSPELL_APP_DEFAULT); |
| 23 | } |
| 24 | |
| 25 | if (! sqgetGlobalVar('lang_default',$lang_default,SQ_POST)) { |
| 26 | $lang_default = $SQSPELL_APP_DEFAULT; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Rebuild languages. Default language is first one. |
| 31 | */ |
| 32 | $new_langs = array($lang_default); |
| 33 | foreach ($use_langs as $lang) { |
| 34 | if (! in_array($lang,$new_langs)) { |
| 35 | $new_langs[]=$lang; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | if (sizeof($new_langs)>1) { |
| 40 | $dsp_string = ''; |
| 41 | foreach( $new_langs as $a) { |
| 42 | $dsp_string .= _(htmlspecialchars(trim($a))) . ', '; |
| 43 | } |
| 44 | // remove last comma and space |
| 45 | $dsp_string = substr( $dsp_string, 0, -2 ); |
| 46 | |
| 47 | /** |
| 48 | * i18n: first %s is comma separated list of languages, second %s - default language. |
| 49 | * Language names are translated, if they are present in squirrelmail.po file. |
| 50 | * make sure that you don't use html codes in language name translations |
| 51 | */ |
| 52 | $msg = '<p>' |
| 53 | . sprintf(_("Settings adjusted to: %s with %s as default dictionary."), |
| 54 | '<strong>'.htmlspecialchars($dsp_string).'</strong>', |
| 55 | '<strong>'.htmlspecialchars(_($lang_default)).'</strong>') |
| 56 | . '</p>'; |
| 57 | } else { |
| 58 | /** |
| 59 | * Only one dictionary is selected. |
| 60 | */ |
| 61 | $msg = '<p>' |
| 62 | . sprintf(_("Using %s dictionary for spellcheck." ), '<strong>'.htmlspecialchars(_($new_langs[0])).'</strong>') |
| 63 | . '</p>'; |
| 64 | } |
| 65 | |
| 66 | /** save settings */ |
| 67 | sqspell_saveSettings($new_langs); |
| 68 | |
| 69 | sqspell_makePage(_("International Dictionaries Preferences Updated"), |
| 70 | null, $msg); |
| 71 | |
| 72 | /** |
| 73 | * For Emacs weenies: |
| 74 | * Local variables: |
| 75 | * mode: php |
| 76 | * End: |
| 77 | * vim: syntax=php |
| 78 | */ |
| 79 | ?> |