Changeset 16480
- Timestamp:
- 05/27/08 23:51:40 (5 months ago)
- Files:
-
- trunk/midcom/midcom.admin.babel/config/manifest.inc (modified) (1 diff)
- trunk/midcom/midcom.admin.babel/documentation/CHANGES (modified) (1 diff)
- trunk/midcom/midcom.admin.babel/handler/process.php (modified) (16 diffs)
- trunk/midcom/midcom.admin.babel/style/midcom_admin_babel_edit.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.admin.babel/config/manifest.inc
r15038 r16480 15 15 'name' => 'Marcin SoÅtysiak', 16 16 'email' => 'olga@olga.pl', 17 'role' => 'lead', 18 ), 19 'adrenalin' => array 20 ( 21 'name' => 'Arttu Manninen', 17 22 'role' => 'lead', 18 23 ), trunk/midcom/midcom.admin.babel/documentation/CHANGES
r12795 r16480 8 8 which might even break existing functionality. 9 9 - All items marked with "+" represent completely new features. 10 11 2008-05-27 adrenalin 12 + Allow the fallback language to be chosen instead of forced English 13 10 14 2007-10-13 solt 11 15 + Moved to Asgard plugin trunk/midcom/midcom.admin.babel/handler/process.php
r14773 r16480 36 36 $this->_l10n = $_MIDCOM->i18n->get_l10n('midcom.admin.babel'); 37 37 $this->_request_data['l10n'] = $this->_l10n; 38 $this->_debug_prefix = "midcom_admin_babel::";38 $this->_debug_prefix = 'midcom_admin_babel::'; 39 39 $this->_save_new = false; 40 40 $this->_save_update = false; 41 42 $this->_fallback_language = $_MIDCOM->i18n->get_fallback_language(); 41 43 42 44 $_MIDCOM->cache->content->no_cache(); … … 49 51 'type' => 'text/css', 50 52 'media' => 'screen', 51 'href' => MIDCOM_STATIC_URL . "/midcom.admin.babel/babel.css"53 'href' => MIDCOM_STATIC_URL .'/midcom.admin.babel/babel.css' 52 54 ) 53 55 ); … … 165 167 } 166 168 167 debug_add("saving data for component ' ".$this->_component_path."', language '".$this->_lang."'", MIDCOM_LOG_DEBUG);169 debug_add("saving data for component '{$this->_component_path}', language '{$this->_lang}'"); 168 170 169 171 $this->_component_l10n = $_MIDCOM->i18n->get_l10n($this->_component_path); 170 172 171 if (array_key_exists("string_id", $_REQUEST)) 172 { 173 $this->_save_update = Array ( 174 "id" => $_REQUEST["string_id"], 175 "value" => $_REQUEST["string_value"] 173 if (array_key_exists('string_id', $_REQUEST)) 174 { 175 $this->_save_update = array 176 ( 177 'id' => $_REQUEST['string_id'], 178 'value' => $_REQUEST['string_value'] 176 179 ); 177 180 } 178 181 179 if ((array_key_exists("new_stringid", $_REQUEST)) && 180 ($_REQUEST["new_stringid"] != "") && 181 (array_key_exists("new_en", $_REQUEST)) && 182 ($_REQUEST["new_en"] != "")) 183 { 184 $this->_save_new = Array ( 185 "stringid" => $_REQUEST["new_stringid"], 186 "en" => $_REQUEST["new_en"] 182 if ( array_key_exists('new_stringid', $_REQUEST) 183 && $_REQUEST['new_stringid'] 184 && array_key_exists('new_fallback', $_REQUEST) 185 && $_REQUEST['new_fallback']) 186 { 187 $this->_save_new = Array 188 ( 189 'stringid' => $_REQUEST['new_stringid'], 190 $this->_fallback_language => $_REQUEST['new_fallback'] 187 191 ); 188 if ((array_key_exists("new_loc", $_REQUEST)) && 189 ($_REQUEST["new_loc"] != "")) 190 { 191 $this->_save_new["loc"] = $_REQUEST["new_loc"]; 192 193 if ( array_key_exists('new_loc', $_REQUEST) 194 && $_REQUEST['new_loc']) 195 { 196 $this->_save_new['loc'] = $_REQUEST['new_loc']; 192 197 } 193 198 } … … 198 203 if ($this->_save_update) 199 204 { 200 debug_add( "Updating strings", MIDCOM_LOG_DEBUG);201 foreach ($this->_save_update[ "id"] as $k => $v)202 { 203 $id = $this->_save_update[ "id"][$k];204 $loc = $this->_save_update[ "value"][$k];205 debug_add('Updating strings', MIDCOM_LOG_DEBUG); 206 foreach ($this->_save_update['id'] as $k => $v) 207 { 208 $id = $this->_save_update['id'][$k]; 209 $loc = $this->_save_update['value'][$k]; 205 210 $origloc = $this->_component_l10n->get($id, $this->_lang); 206 211 … … 209 214 if ($loc == $origloc) 210 215 { 211 debug_add(" '$id' is unchanged, skipping it.");216 debug_add("'{$id}' is unchanged, skipping it."); 212 217 continue; 213 218 } 214 if ($loc == "") 219 220 if (!$loc) 215 221 { 216 debug_add(" Resetting '$id'", MIDCOM_LOG_DEBUG);222 debug_add("Resetting '{$id}'", MIDCOM_LOG_DEBUG); 217 223 $this->_component_l10n->delete($id, $this->_lang); 218 224 $changes = true; … … 220 226 else 221 227 { 222 debug_add(" Updating '$id' -> '$loc'", MIDCOM_LOG_DEBUG);228 debug_add("Updating '{$id}' -> '{$loc}'", MIDCOM_LOG_DEBUG); 223 229 $this->_component_l10n->update($id, $this->_lang, $loc); 224 230 $changes = true; 225 231 } 226 232 } 227 else if ( $loc != "")228 { 229 debug_add(" Creating ' $id' -> '$loc'", MIDCOM_LOG_DEBUG);233 else if (!$loc) 234 { 235 debug_add(" Creating '{$id}' -> '{$loc}'", MIDCOM_LOG_DEBUG); 230 236 $this->_component_l10n->update($id, $this->_lang, $loc); 231 237 $changes = true; … … 233 239 else 234 240 { 235 debug_add(" Ignoring ' $id' -> '$loc'", MIDCOM_LOG_DEBUG);241 debug_add(" Ignoring '{$id}' -> '{$loc}'", MIDCOM_LOG_DEBUG); 236 242 } 237 243 } … … 241 247 if ($this->_save_new) 242 248 { 243 debug_add("Creating new string", MIDCOM_LOG_DEBUG); 244 // create english string 245 $this->_component_l10n->update($this->_save_new["stringid"], "en", $this->_save_new["en"]); 246 // create loc'd string 247 if (array_key_exists("loc", $this->_save_new)) 248 $this->_component_l10n->update($this->_save_new["stringid"], $this->_lang, $this->_save_new["loc"]); 249 debug_add('Creating new string', MIDCOM_LOG_DEBUG); 250 251 // create fallback language string 252 $this->_component_l10n->update($this->_save_new['stringid'], $this->_fallback_language, $this->_save_new[$this->_fallback_language]); 253 254 // create loc'd string 255 if (array_key_exists('loc', $this->_save_new)) 256 { 257 $this->_component_l10n->update($this->_save_new['stringid'], $this->_lang, $this->_save_new['loc']); 258 } 249 259 250 260 $changes = true; … … 253 263 if ($changes) 254 264 { 255 debug_add( "Changes have been made, Flushing to disk now.");265 debug_add('Changes have been made, Flushing to disk now.'); 256 266 $this->_component_l10n->flush(); 257 267 } … … 322 332 $data['section'] = 'core'; 323 333 midcom_show_style('midcom_admin_babel_status_section_header'); 334 324 335 foreach ($data['components_core'] as $component => $string_counts) 325 336 { … … 328 339 midcom_show_style('midcom_admin_babel_status_item'); 329 340 } 341 330 342 midcom_show_style('midcom_admin_babel_status_section_footer'); 331 343 332 344 $data['section'] = 'other'; 333 345 midcom_show_style('midcom_admin_babel_status_section_header'); 346 334 347 foreach ($data['components_other'] as $component => $string_counts) 335 348 { … … 338 351 midcom_show_style('midcom_admin_babel_status_item'); 339 352 } 353 340 354 midcom_show_style('midcom_admin_babel_status_section_footer'); 341 355 … … 359 373 } 360 374 361 debug_push($this->_debug_prefix . "handle");375 debug_push($this->_debug_prefix . 'handle'); 362 376 363 377 // make sure text is displayed as utf-8 => REALLY? 364 //header( "Content-type: text/html; charset=UTF-8");378 //header('Content-type: text/html; charset=UTF-8'); 365 379 366 380 if ( $this->_component_path 367 381 && $this->_lang) 368 382 { 369 debug_add( "Loading i10n class for ".$this->_component_path, MIDCOM_LOG_DEBUG);383 debug_add('Loading i10n class for '.$this->_component_path, MIDCOM_LOG_DEBUG); 370 384 if (!$this->_component_l10n = $_MIDCOM->i18n->get_l10n($this->_component_path)) 371 385 { … … 426 440 $view_strings[$id] = array 427 441 ( 428 'en' => $this->_component_l10n->get($id, 'en'),442 $this->_fallback_language => $this->_component_l10n->get($id, $this->_fallback_language), 429 443 $this->_lang => $loc 430 444 ); … … 449 463 function _show_permission_check($handler_id, &$data) 450 464 { 451 if ($this->_component_path == "midcom")465 if ($this->_component_path == 'midcom') 452 466 { 453 467 $path = MIDCOM_ROOT . '/midcom/locale'; … … 455 469 else 456 470 { 457 $path = MIDCOM_ROOT . '/' . str_replace(".", "/", $this->_component_path) . '/locale'; 458 } 459 $en = "{$path}/default.en.txt"; 471 $path = MIDCOM_ROOT . '/' . str_replace('.', '/', $this->_component_path) . '/locale'; 472 } 473 474 $fallback = "{$path}/default.{$this->_fallback_language}.txt"; 460 475 $main = "{$path}/default.{$this->_lang}.txt"; 461 476 462 if ( ! is_writable($path) 463 || (file_exists($en) && ! is_writable($en)) 464 || (file_exists($main) && ! is_writable($main))) 477 if ( !is_writable($path) 478 || ( file_exists($fallback) 479 && ! is_writable($fallback)) 480 || ( file_exists($main) 481 && ! is_writable($main))) 465 482 { 466 483 midcom_show_style('midcom_admin_babel_permission_denied'); 467 484 } 468 485 } 469 470 471 472 486 } 473 474 487 ?> trunk/midcom/midcom.admin.babel/style/midcom_admin_babel_edit.php
r12850 r16480 9 9 asort($components); 10 10 11 $fallback_language = $_MIDCOM->i18n->get_fallback_language(); 11 12 $deflang = $languages[$_MIDCOM->i18n->get_fallback_language()]['enname']; 12 13 $editlang = $languages[$data['view_lang']]['enname']; … … 29 30 <th>&(deflang); (<?php echo $data['l10n']->get('default');?>)</th> 30 31 <?php 31 if ($data['view_lang'] != 'en')32 if ($data['view_lang'] !== $fallback_language) 32 33 { 33 34 ?> … … 43 44 <tr class="newstring"> 44 45 <td><?php echo $data['l10n']->get('new string')?><br /><input type="text" name="new_stringid" size="35" /></td> 45 <td><textarea type="text" name="new_ en" cols="30" rows="3" wrap="virtual"></textarea></td>46 <td><textarea type="text" name="new_fallback" cols="30" rows="3" wrap="virtual"></textarea></td> 46 47 <?php 47 if ($data['view_lang'] != 'en')48 if ($data['view_lang'] !== $fallback_language) 48 49 { 49 50 ?> … … 58 59 foreach ($data['view_strings'] as $id => $str) 59 60 { 60 $ en = $str['en'];61 $fallback = $str[$fallback_language]; 61 62 $loc = $str[$data['view_lang']]; 62 $row = ($count/2 == floor($count/2))?"even":"odd"; 63 64 if ($count % 2 === 0) 65 { 66 $row = 'even'; 67 } 68 else 69 { 70 $row = 'odd'; 71 } 63 72 ?> 64 73 <tr class="string-&(row);"> 65 74 <th>&(id);</th> 66 75 <?php 67 if ($data['view_lang'] != 'en')76 if ($data['view_lang'] !== $fallback_language) 68 77 { 69 78 ?> 70 <td><span>&( en);</span></td>79 <td><span>&(fallback);</span></td> 71 80 <?php 72 81 }
