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