lang_change.mod 2.0 KB

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