diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-02-17 12:59:24 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-02-17 12:59:24 +0000 |
commit | 52a1d1bbe80422ca7a8c79dde6fd92db542b9b2d (patch) | |
tree | 1dfcddc91c4b41071dcfa3b8d876d8b370551e97 /modules | |
parent | e7f043c30afbfef8301e0dcd9a9c597432ef2bad (diff) | |
download | brdo-52a1d1bbe80422ca7a8c79dde6fd92db542b9b2d.tar.gz brdo-52a1d1bbe80422ca7a8c79dde6fd92db542b9b2d.tar.bz2 |
- More updates on the translation support
Diffstat (limited to 'modules')
-rw-r--r-- | modules/diary.module | 10 | ||||
-rw-r--r-- | modules/drupal.module | 8 | ||||
-rw-r--r-- | modules/drupal/drupal.module | 8 | ||||
-rw-r--r-- | modules/locale.module | 89 | ||||
-rw-r--r-- | modules/locale/locale.module | 89 | ||||
-rw-r--r-- | modules/watchdog.module | 2 | ||||
-rw-r--r-- | modules/watchdog/watchdog.module | 2 |
7 files changed, 179 insertions, 29 deletions
diff --git a/modules/diary.module b/modules/diary.module index c4939bdca..381afc887 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -35,7 +35,7 @@ function diary_page_overview($num = 20) { while ($diary = db_fetch_object($result)) { if ($time != date("F jS", $diary->timestamp)) { - $output .= "<B>". date("l, F jS", $diary->timestamp) ."</B>\n"; + $output .= "<B>". $date = t(date("l", $timestamp)) .", ". t(date("F", $timestamp)) ." ". date("j", $diary->timestamp) ."</B>\n"; $time = date("F jS", $diary->timestamp); } $output .= "<DL>\n"; @@ -55,13 +55,13 @@ function diary_page_overview($num = 20) { function diary_page_entry($timestamp, $text, $id = 0) { if ($id) { $output .= "<DL>\n"; - $output .= " <DT><B>". date("l, F jS", $timestamp) .":</B> </DT>\n"; + $output .= " <DT><B>". format_date($timestamp, "large") .":</B></DT>\n"; $output .= " <DD><P>[ <A HREF=\"module.php?mod=diary&op=edit&id=$id\">". t("edit") ."</A> ]</P><P>". check_output($text, 1) ."</P></DD>\n"; $output .= "</DL>\n"; } else { $output .= "<DL>\n"; - $output .= " <DT><B>". date("l, F jS", $timestamp) .":</B></DT>\n"; + $output .= " <DT><B>". format_date($timestamp, "large") .":</B></DT>\n"; $output .= " <DD><P>". check_output($text, 1) ."</P></DD>\n"; $output .= "</DL>\n"; } @@ -215,7 +215,7 @@ function diary_user($username, $section, $operation) { if ($section == "user" && $operation == "view") { $result = db_query("SELECT d.* FROM diaries d LEFT JOIN users u ON u.id = d.author WHERE u.userid = '$username' AND d.timestamp > ". (time() - 1209600) ." ORDER BY id DESC LIMIT 2"); while ($diary = db_fetch_object($result)) { - $content .= "<DL><DT><B>". date("l, F jS", $diary->timestamp) .":</B></DT><DD><P>". check_output($diary->text) ."</P><P>[ <A HREF=\"module.php?mod=diary&op=view&name=$username\">more</A> ]</P></DD></DL>\n"; + $content .= "<DL><DT><B>". format_date($diary->timestamp, "large") .":</B></DT><DD><P>". check_output($diary->text) ."</P><P>[ <A HREF=\"module.php?mod=diary&op=view&name=$username\">more</A> ]</P></DD></DL>\n"; $diaries++; } @@ -236,7 +236,7 @@ function diary_block() { while ($diary = db_fetch_object($result)) { if ($time != date("F jS", $diary->timestamp)) { - $content .= "<P><B>". date("l, M jS", $diary->timestamp) ."</B></P>\n"; + $content .= "<P><B>". t(date("l", $diary->timestamp)) ."</B> (". date("m/d/Y", $diary->timestamp) .")</P>\n"; $time = date("F jS", $diary->timestamp); } $content .= "<LI><A HREF=\"module.php?mod=diary&op=view&name=$diary->userid\">$diary->userid</A></LI>\n"; diff --git a/modules/drupal.module b/modules/drupal.module index 8ece0a6d9..47a08265a 100644 --- a/modules/drupal.module +++ b/modules/drupal.module @@ -43,12 +43,12 @@ function drupal_page() { global $cid, $comment, $id, $op, $pid, $lid, $link, $mode, $order, $subject, $theme, $threshold; switch($op) { - case "Preview comment": + case t("Preview comment"): $theme->header(); comment_preview($pid, $id, $subject, $comment); $theme->footer(); break; - case "Post comment": + case t("Post comment"): comment_post($pid, $id, $subject, $comment); $theme->header(); drupal_render($id, $cid); @@ -59,13 +59,13 @@ function drupal_page() { comment_reply($pid, $id); $theme->footer(); break; - case "Update settings": + case t("Update settings"): comment_settings($mode, $order, $threshold); $theme->header(); drupal_render($id, $cid); $theme->footer(); break; - case "Moderate comments": + case t("Moderate comments"): comment_moderate($moderate); $theme->header(); drupal_render($id, $cid); diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module index 8ece0a6d9..47a08265a 100644 --- a/modules/drupal/drupal.module +++ b/modules/drupal/drupal.module @@ -43,12 +43,12 @@ function drupal_page() { global $cid, $comment, $id, $op, $pid, $lid, $link, $mode, $order, $subject, $theme, $threshold; switch($op) { - case "Preview comment": + case t("Preview comment"): $theme->header(); comment_preview($pid, $id, $subject, $comment); $theme->footer(); break; - case "Post comment": + case t("Post comment"): comment_post($pid, $id, $subject, $comment); $theme->header(); drupal_render($id, $cid); @@ -59,13 +59,13 @@ function drupal_page() { comment_reply($pid, $id); $theme->footer(); break; - case "Update settings": + case t("Update settings"): comment_settings($mode, $order, $threshold); $theme->header(); drupal_render($id, $cid); $theme->footer(); break; - case "Moderate comments": + case t("Moderate comments"): comment_moderate($moderate); $theme->header(); drupal_render($id, $cid); diff --git a/modules/locale.module b/modules/locale.module index 95594a65a..8a1c3e1ac 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -1,17 +1,92 @@ <? -$module = array("page" => "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 .= "<FORM ACTION=\"admin.php?mod=locale\" METHOD=\"post\">\n"; + $output .= "<B>Original string:</B><BR>\n"; + $output .= check_output($translation->string) ."<P>"; + foreach ($languages as $code=>$language) { + $output .= "<B>$language:</B><BR>"; + $output .= "<INPUT TYPE=\"text\" NAME=\"edit[$code]\" VALUE=\"". check_textfield($translation->$code) ."\"><P>"; + } + $output .= "<INPUT NAME=\"id\" TYPE=\"hidden\" VALUE=\"$id\">\n"; + $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save translations\">\n"; + $output .= "</FORM>\n"; + + print $output; + } +} + +function locale_languages($translation) { + global $languages; + foreach ($languages as $key=>$value) { + $output .= ($translation->$key) ? "$key " : "<STRIKE>$key</STRIKE> "; + } + return $output; +} + +function locale_display() { + $result = db_query("SELECT * FROM locales ORDER BY string"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>string</TH><TH COLSPAN=\"2\">operations</TH><TR>\n"; + $output .= " <TR><TH>string</TH><TH>languages</TH><TH COLSPAN=\"2\">operations</TH><TR>\n"; while ($locale = db_fetch_object($result)) { - $output .= " <TR><TD>". check_output($locale->english) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">delete</A></TD></TR>"; + $languages = locale_languages($locale); + $output .= " <TR><TD>". check_output($locale->string) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD ALIGN=\"center\">$languages</TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=delete&id=$locale->id\">delete</A></TD></TR>"; } $output .= "</TABLE>\n"; print $output; } -?> +function locale_admin() { + global $id, $edit, $op; + + print "<SMALL><A HREF=\"admin.php?mod=locale\">overview</A> | <A HREF=\"admin.php?mod=locale&op=help\">help</A></SMALL><HR>\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 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 @@ <? -$module = array("page" => "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 .= "<FORM ACTION=\"admin.php?mod=locale\" METHOD=\"post\">\n"; + $output .= "<B>Original string:</B><BR>\n"; + $output .= check_output($translation->string) ."<P>"; + foreach ($languages as $code=>$language) { + $output .= "<B>$language:</B><BR>"; + $output .= "<INPUT TYPE=\"text\" NAME=\"edit[$code]\" VALUE=\"". check_textfield($translation->$code) ."\"><P>"; + } + $output .= "<INPUT NAME=\"id\" TYPE=\"hidden\" VALUE=\"$id\">\n"; + $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save translations\">\n"; + $output .= "</FORM>\n"; + + print $output; + } +} + +function locale_languages($translation) { + global $languages; + foreach ($languages as $key=>$value) { + $output .= ($translation->$key) ? "$key " : "<STRIKE>$key</STRIKE> "; + } + return $output; +} + +function locale_display() { + $result = db_query("SELECT * FROM locales ORDER BY string"); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>string</TH><TH COLSPAN=\"2\">operations</TH><TR>\n"; + $output .= " <TR><TH>string</TH><TH>languages</TH><TH COLSPAN=\"2\">operations</TH><TR>\n"; while ($locale = db_fetch_object($result)) { - $output .= " <TR><TD>". check_output($locale->english) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">delete</A></TD></TR>"; + $languages = locale_languages($locale); + $output .= " <TR><TD>". check_output($locale->string) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD ALIGN=\"center\">$languages</TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=delete&id=$locale->id\">delete</A></TD></TR>"; } $output .= "</TABLE>\n"; print $output; } -?> +function locale_admin() { + global $id, $edit, $op; + + print "<SMALL><A HREF=\"admin.php?mod=locale\">overview</A> | <A HREF=\"admin.php?mod=locale&op=help\">help</A></SMALL><HR>\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 diff --git a/modules/watchdog.module b/modules/watchdog.module index 81593d4c0..f1bb7925f 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -50,7 +50,7 @@ function watchdog_view($id) { if ($watchdog = db_fetch_object($result)) { $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Level:</B></TD><TD>$watchdog->level</TD></TR>\n"; - $output .= " <TR><TD ALIGN=\"right\"><B>Date:</B></TD><TD>". format_date($watchdog->timestamp, "extra large") ."</TD></TR>\n"; + $output .= " <TR><TD ALIGN=\"right\"><B>Date:</B></TD><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>User:</B></TD><TD>". format_username($watchdog->userid) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Location:</B></TD><TD>$watchdog->location</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Message:</B></TD><TD>$watchdog->message</TD></TR>\n"; diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module index 81593d4c0..f1bb7925f 100644 --- a/modules/watchdog/watchdog.module +++ b/modules/watchdog/watchdog.module @@ -50,7 +50,7 @@ function watchdog_view($id) { if ($watchdog = db_fetch_object($result)) { $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Level:</B></TD><TD>$watchdog->level</TD></TR>\n"; - $output .= " <TR><TD ALIGN=\"right\"><B>Date:</B></TD><TD>". format_date($watchdog->timestamp, "extra large") ."</TD></TR>\n"; + $output .= " <TR><TD ALIGN=\"right\"><B>Date:</B></TD><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>User:</B></TD><TD>". format_username($watchdog->userid) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Location:</B></TD><TD>$watchdog->location</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Message:</B></TD><TD>$watchdog->message</TD></TR>\n"; |