source: tags/start/plugins/admin_language.tcl @ 1143

Revision 2, 2.0 KB checked in by jamesoff, 9 years ago (diff)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1# bMotion: admin plugin file for language mangement
2#
3# $Id$
4#
5
6###############################################################################
7# This is a bMotion plugin
8# Copyright (C) James Michael Seward 2000-2002
9#
10# This program is covered by the GPL, please refer the to LICENCE file in the
11# distribution; further information can be found in the headers of the scripts
12# in the modules directory.
13###############################################################################
14
15proc bMotion_plugin_admin_language { handle idx { arg "" }} {
16  global bMotionSettings
17
18  if [regexp -nocase {remove (.+)} $arg matches lang] {
19    putidx $idx "Removing language $lang...\r"
20    set langs [split $bMotionSettings(languages) ","]
21    set newlangs [list]
22    foreach language $langs {
23      if {$lang != $language} {
24        lappend newlangs $language
25      }
26    }
27    if {[llength $newlangs] == 0} {
28      set newlangs [list "en"]
29    }
30
31    set newlangstring [join $newlangs ","]
32
33    set bMotionSettings(languages) $newlangstring
34
35    putidx $idx "bMotion: new languages are $newlangstring ... rehash to load"
36
37    return 0
38  }
39
40  if [regexp -nocase {add (.+)} $arg matches lang] {
41    putidx $idx "Adding language $lang...\r"
42    append bMotionSettings(languages) ",$lang"
43    putidx $idx "bMotion: new languages are $bMotionSettings(languages) ... rehash to load"
44    return 0
45  }
46
47  if [regexp -nocase {use (.+)} $arg matches lang] {
48    putidx $idx "Switching languages to $lang..."
49    if [regexp $lang $bMotionSettings(languages)] {
50      global bMotionInfo
51      set bMotionInfo(language) $lang
52    } else {
53      putidx $idx "Error! Language $lang not loaded"
54    }
55    return 0
56  }
57
58  #else list langs
59  set langs "bMotion loaded languages: "
60  foreach lang $bMotionSettings(languages) {
61    append langs "$lang  "
62  }
63  global bMotionInfo
64  putidx $idx "$langs\r"
65  putidx $idx "Current language is $bMotionInfo(language)\r"
66}
67
68# register the plugin
69bMotion_plugin_add_admin "lang" "^lang(uage)?" n "bMotion_plugin_admin_language" "any"
Note: See TracBrowser for help on using the repository browser.