Skip to content
This repository
Browse code

always set the current language in the session

  • Loading branch information...
commit 34591120382526d245bea04fea65e5791cb1b355 1 parent c819604
Dominik Eckelmann authored January 07, 2013

Showing 1 changed file with 12 additions and 5 deletions. Show diff stats Hide diff stats

  1. 17  action.php
17  action.php
@@ -34,9 +34,8 @@ function action_plugin_translation(){
34 34
      */
35 35
     function register(&$controller) {
36 36
         // should the lang be applied to UI?
  37
+        $scriptName = basename($_SERVER['PHP_SELF']);
37 38
         if($this->getConf('translateui')){
38  
-            $scriptName = basename($_SERVER['PHP_SELF']);
39  
-
40 39
             switch ($scriptName) {
41 40
                 case 'js.php':
42 41
                     $controller->register_hook('INIT_LANG_LOAD', 'BEFORE', $this, 'translation_js');
@@ -48,15 +47,19 @@ function register(&$controller) {
48 47
                     break;
49 48
 
50 49
                 case 'mediamanager.php':
51  
-                    $controller->register_hook('MEDIAMANAGER_STARTED', 'BEFORE', $this, 'translation_hook');
52 50
                     $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'setJsCacheKey');
53 51
                     break;
54 52
 
55 53
                 default:
56  
-                    $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'translation_hook');
57 54
                     $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'setJsCacheKey');
58 55
             }
59 56
         }
  57
+
  58
+        if ($scriptName !== 'js.php' && $scriptName !== 'ajax.php') {
  59
+            $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'translation_hook');
  60
+            $controller->register_hook('MEDIAMANAGER_STARTED', 'BEFORE', $this, 'translation_hook');
  61
+        }
  62
+
60 63
         $controller->register_hook('SEARCH_QUERY_PAGELOOKUP', 'AFTER', $this, 'translation_search');
61 64
     }
62 65
 
@@ -132,13 +135,17 @@ function translation_hook(&$event, $args) {
132 135
         }
133 136
         if(!$lc) $lc = $_SESSION[DOKU_COOKIE]['translationlc'];
134 137
         if(!$lc) return;
  138
+        $this->locale = $lc;
  139
+
  140
+        if (!$this->getConf('translateui')) {
  141
+            return true;
  142
+        }
135 143
 
136 144
         if(file_exists(DOKU_INC.'inc/lang/'.$lc.'/lang.php')) {
137 145
           require(DOKU_INC.'inc/lang/'.$lc.'/lang.php');
138 146
         }
139 147
         $conf['lang_before_translation'] = $conf['lang']; //store for later access in syntax plugin
140 148
         $conf['lang'] = $lc;
141  
-        $this->locale = $lc;
142 149
 
143 150
         return true;
144 151
     }

0 notes on commit 3459112

Please sign in to comment.
Something went wrong with that request. Please try again.