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 --- includes/comment.inc | 78 +++++++++++++++++++------------------------------- includes/common.inc | 6 ++-- includes/function.inc | 14 ++++----- includes/hostname.conf | 9 ++++++ includes/locale.inc | 9 ++++-- includes/theme.inc | 16 +++++------ 6 files changed, 60 insertions(+), 72 deletions(-) (limited to 'includes') 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) { -- cgit v1.2.3