From 52a1d1bbe80422ca7a8c79dde6fd92db542b9b2d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 17 Feb 2001 12:59:24 +0000 Subject: - More updates on the translation support --- modules/locale/locale.module | 89 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 7 deletions(-) (limited to 'modules/locale') diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 95594a65a..8a1c3e1ac 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -1,17 +1,92 @@ "locale", - "admin" => "locale"); +$module = array("help" => "locale_help", + "admin" => "locale_admin", + "locale" => "locale_locale"); -function locale() { - $result = db_query("SELECT * FROM locales ORDER BY english"); +function locale_help() { + print "under construction"; +} + +function locale_delete($id) { + db_query("DELETE FROM locales WHERE id = '$id'"); +} + +function locale_save($id, $edit) { + foreach ($edit as $key=>$value) { + db_query("UPDATE locales SET $key = '". check_input($value) ."' WHERE id = '$id'"); + } +} + +function locale_edit($id) { + global $languages; + $result = db_query("SELECT * FROM locales WHERE id = '$id'"); + if ($translation = db_fetch_object($result)) { + $output .= "
\n"; + $output .= "Original string:
\n"; + $output .= check_output($translation->string) ."

"; + foreach ($languages as $code=>$language) { + $output .= "$language:
"; + $output .= "$code) ."\">

"; + } + $output .= "\n"; + $output .= "\n"; + $output .= "

\n"; + + print $output; + } +} + +function locale_languages($translation) { + global $languages; + foreach ($languages as $key=>$value) { + $output .= ($translation->$key) ? "$key " : "$key "; + } + return $output; +} + +function locale_display() { + $result = db_query("SELECT * FROM locales ORDER BY string"); $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($locale = db_fetch_object($result)) { - $output .= " "; + $languages = locale_languages($locale); + $output .= " "; } $output .= "
stringoperations
stringlanguagesoperations
". check_output($locale->english) ."
$locale->location
id\">editid\">delete
". check_output($locale->string) ."
$locale->location
$languagesid\">editid\">delete
\n"; print $output; } -?> +function locale_admin() { + global $id, $edit, $op; + + print "overview | help
\n"; + + switch ($op) { + case "delete": + locale_delete($id); + locale_display(); + break; + case "help": + locale_help(); + break; + case "edit": + locale_edit($id); + break; + case "Save translations": + locale_save($id, $edit); + // fall through + default: + locale_display(); + } +} + +function locale($string) { + global $locale; + $result = db_query("SELECT id, $locale FROM locales WHERE STRCMP(string, '". addslashes($string) ."') = 0"); + if ($translation = db_fetch_object($result)) $string = ($translation->$locale) ? check_output($translation->$locale) : $string; + else db_query("INSERT INTO locales (string, location) VALUES ('". addslashes($string) ."', '". check_input(getenv("REQUEST_URI")) ."')"); + return $string; +} + +?> \ No newline at end of file -- cgit v1.2.3