source: trunk/plugins/admin_language.tcl @ 1143

Revision 461, 2.5 KB checked in by simsea, 8 years ago (diff)

language pack framework stuff
/me prays it doesn't break everything

  • 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_management_language { handle { arg "" }} {
16  global bMotionSettings
17  global bMotionInfo
18
19  if [regexp -nocase {remove (.+)} $arg matches lang] {
20    if { $lang == $bMotionInfo(language) } {
21      bMotion_putadmin "Cannot remove current language"
22      return 0
23    }
24    bMotion_putadmin "Removing language $lang..."
25    set langs [split $bMotionSettings(languages) ","]
26    set newlangs [list]
27    foreach language $langs {
28      if {$lang != $language} {
29        lappend newlangs $language
30      }
31    }
32    if {[llength $newlangs] == 0} {
33      set newlangs [list "en"]
34    }
35
36    set newlangstring [join $newlangs ","]
37
38    set bMotionSettings(languages) $newlangstring
39
40    bMotion_putadmin "bMotion: new languages are $newlangstring ... rehash to load"
41
42    return 0
43  }
44
45  if [regexp -nocase {add (.+)} $arg matches lang] {
46    set langs [split $bMotionSettings(languages) ","]
47    foreach language $langs {
48      if {$lang == $language} {
49        bMotion_putadmin "Cannot add language already in list"
50        return 0
51      }
52    }
53    bMotion_putadmin "Adding language $lang..."
54    append bMotionSettings(languages) ",$lang"
55    bMotion_putadmin "bMotion: new languages are $bMotionSettings(languages) ... rehash to load"
56    return 0
57  }
58
59  if [regexp -nocase {use (.+)} $arg matches lang] {
60    bMotion_putadmin "Switching languages to $lang..."
61    if [regexp $lang $bMotionSettings(languages)] {
62      # step 1: flush the abstracts
63      bMotion_abstract_flush
64      # step 2: change the language in info
65      set bMotionInfo(language) $lang
66      # step 3: load the new abstracts
67      bMotion_abstract_revive_language
68    } else {
69      bMotion_putadmin "Error! Language $lang not loaded"
70    }
71    return 0
72  }
73
74  #else list langs
75  set langs "bMotion loaded languages: "
76  foreach lang $bMotionSettings(languages) {
77    append langs "$lang  "
78  }
79  global bMotionInfo
80  bMotion_putadmin "$langs"
81  bMotion_putadmin "Current language is $bMotionInfo(language)"
82}
83
84# register the plugin
85bMotion_plugin_add_management "lang" "^lang(uage)?" n "bMotion_plugin_management_language" "any"
Note: See TracBrowser for help on using the repository browser.