lang_change.mod 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * lang_change.mod
  4. * ----------------
  5. * Squirrelspell module
  6. *
  7. * Copyright (c) 1999-2002 The SquirrelMail development 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. * $Id$
  14. *
  15. * @author Konstantin Riabitsev <icon@duke.edu> ($Author$)
  16. * @version $Date$
  17. */
  18. global $use_langs, $lang_default, $SQSPELL_APP_DEFAULT;
  19. $words = sqspell_getWords();
  20. if (!$words) {
  21. $words = sqspell_makeDummy();
  22. }
  23. $langs = sqspell_getSettings($words);
  24. if (sizeof($use_langs)){
  25. /**
  26. * See if the user clicked any options on the previous page.
  27. */
  28. if (sizeof($use_langs)>1){
  29. /**
  30. * See if s/he wants more than one dictionary.
  31. */
  32. if ($use_langs[0]!=$lang_default){
  33. /**
  34. * See if we need to juggle the order of the dictionaries
  35. * to make the default dictionary first in line.
  36. */
  37. if (in_array($lang_default, $use_langs)){
  38. /**
  39. * See if the user was dumb and chose a default dictionary
  40. * to be something other than the ones he selected.
  41. */
  42. $hold = array_shift($use_langs);
  43. $lang_string = join(", ", $use_langs);
  44. $lang_string = str_replace("$lang_default", "$hold", $lang_string);
  45. $lang_string = $lang_default . ", " . $lang_string;
  46. } else {
  47. /**
  48. * Yes, he is dumb.
  49. */
  50. $lang_string = join(', ', $use_langs);
  51. }
  52. } else {
  53. /**
  54. * No need to juggle the order -- preferred is already first.
  55. */
  56. $lang_string = join(', ', $use_langs);
  57. }
  58. } else {
  59. /**
  60. * Just one dictionary, please.
  61. */
  62. $lang_string = $use_langs[0];
  63. }
  64. $lang_array = explode( ',', $lang_string );
  65. $dsp_string = '';
  66. foreach( $lang_array as $a) {
  67. $dsp_string .= _(trim($a)) . ', ';
  68. }
  69. $dsp_string = substr( $dsp_string, 0, -2 );
  70. $msg = '<p>'
  71. . sprintf(_("Settings adjusted to: <strong>%s</strong> with <strong>%s</strong> as default dictionary."), $dsp_string, _($lang_default))
  72. . '</p>';
  73. } else {
  74. /**
  75. * No dictionaries selected. Use system default.
  76. */
  77. $msg = '<p>'
  78. . sprintf(_("Using <strong>%s</strong> dictionary (system default) for spellcheck." ), $SQSPELL_APP_DEFAULT)
  79. . '</p>';
  80. $lang_string = $SQSPELL_APP_DEFAULT;
  81. }
  82. $old_lang_string = join(", ", $langs);
  83. $words = str_replace("# LANG: $old_lang_string", "# LANG: $lang_string",
  84. $words);
  85. /**
  86. * Write it down where the sun don't shine.
  87. */
  88. sqspell_writeWords($words);
  89. sqspell_makePage(_("International Dictionaries Preferences Updated"),
  90. null, $msg);
  91. /**
  92. * For Emacs weenies:
  93. * Local variables:
  94. * mode: php
  95. * End:
  96. */
  97. ?>