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 --- account.php | 120 ++++++++++++++++++++++----------------- database/database.mysql | 11 +++- includes/comment.inc | 78 ++++++++++--------------- includes/common.inc | 6 +- includes/function.inc | 14 ++--- includes/hostname.conf | 9 +++ includes/locale.inc | 9 ++- includes/theme.inc | 16 +++--- modules/diary.module | 10 ++-- modules/drupal.module | 8 +-- modules/drupal/drupal.module | 8 +-- modules/locale.module | 89 ++++++++++++++++++++++++++--- modules/locale/locale.module | 89 ++++++++++++++++++++++++++--- modules/watchdog.module | 2 +- modules/watchdog/watchdog.module | 2 +- search.php | 2 +- story.php | 14 ++--- submit.php | 120 ++++++++++++++------------------------- themes/marvin/marvin.theme | 14 ++--- updates/1.00-to-1.xx | 3 + 20 files changed, 379 insertions(+), 245 deletions(-) diff --git a/account.php b/account.php index 48be2b2b8..6a2ff7b5f 100644 --- a/account.php +++ b/account.php @@ -10,17 +10,11 @@ function account_get_user($uname) { function account_email() { $output .= "

". t("Lost your password? Fill out your username and e-mail address, and your password will be mailed to you.") ."

\n"; $output .= "
\n"; - $output .= "

\n"; - $output .= " ". t("Username") .":
\n"; - $output .= "
\n"; - $output .= "

\n"; - $output .= "

\n"; - $output .= " ". t("E-mail address") .":
\n"; - $output .= "
\n"; - $output .= "

\n"; - $output .= "

\n"; - $output .= " \n"; - $output .= "

\n"; + $output .= "". t("Username") .":
\n"; + $output .= "

\n"; + $output .= "". t("E-mail address") .":
\n"; + $output .= "

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

\n"; return $output; @@ -29,7 +23,7 @@ function account_email() { function account_create($user = "", $error = "") { global $theme; - if ($error) $output .= "Failed to create account:$error\n"; + if ($error) $output .= "

". t("Failed to create account: $error.") ."

\n"; else $output .= "

". t("Registering allows you to comment on stories, to moderate comments and pending stories, to customize the look and feel of the site and generally helps you interact with the site more efficiently.") ."

". t("To create an account, simply fill out this form an click the 'Create account' button below. An e-mail will then be sent to you with instructions on how to validate your account.") ."

\n"; $output .= "
\n"; @@ -39,7 +33,7 @@ function account_create($user = "", $error = "") { $output .= "". t("E-mail address") .":
\n"; $output .= "
\n"; $output .= "". t("You will be sent instructions on how to validate your account via this e-mail address: make sure it is accurate.") ."

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

\n"; return $output; @@ -72,31 +66,40 @@ function account_user_edit() { if ($user->id) { // Generate output/content: $output .= "
\n"; + $output .= "". t("Username") .":
\n"; $output .= "  $user->userid

\n"; $output .= "". t("Required, unique, and can not be changed.") ."

\n"; + $output .= "". t("Real name") .":
\n"; $output .= "name\">
\n"; - $output .= "". t("Optional.") ."

\n"; + $output .= "". t("Optional") .".

\n"; + $output .= "". t("Real e-mail address") .":
\n"; $output .= "  $user->real_email

\n"; $output .= "". t("Required, unique, can not be changed.") ." ". t("Your real e-mail address is never displayed publicly: only needed in case you lose your password.") ."

\n"; + $output .= "". t("Fake e-mail address") .":
\n"; $output .= "fake_email\">
\n"; - $output .= "". t("Optional.") ." ". t("Displayed publicly so you may spam proof your real e-mail address if you want.") ."

\n"; + $output .= "". t("Optional") .". ". t("Displayed publicly so you may spam proof your real e-mail address if you want.") ."

\n"; + $output .= "". t("Homepage") .":
\n"; $output .= "url\">
\n"; - $output .= "". t("Optional.") ." ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\".") ."

\n"; + $output .= "". t("Optional") .". ". t("Make sure you enter fully qualified URLs only. That is, remember to include \"http://\".") ."

