Commit 52bfb710 authored by Steven Wittens's avatar Steven Wittens
Browse files

Locale.module:

Added a piece of code to insert common strings (currently weekdays and month-names) into the locale table. It's triggered whenever you visit the locale admin pages, but executes only once.
parent 837087ea
......@@ -216,6 +216,8 @@ function locale_admin() {
print status("locale disabled.");
}
else if (user_access("administer locales")) {
locale_admin_initialize();
print "<small>". locale_links(1) . locale_links(0) . la(t("search"), array("mod" => "locale", "op" => "Search")) ." | ". la(t("overview"), array("mod" => "locale", "op" => "overview")) ." | ". la(t("help"), array("mod" => "locale", "op" => "help")) ."</small><hr />\n";
switch ($op) {
......@@ -253,6 +255,29 @@ function locale_admin() {
}
}
function locale_admin_initialize() {
/* This function inserts common strings into the locale table (e.g. names of months and days).
* We use $revision and a stored variable to track if the locale table is up-to-date.
*/
$revision = 1;
if (variable_get("locale_initialize_revision", 0) < $revision) {
variable_set("locale_initialize_revision", $revision);
for ($i = 1; $i <= 12; $i++) {
$stamp = mktime(0, 0, 0, $i, 1, 1971);
t(date("F", $stamp));
t(date("M", $stamp));
}
for ($i = 0; $i <= 7; $i++) {
$stamp = $i * 86400;
t(date("D", $stamp));
t(date("l", $stamp));
}
}
}
function locale($string) {
global $locale;
static $locale_t;
......
......@@ -216,6 +216,8 @@ function locale_admin() {
print status("locale disabled.");
}
else if (user_access("administer locales")) {
locale_admin_initialize();
print "<small>". locale_links(1) . locale_links(0) . la(t("search"), array("mod" => "locale", "op" => "Search")) ." | ". la(t("overview"), array("mod" => "locale", "op" => "overview")) ." | ". la(t("help"), array("mod" => "locale", "op" => "help")) ."</small><hr />\n";
switch ($op) {
......@@ -253,6 +255,29 @@ function locale_admin() {
}
}
function locale_admin_initialize() {
/* This function inserts common strings into the locale table (e.g. names of months and days).
* We use $revision and a stored variable to track if the locale table is up-to-date.
*/
$revision = 1;
if (variable_get("locale_initialize_revision", 0) < $revision) {
variable_set("locale_initialize_revision", $revision);
for ($i = 1; $i <= 12; $i++) {
$stamp = mktime(0, 0, 0, $i, 1, 1971);
t(date("F", $stamp));
t(date("M", $stamp));
}
for ($i = 0; $i <= 7; $i++) {
$stamp = $i * 86400;
t(date("D", $stamp));
t(date("l", $stamp));
}
}
}
function locale($string) {
global $locale;
static $locale_t;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment