diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2003-11-01 11:53:13 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2003-11-01 11:53:13 +0000 |
commit | cee7de8e1a6a3ba8aa776c22dea10d183d03dd00 (patch) | |
tree | 8c77d1d4d745ec0a74a89abaffce0633f4f2675a | |
parent | 41d8e55409110befa2f978aac98414c5f2ef6655 (diff) | |
download | forums-cee7de8e1a6a3ba8aa776c22dea10d183d03dd00.tar forums-cee7de8e1a6a3ba8aa776c22dea10d183d03dd00.tar.gz forums-cee7de8e1a6a3ba8aa776c22dea10d183d03dd00.tar.bz2 forums-cee7de8e1a6a3ba8aa776c22dea10d183d03dd00.tar.xz forums-cee7de8e1a6a3ba8aa776c22dea10d183d03dd00.zip |
a lot of handwork is still required...
git-svn-id: file:///svn/phpbb/trunk@4629 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/develop/create_variable_overview.php | 9 | ||||
-rw-r--r-- | phpBB/develop/write_lang_files.php | 132 |
2 files changed, 140 insertions, 1 deletions
diff --git a/phpBB/develop/create_variable_overview.php b/phpBB/develop/create_variable_overview.php index 7787812e37..8337004c30 100644 --- a/phpBB/develop/create_variable_overview.php +++ b/phpBB/develop/create_variable_overview.php @@ -30,6 +30,13 @@ $ext = 'html'; $store_dir = '../store/'; $phpfiles_directories = array('../', '../includes/', '../includes/acm/', '../includes/auth/', '../includes/mcp/', '../includes/ucp/'); +// Template Files beginning with this names are merged together +$merge = array('gcp', 'login', 'mcp', 'memberlist', 'posting', 'ucp'); + +if (!is_writable($store_dir)) +{ + die("Directory $store_dir is not writeable!"); +} $contents = implode('', file('../adm/subSilver.css', filesize('../adm/subSilver.css'))); $fp = fopen($store_dir . 'subSilver.css', 'w'); @@ -88,6 +95,7 @@ $html_skeleton .= ' // Open Language File include('../language/en/lang_main.php'); +include('../language/en/lang_admin.php'); $files_to_parse = $php_files = array(); @@ -413,7 +421,6 @@ fclose($fp); // Not only write down all language files, place them into a specific array, named by the template file // All Language vars assigned to more than one template will be placed into a common file $entry = array(); -$merge = array('gcp', 'login', 'mcp', 'memberlist', 'posting', 'ucp'); $common_fp = fopen($store_dir . 'lang_common.php', 'w'); fwrite($common_fp, "<?php\n\n \$lang = array(\n"); diff --git a/phpBB/develop/write_lang_files.php b/phpBB/develop/write_lang_files.php new file mode 100644 index 0000000000..31bea2279d --- /dev/null +++ b/phpBB/develop/write_lang_files.php @@ -0,0 +1,132 @@ +<?php +// ------------------------------------------------------------- +// +// $Id$ +// +// FILENAME : write_lang_files.php +// STARTED : Sat Nov 01 2003 +// COPYRIGHT : © 2003 phpBB Group +// WWW : http://www.phpbb.com/ +// LICENCE : GPL vs2.0 [ see /docs/COPYING ] +// +// ------------------------------------------------------------- + +/* + This script writes down all $user->lang occurrences used by php files. +*/ + +// +// Security message: +// +// This script is potentially dangerous. +// Remove or comment the next line (die(".... ) to enable this script. +// Do NOT FORGET to either remove this script or disable it after you have used it. +// +die("Please read the first lines of this script for instructions on how to enable it"); + +$phpfiles_directories = array('../', '../includes/', '../includes/acm/', '../includes/auth/', '../includes/mcp/', '../includes/ucp/'); +$ext = 'php'; +$store_dir = '../store/main/'; + +if (!is_writable($store_dir)) +{ + die("Directory $store_dir is not writeable!"); +} + +// Open Language File +include('../language/en/lang_main.php'); +include('../language/en/lang_admin.php'); + +$files_to_parse = $php_files = array(); + +$num = 0; +foreach ($phpfiles_directories as $directory) +{ + $dhandler = opendir($directory); + if (!$dhandler) + { + die("Unable to open $directory"); + } + + while ($file = readdir($dhandler)) + { + if (is_file($directory . $file) && preg_match('#\.php$#i', $file)) + { + $php_files[$num]['filename'] = $directory . $file; + $php_files[$num]['single_filename'] = $file; + $num++; + } + } + closedir($dhandler); +} + +echo '<br>Parsing PHP Files'; + +$dependency = array(); + +// Parse PHP Files and get our filenames +foreach ($php_files as $file_num => $data) +{ + echo '.'; + flush(); + $contents = implode('', file($data['filename'], filesize($data['filename']))); + + $lang_entries = array(); + preg_match_all('#' . preg_quote('$user->lang[\'') . '([A-Za-z0-9\-_]*?)' . preg_quote("']") . '#s', $contents, $lang_entries); + $php_files[$file_num]['lang_entries'] = array_unique($lang_entries[1]); + foreach ($php_files[$file_num]['lang_entries'] as $var) + { + $dependency[$var][] = $data['single_filename']; + } +} + +// Not only write down all language files, place them into a specific array, named by the template file +// All Language vars assigned to more than one template will be placed into a common file +$entry = array(); +$merge = array('ucp', 'mcp', 'functions'); +$common_fp = fopen($store_dir . 'lang_common.php', 'w'); +fwrite($common_fp, "<?php\n\n \$lang = array(\n"); + +echo '<br>Write Language Files'; + +asort($dependency); +ksort($dependency); + +foreach ($dependency as $lang_var => $filenames) +{ + $var = $lang_var; + + if (sizeof($filenames) != 1) + { + fwrite($common_fp, (($entry['common']) ? ",\n" : '') . "\t'$var' => '" . $lang[$var] . "'"); + $entry['common'] = true; + } + else if (sizeof($filenames) == 1) + { + // Merge logical - hardcoded + $fname = (preg_match('#^(' . implode('|', $merge) . ')#', $filenames[0], $match)) ? $match[0] . '.php' : $filenames[0]; + + if (!$lang_fp[$fname]) + { + $lang_fp[$fname] = fopen($store_dir . 'lang_' . $fname, 'w'); + fwrite($lang_fp[$fname], "<?php\n\n\$lang = array(\n"); + $entry[$fname] = false; + } + fwrite($lang_fp[$fname], (($entry[$fname]) ? ",\n" : '') . "\t'$var' => '" . $lang[$var] . "'"); + $entry[$fname] = true; + } +} + +fwrite($common_fp, ")\n);\n?>"); +fclose($common_fp); + +foreach ($lang_fp as $filepointer) +{ + fwrite($filepointer, ")\n);\n?>"); + fclose($filepointer); +} + +echo '<br>Finished!'; +flush(); + +?>
\ No newline at end of file |