\n"; + $output .= "". t("Bio") .": (". t("maximal 255 characters") .")
\n"; $output .= "
\n"; - $output .= "". t("Optional.") ." ". t("This biographical information is publicly displayed on your user page.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + $output .= "". t("Optional") .". ". t("This biographical information is publicly displayed on your user page.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + $output .= "". t("Signature") .": (". t("maximal 255 characters") .")
\n"; $output .= "
\n"; - $output .= "". t("Optional.") ." ". t("This information will be publicly displayed at the end of your comments.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + $output .= "". t("Optional") .". ". t("This information will be publicly displayed at the end of your comments.") ."
". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; + $output .= "". t("Password") .":
\n"; $output .= "
\n"; $output .= "". t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.") ."

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

\n"; // Display output/content: @@ -129,34 +132,46 @@ function account_user_save($edit) { } function account_site_edit() { - global $cmodes, $corder, $theme, $themes, $user; + global $cmodes, $corder, $theme, $themes, $languages, $user; if ($user->id) { $output .= "
\n"; + $output .= "". t("Theme" ) .":
\n"; foreach ($themes as $key=>$value) $options1 .= " \n"; $output .= "
\n"; $output .= "". t("Selecting a different theme will change the look and feel of the site.") ."

\n"; + $output .= "". t("Timezone") .":
\n"; $date = time() - date("Z"); for ($zone = -43200; $zone <= 46800; $zone += 3600) $options2 .= " \n"; $output .= "
\n"; $output .= "". t("Select what time you currently have and your timezone settings will be set appropriate.") ."

\n"; + + $output .= "". t("Language" ) .":
\n"; + foreach ($languages as $key=>$value) $options3 .= " \n"; + $output .= "
\n"; + $output .= "". t("Selecting a different language will change the language the site.") ."

\n"; + $output .= "". t("Maximum number of stories to display") .":
\n"; - for ($stories = 10; $stories <= 30; $stories += 5) $options3 .= "\n"; - $output .= "
\n"; + for ($stories = 10; $stories <= 30; $stories += 5) $options4 .= "\n"; + $output .= "
\n"; $output .= "". t("The maximum number of stories that will be displayed on the main page.") ."

\n"; - foreach ($cmodes as $key=>$value) $options4 .= "\n"; + foreach ($cmodes as $key=>$value) $options5 .= "\n"; + $output .= "". t("Comment display mode") .":
\n"; - $output .= "

\n"; - foreach ($corder as $key=>$value) $options5 .= "\n"; + $output .= "

\n"; + foreach ($corder as $key=>$value) $options6 .= "\n"; + $output .= "". t("Comment sort order") .":
\n"; - $output .= "

\n"; - for ($i = -1; $i < 6; $i++) $options6 .= " "; + $output .= "

\n"; + for ($i = -1; $i < 6; $i++) $options7 .= " "; + $output .= "". t("Comment filter") .":
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "". t("Comments that scored less than this threshold setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points.") ."

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

\n"; $theme->header(); @@ -177,6 +192,7 @@ function account_site_save($edit) { if ($user->id) { $data[theme] = $edit[theme]; $data[timezone] = $edit[timezone]; + $data[language] = $edit[language]; $data[stories] = $edit[stories]; $data[mode] = $edit[mode]; $data[sort] = $edit[sort]; @@ -197,7 +213,7 @@ function account_content_edit() { $output .= "name]\"". ($entry->user ? " CHECKED" : "") ."> ". t($block->name) ."
\n"; } $output .= "

". t("Enable the blocks you would like to see displayed in the side bars.") ."

\n"; - $output .= "

