summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-02-17 12:59:24 +0000
committerDries Buytaert <dries@buytaert.net>2001-02-17 12:59:24 +0000
commit52a1d1bbe80422ca7a8c79dde6fd92db542b9b2d (patch)
tree1dfcddc91c4b41071dcfa3b8d876d8b370551e97 /includes
parente7f043c30afbfef8301e0dcd9a9c597432ef2bad (diff)
downloadbrdo-52a1d1bbe80422ca7a8c79dde6fd92db542b9b2d.tar.gz
brdo-52a1d1bbe80422ca7a8c79dde6fd92db542b9b2d.tar.bz2
- More updates on the translation support
Diffstat (limited to 'includes')
-rw-r--r--includes/comment.inc78
-rw-r--r--includes/common.inc6
-rw-r--r--includes/function.inc14
-rw-r--r--includes/hostname.conf9
-rw-r--r--includes/locale.inc9
-rw-r--r--includes/theme.inc16
6 files changed, 60 insertions, 72 deletions
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 .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
// Name field:
- $output .= "<P>\n";
- $output .= " <B>Your name:</B><BR>\n";
- $output .= format_username($user->userid);
- $output .= "</P>\n";
+ $output .= "<B>". t("Your name") .":</B><BR>\n";
+ $output .= format_username($user->userid) ."<P>\n";
// Subject field:
- $output .= "<P>\n";
- $output .= " <B>Subject:</B><BR>\n";
- $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\">\n";
- $output .= "</P>\n";
+ $output .= "<B>". t("Subject") .":</B><BR>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\"><P>\n";
// Comment field:
- $output .= "<P>\n";
- $output .= " <B>Comment:</B><BR>\n";
- $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($user->signature) ."</TEXTAREA><BR>\n";
- $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
- $output .= "</P>\n";
+ $output .= "<B>".t("Comment") .":</B><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($user->signature) ."</TEXTAREA><BR>\n";
+ $output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
// Preview button:
- $output .= "<P>\n";
- $output .= " <SMALL><I>You must preview at least once before you can submit:</I></SMALL><BR>\n";
- $output .= " <INPUT TYPE=\"hidden\" NAME=\"pid\" VALUE=\"$pid\">\n";
- $output .= " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
- $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview comment\"><BR>\n";
- $output .= "</P>\n";
+ $output .= "<SMALL><I>". t("You must preview at least once before you can submit") .":</I></SMALL><BR>\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"pid\" VALUE=\"$pid\">\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview comment") ."\"><BR>\n";
$output .= "</FORM>\n";
@@ -114,42 +105,32 @@ function comment_preview($pid, $id, $subject, $comment) {
$output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
// Name field:
- $output .= "<P>\n";
- $output .= " <B>Your name:</B><BR>\n";
- $output .= format_username($user->userid);
- $output .= "</P>\n";
+ $output .= "<B>". t("Your name") .":</B><BR>\n";
+ $output .= format_username($user->userid) ."<P>\n";
// Subject field:
- $output .= "<P>\n";
- $output .= " <B>Subject:</B><BR>\n";
- $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($subject) ."\">\n";
- $output .= "</P>\n";
+ $output .= "<B>". t("Subject") .":</B><BR>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($subject) ."\"><P>\n";
// Comment field:
- $output .= "<P>\n";
- $output .= " <B>Comment:</B><BR>\n";
- $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment) ."</TEXTAREA><BR>\n";
- $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
- $output .= "</P>\n";
+ $output .= "<B>". t("Comment") .":</B><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment) ."</TEXTAREA><BR>\n";
+ $output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
// Hidden fields:
$output .= "<INPUT TYPE=\"hidden\" NAME=\"pid\" VALUE=\"$pid\">\n";
$output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
if (empty($subject)) {
- $output .= "<P>\n";
- $output .= " <FONT COLOR=\"red\"><B>Warning:</B></FONT> you did not supply a <U>subject</U>.\n";
- $outout .= "</P>\n";
+ $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
}
// Preview and submit button:
- $output .= "<P>\n";
- $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview comment\">\n";
- $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Post comment\">\n";
- $output .= " </FORM>\n";
- $output .= "</P>\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview comment") ."\">\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Post comment") ."\">\n";
+ $output .= "</FORM>\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 .= "</SELECT>\n";
}
else {
- $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". check_output($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". check_output($comment->votes) ."</TR></TABLE>\n";
+ $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>". t("score") .":</TD><TD>". check_output($comment->score) ."</TD></TR><TR><TD>". t("votes") .":</TD><TD>". check_output($comment->votes) ."</TR></TABLE>\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 .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Update settings\">\n";
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Add comment\">\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Update settings") ."\">\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Add comment") ."\">\n";
$output .= "</FORM>\n";
$output .= "</FONT>\n";
return $output;
@@ -228,7 +209,7 @@ function comment_controls($threshold = 1, $mode = 3, $order = 1) {
function comment_threshold($threshold) {
$output .= "<SELECT NAME=\"threshold\">\n";
for ($i = -1; $i < 6; $i++) {
- $output .= " <OPTION VALUE=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">Filter - $i</OPTION>";
+ $output .= " <OPTION VALUE=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">". t("Filter") ." - $i</OPTION>";
}
$output .= "</SELECT>\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 "<P>";
comment_comment($comment);
- print "</P>";
+ print "<P>";
}
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 " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$lid\">\n";
- print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Moderate comments\">\n";
+ print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Moderate comments") ."\">\n";
print "</FORM>\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 = "<I>na</I>";
function check_textfield($message) {
- global $allowed_html;
- return strip_tags(str_replace("\"", "&quot;", stripslashes($message)), $allowed_html);
+ return strip_tags(str_replace("\"", "&quot;", 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
@@ -55,6 +55,15 @@ $themes = array("UnConeD" => array(
"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
# submission's selection box whereas the corresponding values
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 @@
<?
+function locale_load() {
+ global $languages, $user;
+ return ($user->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 .= "<LI><A HREF=\"account.php?op=track&topic=comments\">". t("track your comments") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=stories\">". t("track your stories") ."</A></LI>\n";
- $content .= "<LI><A HREF=\"account.php?op=track&topic=site\">". t("track") ." $site_name</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=track&topic=site\">". strtr(t("track %a"), array("%a" => $site_name)) ."</A></LI>\n";
$content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">". t("edit your information") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">". t("edit your preferences") ."</A></LI>\n";
@@ -54,15 +54,15 @@ function theme_account($theme) {
$content .= "<LI><A HREF=\"account.php?op=logout\">". t("logout") ."</A></LI>\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 .= "<CENTER>\n";
- $output .= " <FORM ACTION=\"account.php?op=Login\" METHOD=\"post\">\n";
- $output .= " <P><B>". t("Username") .":</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"></P>\n";
- $output .= " <P><B>". t("Password") .":</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"></P>\n";
- $output .= " <P><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Login\"></P>\n";
- $output .= " <P><A HREF=\"account.php\">". t("REGISTER") ."</A></P>\n";
+ $output .= " <FORM ACTION=\"account.php?op=login\" METHOD=\"post\">\n";
+ $output .= " <B>". t("Username") .":</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"><P>\n";
+ $output .= " <B>". t("Password") .":</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"><BR>\n";
+ $output .= " <INPUT TYPE=\"submit\" VALUE=\"". t("Login") ."\"><BR>\n";
+ $output .= " <A HREF=\"account.php\">". t("REGISTER") ."</A>\n";
$output .= " </FORM>\n";
$output .= "</CENTER>\n";
@@ -92,7 +92,7 @@ function theme_blocks($region, $theme) {
}
function theme_morelink($theme, $story) {
- return ($story->article) ? "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]";
+ return ($story->article) ? "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\"><B>". t("read more") ."</B></FONT></A> | ". sizeof(explode(" ", $story->article)) ." ". t("words") ." | <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]";
}
function theme_moderation_results($theme, $story) {