Czech translation

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@37 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2007-07-05 10:46:44 +00:00
parent aeee74d7c7
commit 7418af0caa
6 changed files with 161 additions and 13 deletions

View file

@ -1,7 +1,7 @@
<?php
function remove_lang($match) {
global $LANG;
return lang(strtr($match[2], array("\\'" => "'", "\\\\" => "\\")));
$s = lang(strtr($match[2], array("\\'" => "'", "\\\\" => "\\")));
return ($match[1] && $match[3] ? $s : "$match[1]'" . addcslashes($s, "\\'") . "'$match[3]");
}
function put_file($match) {
@ -18,16 +18,25 @@ function put_file($match) {
}
error_reporting(E_ALL & ~E_NOTICE);
if ($_SERVER["argc"] > 1) {
include "./lang.inc.php";
if ($_SERVER["argc"] != 2 || !in_array($_SERVER["argv"][1], lang())) {
echo lang('Usage: php _compile.php [lang]') . "\n" . lang('Purpose: Compile phpMinAdmin[-lang].php from index.php.') . "\n";
exit(1);
}
$_SESSION["lang"] = $_SERVER["argv"][1];
}
$filename = "phpMinAdmin.php";
$file = file_get_contents("index.php");
$LANG = (strlen($_SERVER["argv"][1]) == 2 ? $_SERVER["argv"][1] : "");
if ($LANG) {
if ($_SESSION["lang"]) {
$filename = "phpMinAdmin-$_SESSION[lang].php";
$file = str_replace("include \"./lang.inc.php\";\n", "", $file);
}
$file = preg_replace_callback('~(<\\?php\\s*)?(include|require)(_once)? "([^"]*)";(\\s*\\?>)?~', 'put_file', $file);
if ($LANG) {
include "./lang.inc.php";
preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']*|\\\\.)+)'\\)(;\\s*\\?>)?~s", 'remove_lang', $file);
if ($_SESSION["lang"]) {
$file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']*|\\\\.)+)'\\)(;\\s*\\?>)?~s", 'remove_lang', $file);
$file = str_replace("<?php switch_lang(); ?>\n", "", $file);
}
//! remove spaces and comments
file_put_contents("phpMinAdmin" . ($LANG ? "-$LANG" : "") . ".php", $file);
echo "phpMinAdmin.php created.\n";
file_put_contents($filename, $file);
echo "$filename created.\n";

32
_lang.php Normal file
View file

@ -0,0 +1,32 @@
<?php
if ($_SERVER["argc"] > 1) {
echo "Usage: php _lang.php\nPurpose: Update lang.inc.php from source code messages.\n";
exit(1);
}
$messages = array();
foreach (glob("*.php") as $filename) {
$file = file_get_contents($filename);
preg_match_all("~lang\\(('(?:[^\\\\']*|\\\\.)+')\\)~s", $file, $matches);
$messages += array_flip($matches[1]);
}
$file = file_get_contents("lang.inc.php");
preg_match_all("~\n\t\t'.*' => array\\(\n(.*\n)\t\t\\)~sU", $file, $translations, PREG_OFFSET_CAPTURE);
foreach ($translations[1] as $translation) {
preg_match_all("~^(\\s*(?:// )?)(('(?:[^\\\\']*|\\\\.)+') => .*[^,\n]),?~m", $translation[0], $matches, PREG_SET_ORDER);
$s = "";
foreach ($matches as $match) {
if (isset($messages[$match[3]])) {
$s .= "$match[1]$match[2],\n";
unset($messages[$match[3]]);
} else {
$s .= "$match[1]// $match[2],\n";
}
}
foreach($messages as $key => $val) {
$s .= "\t\t\t$key => '',\n";
}
$file = substr_replace($file, $s, $translation[1], strlen($translation[0]));
}
file_put_contents("lang.inc.php", $file);

View file

@ -23,7 +23,7 @@ if (isset($_GET["logout"]) || !@mysql_connect($_GET["server"], $_SESSION["userna
<form action="" method="post">
<table border="0" cellspacing="0" cellpadding="2">
<tr><th><?php echo lang('Server'); ?>:</th><td><input name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>" maxlength="60" /></td></tr>
<tr><th><?php echo lang('Login'); ?>:</th><td><input name="username" value="<?php echo htmlspecialchars($_SESSION["username"]); ?>" maxlength="16" /></td></tr>
<tr><th><?php echo lang('Username'); ?>:</th><td><input name="username" value="<?php echo htmlspecialchars($_SESSION["username"]); ?>" maxlength="16" /></td></tr>
<tr><th><?php echo lang('Password'); ?>:</th><td><input type="password" name="password" /></td></tr>
<tr><th><?php
foreach ($_POST as $key => $val) { // expired session

View file

@ -29,6 +29,7 @@ H2 { font-size: 150%; margin-top: 0; }
?>
<div id="menu">
<h1><a href="<?php echo htmlspecialchars(substr($SELF, 0, -1)); ?>"><?php echo lang('phpMinAdmin'); ?></a></h1>
<?php switch_lang(); ?>
<p>
<a href="<?php echo htmlspecialchars($SELF); ?>sql="><?php echo lang('SQL command'); ?></a>
<a href="<?php echo htmlspecialchars($SELF); ?>dump="><?php echo lang('Dump'); ?></a>

View file

@ -1,4 +1,110 @@
<?php
function lang($idf) {
return $idf;
function lang($idf = null) {
static $translation = array(
'en' => array(),
'cs' => array(
'Usage: php _compile.php [lang]' => 'Použití: php _compile.php [jazyk]',
'Purpose: Compile phpMinAdmin[-lang].php from index.php.' => 'Účel: Zkompilovat phpMinAdmin[-jazyk].php z index.php.',
'Login' => 'Přihlásit se',
'phpMinAdmin' => 'phpMinAdmin',
'Logout successful.' => 'Odhlášení proběhlo v pořádku.',
'Invalid credentials.' => 'Neplatné přihlašovací údaje.',
'Server' => 'Server',
'Username' => 'Uživatel',
'Password' => 'Heslo',
'Select database' => 'Vybrat databáze',
'Invalid database.' => 'Nesprávná databáze.',
'Create new database' => 'Vytvořit novou databázi',
'Table has been dropped.' => 'Tabulka byla odstraněna.',
'Table has been altered.' => 'Tabulka byla změněna.',
'Table has been created.' => 'Tabulka byla vytvořena.',
'Alter table' => 'Změnit tabulku',
'Create table' => 'Vytvořit tabulku',
'Unable to operate table' => 'Nepodařilo se zpracovat tabulku',
'Table name' => 'Název tabulky',
'engine' => 'typ tabulky',
'collation' => 'porovnávání',
'Name' => 'Název',
'Type' => 'Typ',
'Length' => 'Délka',
'NULL' => 'NULL',
'Auto-increment' => 'Auto-increment',
'Add row' => 'Přidat řádek',
'Save' => 'Uložit',
'Drop' => 'Odstranit',
'Database has been dropped.' => 'Databáze byla odstraněna.',
'Database has been created.' => 'Databáze byla vytvořena.',
'Database has been renamed.' => 'Databáze byla přejmenována.',
'Database has been altered.' => 'Databáze byla změněna.',
'Alter database' => 'Změnit databázi',
'Create database' => 'Vytvořit databázi',
'Unable to operate database' => 'Nepodařilo se zpracovat databázi',
'SQL command' => 'SQL příkaz',
'Dump' => 'Export',
'Logout' => 'Odhlásit',
'database' => 'databáze',
'Use' => 'Vybrat',
'No tables.' => 'Žádné tabulky.',
'select' => 'vypsat',
'Create new table' => 'Vytvořit novou tabulku',
'Item has been deleted.' => 'Položka byla smazána.',
'Item has been updated.' => 'Položka byla aktualizována.',
'Item has been inserted.' => 'Položka byla vložena.',
'Edit' => 'Upravit',
'Insert' => 'Vložit',
'Error during saving' => 'Chyba při ukládání',
'Save and insert' => 'Uložit a vložit',
'Delete' => 'Smazat',
'Database' => 'Databáze',
'Routines' => 'Procedury',
'Indexes has been altered.' => 'Indexy byly změněny.',
'Indexes' => 'Indexy',
'Unable to operate indexes' => 'Nepodařilo se zpracovat indexy',
'Alter indexes' => 'Nastavit indexy',
'Language' => 'Jazyk',
'Select' => 'Vypsat',
'New item' => 'Nová položka',
'Search' => 'Vyhledat',
'No rows.' => 'Žádné řádky.',
'Action' => 'Akce',
'edit' => 'upravit',
'Page' => 'Stránka',
'Query executed OK, %d row(s) affected.' => 'Příkaz proběhl v pořádku, bylo změněno %d záznam(ů).',
'Error in query' => 'Chyba v dotazu',
'Execute' => 'Provést',
'Table' => 'Tabulka',
'Foreign keys' => 'Cizí klíče',
'Triggers' => 'Spouště',
'View' => 'Pohled',
),
);
if (!isset($idf)) {
return array_keys($translation);
}
if (strlen($_SESSION["lang"])) {
$lang = $_SESSION["lang"];
} else {
$lang = preg_replace('~[,;].*~', '', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
if (!isset($langs[$lang])) { //! try next languages
$lang = preg_replace('~-.*~', '', $lang);
if (!isset($langs[$lang])) {
$lang = "en";
}
}
}
$return = $translation[$lang][$idf];
return (strlen($return) ? $return : $idf);
}
function switch_lang() {
echo "<p>" . lang('Language') . ":";
$base = preg_replace('~(\\?)lang=[^&]*&|[&?]lang=[^&]*~', '', $_SERVER["REQUEST_URI"]);
foreach (lang() as $lang) {
echo ' <a href="' . htmlspecialchars($base . (strpos($base, "?") !== false ? "&" : "?")) . "lang=$lang\">$lang</a>";
}
echo "</p>\n";
}
if (isset($_GET["lang"])) {
$_SESSION["lang"] = $_GET["lang"];
}

View file

@ -86,7 +86,7 @@ if (!mysql_num_rows($result)) {
}
echo "<td>$val</td>";
}
echo '<td><a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . implode('&amp;', unique_idf($row, $indexes)) . '">edit</a>'; //! views can be unupdatable
echo '<td><a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . implode('&amp;', unique_idf($row, $indexes)) . '">' . lang('edit') . '</a>'; //! views can be unupdatable
foreach ($childs as $child) {
echo ' <a href="' . htmlspecialchars(strlen($child[0]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($child[0]), $SELF) : $SELF) . 'select=' . urlencode($child[1]);
foreach ($child[2] as $i => $source) {