Dotclear

Changeset 1036:4374df1baa97


Ignore:
Timestamp:
11/26/12 13:27:11 (13 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add capability to edit locales files for theme editor plugin

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • locales/fr/plugins.po

    r1011 r1036  
    16211621msgstr "Fichiers JavaScript" 
    16221622 
     1623msgid "Locales files" 
     1624msgstr "Fichiers de traduction" 
     1625 
    16231626msgid "user:preferences" 
    16241627msgstr "user:preferences" 
  • plugins/themeEditor/class.themeEditor.php

    r270 r1036  
    2424     public $css = array(); 
    2525     public $js  = array(); 
     26     public $po  = array(); 
    2627      
    2728     public function __construct($core) 
     
    3940          $this->findStyles(); 
    4041          $this->findScripts(); 
     42          $this->findLocales(); 
    4143     } 
    4244      
     
    106108               } 
    107109                
     110               if ($type == 'po' && !is_dir(dirname($dest))) { 
     111                    files::makeDir(dirname($dest)); 
     112               } 
     113                
    108114               $fp = @fopen($dest,'wb'); 
    109115               if (!$fp) { 
     
    130136          if ($type == 'tpl') { 
    131137               $dest = $this->user_theme.'/tpl/'.$f; 
     138          } elseif ($type == 'po') { 
     139               $dest = $this->user_theme.'/locales/'.$f; 
    132140          } else { 
    133141               $dest = $this->user_theme.'/'.$f; 
     
    143151               } 
    144152          } 
    145            
     153 
     154          if ($type == 'po' && !is_dir(dirname($dest))) { 
     155               if (is_writable($this->user_theme)) { 
     156                    return $dest; 
     157               } 
     158          } 
     159 
    146160          if (is_writable(dirname($dest))) { 
    147161               return $dest; 
     
    161175               case 'js': 
    162176                    return $this->js; 
     177               case 'po': 
     178                    return $this->po; 
    163179               default: 
    164180                    return array(); 
     
    178194               case 'js': 
    179195                    $list =& $this->js; 
     196                    break; 
     197               case 'po': 
     198                    $list =& $this->po; 
    180199                    break; 
    181200               default: 
     
    219238     } 
    220239      
     240     protected function findLocales() 
     241     { 
     242          $langs = l10n::getISOcodes(1,1); 
     243          foreach ($langs as $k => $v) { 
     244               if ($this->parent_theme) { 
     245                    $this->po = array_merge($this->po,$this->getFilesInDir($this->parent_theme.'/locales/'.$v,'po',$v.'/')); 
     246               } 
     247               $this->po = array_merge($this->po,$this->getFilesInDir($this->user_theme.'/locales/'.$v,'po',$v.'/')); 
     248          } 
     249     } 
     250      
    221251     protected function getFilesInDir($dir,$ext=null,$prefix='') 
    222252     { 
  • plugins/themeEditor/index.php

    r997 r1036  
    3636          } elseif (!empty($_REQUEST['js'])) { 
    3737               $file = $o->getFileContent('js',$_REQUEST['js']); 
     38          } elseif (!empty($_REQUEST['po'])) { 
     39               $file = $o->getFileContent('po',$_REQUEST['po']); 
    3840          } 
    3941     } 
     
    126128 
    127129     if ($user_ui_colorsyntax) { 
    128           $editorMode = (!empty($_REQUEST['css']) ? "css" : (!empty($_REQUEST['js']) ? "javascript" : "text/html")); 
     130          $editorMode =  
     131               (!empty($_REQUEST['css']) ? "css" : 
     132               (!empty($_REQUEST['js']) ? "javascript" : 
     133               (!empty($_REQUEST['po']) ? "text/plain" : "text/html"))); 
    129134          echo  
    130135          '<script> 
     
    166171<h3><?php echo __('JavaScript files'); ?></h3> 
    167172<?php echo $o->filesList('js','<a href="'.$p_url.'&amp;js=%2$s" class="js-link">%1$s</a>'); ?> 
     173 
     174<h3><?php echo __('Locales files'); ?></h3> 
     175<?php echo $o->filesList('po','<a href="'.$p_url.'&amp;po=%2$s" class="po-link">%1$s</a>'); ?> 
    168176</div> 
    169177 
Note: See TracChangeset for help on using the changeset viewer.

Sites map