예제 #1
0
    /**
     * Get a list of all files matching the pattern given.
     * Return an array of strings, each the full path name of a file.
     * @param string $p_startdir
     * @param string $p_pattern
     * @return array
     */
    public static function SearchFilesRecursive($p_startdir, $p_pattern)
    {
        $structure = File_Find::mapTreeMultiple($p_startdir);

        // Transform it into a flat structure.
        $filelist = array();
        foreach ($structure as $dir => $file) {
        	// it's a directory
            if (is_array($file)) {
                $filelist = array_merge($filelist,
                    Localizer::SearchFilesRecursive($p_startdir.'/'.$dir, $p_pattern));
            } else {
            	// it's a file
                if (preg_match($p_pattern, $file)) {
                    $filelist[] = $p_startdir.'/'.$file;
                }
            }
        }
        return $filelist;
    } // fn SearchFilesRecursive
예제 #2
0
<?PHP
require_once('../../management/localizer/Localizer.php');

global $g_localizerConfig;
$languages = Localizer::GetAllLanguages('gs');
//echo "<pre>";
//print_r($languages);
//echo "</pre>";

// recursive convert GS-files to XML-files on filesystem
$startdir = $g_localizerConfig['BASE_DIR'];
$pattern  = '/^(locals|globals)\.[a-z]{2,2}\.php$/';
$sep = "|";
$list = Localizer::SearchFilesRecursive($startdir, $pattern, $sep);
$list = explode($sep, $list);

echo "Converting translation files...";
$count = 0;
$allLanguageIds = array();

// Go through all the files
foreach ($list as $pathname) {
    if ($pathname) {
    	// Get the relative path name from server_root
        $pathname = str_replace($startdir, '', $pathname);
        $filenameParts = explode('.', basename($pathname));
        // prefix will be 'locals' or 'globals'
        $prefix = $filenameParts[0];
		$directory = dirname($pathname);

		// Find the language that matches this file.