\n"; + $output .= "\n"; $output .= "\n"; $theme->header(); @@ -243,7 +259,7 @@ function account_user($uname) { // Display account information: $theme->header(); - $theme->box("Personal information", $output); + $theme->box(t("Personal information"), $output); $theme->footer(); } elseif ($uname && $account = account_get_user($uname)) { @@ -285,17 +301,17 @@ function account_validate($user) { global $type2index; // Verify username and e-mail address: - if (empty($user[real_email]) || (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $user[real_email]))) $error .= "
  • ". t("the specified e-mail address is not valid") .".
  • \n"; - if (empty($user[userid]) || (ereg("[^a-zA-Z0-9_-]", $user[userid]))) $error .= "
  • ". t("the specified username is not valid") .".
  • \n"; - if (strlen($user[userid]) > 15) $error .= "
  • ". t("the specified username is too long: it must be less than 15 characters") .".
  • \n"; + if (empty($user[real_email]) || (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $user[real_email]))) $error = t("the specified e-mail address is not valid"); + if (empty($user[userid]) || (ereg("[^a-zA-Z0-9_-]", $user[userid]))) $error = t("the specified username is not valid"); + if (strlen($user[userid]) > 15) $error = t("the specified username is too long: it must be less than 15 characters"); // Check to see whether the username or e-mail address are banned: - if ($ban = ban_match($user[userid], $type2index[usernames])) $error .= "
  • ". t("the specified username is banned for the following reason") .": $ban->reason.
  • \n"; - if ($ban = ban_match($user[real_email], $type2index[addresses])) $error .= "
  • ". t("the specified e-mail address is banned for the following reason") .": $ban->reason.
  • \n"; + if ($ban = ban_match($user[userid], $type2index[usernames])) $error = t("the specified username is banned") .": $ban->reason"; + if ($ban = ban_match($user[real_email], $type2index[addresses])) $error = t("the specified e-mail address is banned") .": $ban->reason."; // Verify whether username and e-mail address are unique: - if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid) = LOWER('$user[userid]')")) > 0) $error .= "
  • ". t("the specified username is already taken") .".
  • \n"; - if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email)=LOWER('$user[real_email]')")) > 0) $error .= "
  • ". t("the specified e-mail address is already registered") .".
  • \n"; + if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid) = LOWER('$user[userid]')")) > 0) $error = t("the specified username is already taken"); + if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email)=LOWER('$user[real_email]')")) > 0) $error = t("the specified e-mail address is already used for another account"); return $error; } @@ -463,7 +479,7 @@ function account_track_site() { } $theme->header(); - $theme->box(t("Track $site_name"), $output); + $theme->box(strtr(t("Track %a"), array("%a" => $site_name)), ($output ? $output : t("No comments or stories posted recently."))); $theme->footer(); } @@ -474,31 +490,31 @@ if (strstr($name, " ") || strstr($hash, " ")) { } switch ($op) { - case "Login": - account_session_start($userid, $passwd); - header("Location: account.php?op=info"); - break; - case "E-mail new password": + case t("E-mail new password"): account_email_submit($userid, $email); break; - case "Create account": + case t("Create account"): account_create_submit($userid, $email); break; - case "confirm": - account_create_confirm($name, $hash); - break; - case "Save user information": + case t("Save user information"): account_user_save($edit); account_user($user->userid); break; - case "Save site settings": + case t("Save site settings"): account_site_save($edit); header("Location: account.php?op=info"); break; - case "Save content settings": + case t("Save content settings"): account_content_save($edit); account_user($user->userid); break; + case "confirm": + account_create_confirm($name, $hash); + break; + case "login": + account_session_start($userid, $passwd); + header("Location: account.php?op=info"); + break; case "logout": account_session_close(); header("Location: account.php?op=info"); @@ -540,4 +556,4 @@ switch ($op) { account_user($user->userid); } -?> +?> \ No newline at end of file diff --git a/database/database.mysql b/database/database.mysql index 009895c51..07cd2813e 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -110,8 +110,16 @@ CREATE TABLE layout ( CREATE TABLE locales ( id int(11) DEFAULT '0' NOT NULL auto_increment, - english TEXT DEFAULT '' NOT NULL, location varchar(128) DEFAULT '' NOT NULL, + string TEXT DEFAULT '' NOT NULL, + da TEXT DEFAULT '' NOT NULL, + fi TEXT DEFAULT '' NOT NULL, + fr TEXT DEFAULT '' NOT NULL, + en TEXT DEFAULT '' NOT NULL, + es TEXT DEFAULT '' NOT NULL, + nl TEXT DEFAULT '' NOT NULL, + no TEXT DEFAULT '' NOT NULL, + sw TEXT DEFAULT '' NOT NULL, PRIMARY KEY (id) ); @@ -168,6 +176,7 @@ CREATE TABLE users ( hash varchar(12) DEFAULT '' NOT NULL, rating decimal(8,4) DEFAULT '0' NOT NULL, timezone varchar(8) DEFAULT '0' NOT NULL, + language varchar(2) DEFAULT '0' NOT NULL, PRIMARY KEY (id) ); diff --git a/includes/comment.inc b/includes/comment.inc index dcd4557eb..c64a3e4dd 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -56,7 +56,6 @@ function comment_settings($mode, $order, $threshold) { function comment_reply($pid, $id) { global $allowed_html, $link, $REQUEST_URI, $theme, $user; - // Extract parent-information/data: if ($pid) { $item = db_fetch_object(db_query("SELECT comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = $pid")); $theme->comment(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), "reply to this comment"); @@ -73,31 +72,23 @@ function comment_reply($pid, $id) { $output .= "
    \n"; // Name field: - $output .= "

    \n"; - $output .= " Your name:
    \n"; - $output .= format_username($user->userid); - $output .= "

    \n"; + $output .= "". t("Your name") .":
    \n"; + $output .= format_username($user->userid) ."

    \n"; // Subject field: - $output .= "

    \n"; - $output .= " Subject:
    \n"; - $output .= " \n"; - $output .= "

    \n"; + $output .= "". t("Subject") .":
    \n"; + $output .= "

    \n"; // Comment field: - $output .= "

    \n"; - $output .= " Comment:
    \n"; - $output .= "
    \n"; - $output .= " Allowed HTML tags: ". htmlspecialchars($allowed_html) .".\n"; - $output .= "

    \n"; + $output .= "".t("Comment") .":
    \n"; + $output .= "
    \n"; + $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

    \n"; // Preview button: - $output .= "

    \n"; - $output .= " You must preview at least once before you can submit:
    \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
    \n"; - $output .= "

    \n"; + $output .= "". t("You must preview at least once before you can submit") .":
    \n"; + $output .= "\n"; + $output .= "\n"; + $output .= "
    \n"; $output .= "
    \n"; @@ -114,42 +105,32 @@ function comment_preview($pid, $id, $subject, $comment) { $output .= "
    \n"; // Name field: - $output .= "

    \n"; - $output .= " Your name:
    \n"; - $output .= format_username($user->userid); - $output .= "

    \n"; + $output .= "". t("Your name") .":
    \n"; + $output .= format_username($user->userid) ."

    \n"; // Subject field: - $output .= "

    \n"; - $output .= " Subject:
    \n"; - $output .= " \n"; - $output .= "

    \n"; + $output .= "". t("Subject") .":
    \n"; + $output .= "

    \n"; // Comment field: - $output .= "

    \n"; - $output .= " Comment:
    \n"; - $output .= "
    \n"; - $output .= " Allowed HTML tags: ". htmlspecialchars($allowed_html) .".\n"; - $output .= "

    \n"; + $output .= "". t("Comment") .":
    \n"; + $output .= "
    \n"; + $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

    \n"; // Hidden fields: $output .= "\n"; $output .= "\n"; if (empty($subject)) { - $output .= "

    \n"; - $output .= " Warning: you did not supply a subject.\n"; - $outout .= "

    \n"; + $output .= "". t("Warning: you did not supply a subject.") ."

    \n"; } // Preview and submit button: - $output .= "

    \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "

    \n"; - $output .= "

    \n"; + $output .= "\n"; + $output .= "\n"; + $output .= "\n"; - $theme->box("Reply", $output); + $theme->box(t("Reply"), $output); } function comment_post($pid, $id, $subject, $comment) { @@ -205,7 +186,7 @@ function comment_moderation($comment) { $output .= "\n"; } else { - $output .= "
    score:". check_output($comment->score) ."
    votes:". check_output($comment->votes) ."
    \n"; + $output .= "
    ". t("score") .":". check_output($comment->score) ."
    ". t("votes") .":". check_output($comment->votes) ."
    \n"; } return $output; @@ -218,8 +199,8 @@ function comment_controls($threshold = 1, $mode = 3, $order = 1) { $output .= comment_mode(($user->id ? $user->mode : $mode)); $output .= comment_order(($user->id ? $user->sort : $order)); $output .= comment_threshold(($user->id ? $user->threshold : $threshold)); - $output .= "\n"; - $output .= "\n"; + $output .= "\n"; + $output .= "\n"; $output .= "\n"; $output .= "\n"; return $output; @@ -228,7 +209,7 @@ function comment_controls($threshold = 1, $mode = 3, $order = 1) { function comment_threshold($threshold) { $output .= "\n"; return $output; @@ -313,9 +294,8 @@ function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) { $theme->comment($comment, comment_link($comment, 0)); } else { - print "

    "; comment_comment($comment); - print "

    "; + print "

    "; } comment_thread_max($comment->cid, $mode, $threshold, $level + 1, $dummy + 1); } @@ -385,7 +365,7 @@ function comment_render($lid, $cid) { if ($user->id) { // Print moderation form: print " \n"; - print " \n"; + print " \n"; print "\n"; } } diff --git a/includes/common.inc b/includes/common.inc index 3cda625af..7ee1034c6 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -15,14 +15,14 @@ include_once "includes/$conf.conf"; include_once "includes/database.inc"; include_once "includes/watchdog.inc"; include_once "includes/function.inc"; -include_once "includes/search.inc"; -include_once "includes/locale.inc"; include_once "includes/module.inc"; +include_once "includes/locale.inc"; +include_once "includes/search.inc"; include_once "includes/theme.inc"; include_once "includes/user.inc"; user_load(); - +$locale = locale_load(); $theme = theme_load(); ?> \ No newline at end of file diff --git a/includes/function.inc b/includes/function.inc index 1305d4b96..04402f5a7 100644 --- a/includes/function.inc +++ b/includes/function.inc @@ -3,8 +3,7 @@ $na = "na"; function check_textfield($message) { - global $allowed_html; - return strip_tags(str_replace("\"", """, stripslashes($message)), $allowed_html); + return strip_tags(str_replace("\"", """, stripslashes($message))); } function check_textarea($message) { @@ -60,19 +59,16 @@ function format_date($timestamp, $type = "medium") { switch ($type) { case "small": - $date = date("D, m/d/y - H:i", $timestamp); + $date = date("m/d/y - H:i", $timestamp); break; case "medium": - $date = date("l, m/d/Y - H:i", $timestamp); + $date = t(date("l", $timestamp)) .", ". date("m/d/Y - H:i", $timestamp); break; case "large": - $date = date("D, M d, Y - H:i", $timestamp); - break; - case "extra large": - $date = date("l, F dS, Y - H:i", $timestamp); + $date = t(date("l", $timestamp)) .", ". t(date("F", $timestamp)) ." ". date("d, Y - H:i", $timestamp); break; default: - $date = date("D, M d, Y - H:i", $timestamp); + $date = t(date("l", $timestamp)) .", ". date("m/d/Y - H:i", $timestamp); } return $date; } diff --git a/includes/hostname.conf b/includes/hostname.conf index e9b597b2e..78882cc7d 100644 --- a/includes/hostname.conf +++ b/includes/hostname.conf @@ -54,6 +54,15 @@ $themes = array("UnConeD" => array( "themes/marvin/marvin.theme", "classic theme, white, basic design with a fresh look")); +# +# Languages / translation / internationalization: +# the first language listed in this associative array will +# automatically become the default language. You can add +# a lanaguage but make sure your SQL table, called locales +# is updated appropriatly. +# +$languages = array("en" => "English"); + # # Submission moderation votes: # the keys of this associative array are displayed in each diff --git a/includes/locale.inc b/includes/locale.inc index 3e35bfd70..85b03eccb 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -1,9 +1,12 @@ language) ? $user->language : key($languages); +} + function t($string) { - $result = db_query("SELECT id FROM locales WHERE english = '". addslashes($string) ."'"); - if (!db_fetch_object($result)) db_query("INSERT INTO locales (english, location) VALUES ('". addslashes($string) ."', '". check_input(getenv("REQUEST_URI")) ."')"); - return $string; + return locale($string); } ?> \ No newline at end of file diff --git a/includes/theme.inc b/includes/theme.inc index 57b2f7d29..5791ed049 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -32,7 +32,7 @@ function theme_account($theme) { // Display account settings: $content .= "

  • ". t("track your comments") ."
  • \n"; $content .= "
  • ". t("track your stories") ."
  • \n"; - $content .= "
  • ". t("track") ." $site_name
  • \n"; + $content .= "
  • ". strtr(t("track %a"), array("%a" => $site_name)) ."
  • \n"; $content .= "

    \n"; $content .= "

  • ". t("edit your information") ."
  • \n"; $content .= "
  • ". t("edit your preferences") ."
  • \n"; @@ -54,15 +54,15 @@ function theme_account($theme) { $content .= "
  • ". t("logout") ."
  • \n"; - $theme->box(strtr(t("%s's configuration"), array("%s" => $user->userid)), "$content"); + $theme->box(strtr(t("%a's configuration"), array("%a" => $user->userid)), "$content"); } else { $output .= "
    \n"; - $output .= "
    \n"; - $output .= "

    ". t("Username") .":

    \n"; - $output .= "

    ". t("Password") .":

    \n"; - $output .= "

    \n"; - $output .= "

    ". t("REGISTER") ."

    \n"; + $output .= " \n"; + $output .= " ". t("Username") .":

    \n"; + $output .= " ". t("Password") .":

    \n"; + $output .= "
    \n"; + $output .= " ". t("REGISTER") ."\n"; $output .= "

    \n"; $output .= "
    \n"; @@ -92,7 +92,7 @@ function theme_blocks($region, $theme) { } function theme_morelink($theme, $story) { - return ($story->article) ? "[ id\">link\">read more | ". strlen($story->article) ." bytes | id\">link\">". format_plural($story->comments, "comment", "comments") ." ]" : "[ id\">link\">". format_plural($story->comments, "comment", "comments") ." ]"; + return ($story->article) ? "[ id\">link\">". t("read more") ." | ". sizeof(explode(" ", $story->article)) ." ". t("words") ." | id\">link\">". format_plural($story->comments, "comment", "comments") ." ]" : "[ id\">link\">". format_plural($story->comments, "comment", "comments") ." ]"; } function theme_moderation_results($theme, $story) { 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 .= "". date("l, F jS", $diary->timestamp) ."\n"; + $output .= "". $date = t(date("l", $timestamp)) .", ". t(date("F", $timestamp)) ." ". date("j", $diary->timestamp) ."\n"; $time = date("F jS", $diary->timestamp); } $output .= "
    \n"; @@ -55,13 +55,13 @@ function diary_page_overview($num = 20) { function diary_page_entry($timestamp, $text, $id = 0) { if ($id) { $output .= "
    \n"; - $output .= "
    ". date("l, F jS", $timestamp) .":
    \n"; + $output .= "
    ". format_date($timestamp, "large") .":
    \n"; $output .= "

    [ ". t("edit") ." ]

    ". check_output($text, 1) ."

    \n"; $output .= "
    \n"; } else { $output .= "
    \n"; - $output .= "
    ". date("l, F jS", $timestamp) .":
    \n"; + $output .= "
    ". format_date($timestamp, "large") .":
    \n"; $output .= "

    ". check_output($text, 1) ."

    \n"; $output .= "
    \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 .= "
    ". date("l, F jS", $diary->timestamp) .":

    ". check_output($diary->text) ."

    [ more ]

    \n"; + $content .= "
    ". format_date($diary->timestamp, "large") .":

    ". check_output($diary->text) ."

    [ more ]

    \n"; $diaries++; } @@ -236,7 +236,7 @@ function diary_block() { while ($diary = db_fetch_object($result)) { if ($time != date("F jS", $diary->timestamp)) { - $content .= "

    ". date("l, M jS", $diary->timestamp) ."

    \n"; + $content .= "

    ". t(date("l", $diary->timestamp)) ." (". date("m/d/Y", $diary->timestamp) .")

    \n"; $time = date("F jS", $diary->timestamp); } $content .= "
  • userid\">$diary->userid
  • \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 @@ "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 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 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 .= "\n"; $output .= " \n"; - $output .= " \n"; + $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \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 .= "
    Level:$watchdog->level
    Date:". format_date($watchdog->timestamp, "extra large") ."
    Date:". format_date($watchdog->timestamp, "large") ."
    User:". format_username($watchdog->userid) ."
    Location:$watchdog->location
    Message:$watchdog->message
    \n"; $output .= " \n"; - $output .= " \n"; + $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; diff --git a/search.php b/search.php index 77d2ff50a..23daad6dc 100644 --- a/search.php +++ b/search.php @@ -12,7 +12,7 @@ module_iterate("find_module"); $search .= "\n"; $search .= " \n"; $search .= " \n"; -$search .= " \n"; +$search .= " \n"; $search .= "\n"; $output = search_data($keys, $type); diff --git a/story.php b/story.php index 7f12e535f..1e640d9a0 100644 --- a/story.php +++ b/story.php @@ -9,27 +9,27 @@ function story_render($id, $cid) { $story = db_fetch_object(db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id")); if (story_visible($story)) { - $theme->article($story, "[ reply to this story ]"); + $theme->article($story, "[ ". t("reply to this story") ." ]"); comment_render($id, $cid); } else { - $theme->box("Warning message", "The story you requested is not available or does not exist."); + $theme->box(t("Warning message"), t("The story you requested is not available or does not exist.")); } } 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(); story_render($id, $cid); $theme->footer(); break; - case "Add comment": + case t("Add comment"): $theme->header(); comment_reply($cid, $id); $theme->footer(); @@ -39,13 +39,13 @@ switch($op) { comment_reply($pid, $id); $theme->footer(); break; - case "Update settings": + case t("Update settings"): comment_settings($mode, $order, $threshold); $theme->header(); story_render($id, $cid); $theme->footer(); break; - case "Moderate comments": + case t("Moderate comments"): comment_moderate($moderate); $theme->header(); story_render($id, $cid); diff --git a/submit.php b/submit.php index 7db513f90..337aa69a2 100644 --- a/submit.php +++ b/submit.php @@ -1,5 +1,7 @@ \n"; - $output .= "

    \n"; - $output .= " ". t("Your name") .":
    \n"; - $output .= format_username($user->userid); - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= " ". t("Subject") .":
    \n"; - $output .= "
    \n"; - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= " ". t("Section") .":
    \n"; - $output .= " \n"; - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= " ". t("Abstract") .":
    \n"; - $output .= "
    \n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".\n"; - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= " ". t("Extended story") .":
    \n"; - $output .= "
    \n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".\n"; - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= " ". t("You must preview at least once before you can submit") .":
    \n"; - $output .= " \n"; - $output .= "

    \n"; + $output .= "". t("Your name") .":
    \n"; + $output .= format_username($user->userid) ."

    \n"; + + $output .= "". t("Subject") .":
    \n"; + $output .= "

    \n"; + + $output .= "". t("Section") .":
    \n"; + foreach ($sections = section_get() as $value) $options .= " \n"; + $output .= "

    \n"; + + $output .= "". t("Abstract") .":
    \n"; + $output .= "
    \n"; + $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

    \n"; + + $output .= "". t("Extended story") .":
    \n"; + $output .= "
    \n"; + $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

    \n"; + + $output .= "". t("You must preview at least once before you can submit") .":
    \n"; + $output .= "

    \n"; $output .= "\n"; $theme->header(); - $theme->box(t("Submit a story"), $output); + $theme->box(t("New submission"), $output); $theme->footer(); } @@ -59,54 +48,35 @@ function submit_preview($subject, $abstract, $article, $section) { $output .= "
    \n"; - $output .= "

    \n"; - $output .= " ". t("Your name") .":
    \n"; - $output .= format_username($user->userid); - $output .= "

    \n"; + $output .= "". t("Your name") .":
    \n"; + $output .= format_username($user->userid) ."

    "; - $output .= "

    \n"; - $output .= " ". t("Subject") .":
    \n"; - $output .= "
    \n"; - $output .= "

    \n"; + $output .= "". t("Subject") .":
    \n"; + $output .= "

    \n"; - $output .= "

    \n"; - $output .= " ". t("Section") .":
    \n"; - $output .= " \n"; - $output .= "

    \n"; + $output .= "". t("Section") .":
    \n"; + foreach ($sections = section_get() as $value) $options .= " \n"; + $output .= "

    \n"; - $output .= "

    \n"; $output .= "". t("Abstract") .":
    \n"; - $output .= "
    \n"; - $output .= " Allowed HTML tags: ". htmlspecialchars($allowed_html) .".\n"; - $output .= "

    \n"; + $output .= "
    \n"; + $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

    \n"; - $output .= "

    \n"; - $output .= " ". t("Extended story") .":
    \n"; - $output .= "
    \n"; - $output .= " Allowed HTML tags: ". htmlspecialchars($allowed_html) .".\n"; - $output .= "

    \n"; + $output .= "". t("Extended story") .":
    \n"; + $output .= "
    \n"; + $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

    \n"; if (empty($subject)) { - $output .= "

    ". t("Warning: you did not supply a subject.") ."

    \n"; - $output .= "

    \n"; - $output .= " \n"; - $output .= "

    \n"; + $output .= "". t("Warning: you did not supply a subject.") ."

    \n"; + $output .= "\n"; } else if (empty($abstract)) { - $output .= "

    \n"; - $output .= " ". t("Warning: you did not supply an abstract.") ."\n"; - $outout .= "

    \n"; - $output .= "

    \n"; - $output .= " \n"; - $output .= "

    \n"; + $output .= "". t("Warning: you did not supply an abstract.") ."

    \n"; + $output .= "\n"; } else { - $output .= "

    \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "

    \n"; + $output .= "\n"; + $output .= "\n"; } $output .= "\n"; @@ -127,17 +97,15 @@ function submit_submit($subject, $abstract, $article, $section) { // Display confirmation message: $theme->header(); - $theme->box("Thank you for your submission.", "Thank you for your submission. Your submission has been whisked away to our submission queue where our registered users will frown at it, poke at it and hopefully carry it to the front page for discussion."); + $theme->box(t("Submission completed"), t("Thank you for your submission. Your submission has been whisked away to our submission queue where our registered users will frown at it, poke at it and hopefully carry it to the front page for discussion.")); $theme->footer(); } -include_once "includes/common.inc"; - switch($op) { - case "Preview submission": + case t("Preview submission"): submit_preview($subject, $abstract, $article, $section); break; - case "Submit submission": + case t("Submit submission"): submit_submit($subject, $abstract, $article, $section); break; default: diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index 287c8a524..50622d264 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -45,7 +45,7 @@
    - \n"; print " \n"; print " \n"; print " \n"; print " \n"; @@ -79,7 +79,7 @@ print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; @@ -119,7 +119,7 @@ print " \n"; // Subject: - print " \n"; + print " \n"; print " \n"; // Moderation: @@ -130,12 +130,12 @@ // Author: print " \n"; - print " \n"; + print " \n"; print " \n"; // Date print " \n"; - print " \n"; + print " \n"; print " \n"; print "
    Level:$watchdog->level
    Date:". format_date($watchdog->timestamp, "extra large") ."
    Date:". format_date($watchdog->timestamp, "large") ."
    User:". format_username($watchdog->userid) ."
    Location:$watchdog->location
    Message:$watchdog->message
    home | faq | diary | search | submit news | user account
    + \"\"
    \n"; - print " Submitted by ". format_username($story->userid) ." on ". format_date($story->timestamp, "extra large"). ""; ?>department) print "
    from the $story->department dept."; ?>
    section) ."\">$story->section\n"; + print " ". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?>department) print "
    from the $story->department dept."; ?>
    section) ."\">$story->section\n"; print "
     
    \"\"
    \n"; - print " Submitted by ". format_username($story->userid) ." on ". format_date($story->timestamp, "extra large") .""; ?>department) print "
    from the $story->department dept."; ?>
    section) ."\">$story->section\n"; + print " ". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?>department) print "
    from the $story->department dept."; ?>
    section) ."\">$story->section\n"; print "
     
    Subject:". t("Subject") .":hlcolor1\">". check_output($comment->subject) ."
    Author:". format_username($comment->userid) ."". t("Author") .":". format_username($comment->userid) ."
    Date:". format_date($comment->timestamp) ."". t("Date") .":". format_date($comment->timestamp) ."
    \n"; @@ -175,7 +175,7 @@ function footer() { ?> - +