summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2009-01-08 17:13:06 +0000
committerAndy Staudacher <andy.st@gmail.com>2009-01-08 17:13:06 +0000
commita631fe29f3950f8db1f7fb4ce1f47261a9b0feff (patch)
treeb5af3ad39362dea97ce01be63d5ec09b7846bb9c /core/helpers
parentfd081159f1783918d81e355e25e262ccc5249913 (diff)
i18n refactoring: Rename all _() (reserved by gettext) calls to t().
- And refactor printf to our string interpolation / pluralization syntax - Also, a slight change to the translations_incomings table, using binary(16) instead of char(32) as message key.
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/album.php20
-rw-r--r--core/helpers/core_block.php12
-rw-r--r--core/helpers/core_installer.php6
-rw-r--r--core/helpers/core_menu.php46
-rw-r--r--core/helpers/graphics.php17
-rw-r--r--core/helpers/module.php4
-rw-r--r--core/helpers/photo.php22
7 files changed, 66 insertions, 61 deletions
diff --git a/core/helpers/album.php b/core/helpers/album.php
index 82697254..8998c8d0 100644
--- a/core/helpers/album.php
+++ b/core/helpers/album.php
@@ -65,12 +65,12 @@ class album_Core {
static function get_add_form($parent) {
$form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gAddAlbumForm"));
- $group = $form->group("add_album")->label(sprintf(_("Add Album to %s"), $parent->title));
- $group->input("name")->label(_("Name"));
- $group->input("title")->label(_("Title"));
- $group->textarea("description")->label(_("Description"));
+ $group = $form->group("add_album")->label(t("Add Album to {{album_title}}", array("album_title" => $parent->title)));
+ $group->input("name")->label(t("Name"));
+ $group->input("title")->label(t("Title"));
+ $group->textarea("description")->label(t("Description"));
$group->hidden("type")->value("album");
- $group->submit(_("Create"));
+ $group->submit(t("Create"));
$form->add_rules_from(ORM::factory("item"));
return $form;
}
@@ -78,14 +78,14 @@ class album_Core {
static function get_edit_form($parent) {
$form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gEditAlbumForm"));
$form->hidden("_method")->value("put");
- $group = $form->group("edit_album")->label(_("Edit Album"));
+ $group = $form->group("edit_album")->label(t("Edit Album"));
if ($parent->id != 1) {
- $group->input("name")->label(_("Name"))->value($parent->name);
+ $group->input("name")->label(t("Name"))->value($parent->name);
}
- $group->input("title")->label(_("Title"))->value($parent->title);
- $group->textarea("description")->label(_("Description"))->value($parent->description);
+ $group->input("title")->label(t("Title"))->value($parent->title);
+ $group->textarea("description")->label(t("Description"))->value($parent->description);
$group->hidden("type")->value("album");
- $group->submit(_("Modify"));
+ $group->submit(t("Modify"));
$form->add_rules_from(ORM::factory("item"));
return $form;
}
diff --git a/core/helpers/core_block.php b/core/helpers/core_block.php
index f4224190..8c65b1ad 100644
--- a/core/helpers/core_block.php
+++ b/core/helpers/core_block.php
@@ -70,13 +70,13 @@ class core_block_Core {
public static function admin_dashboard_blocks($theme) {
$block = new Block();
$block->id = "gWelcome";
- $block->title = _("Welcome to Gallery3");
+ $block->title = t("Welcome to Gallery3");
$block->content = new View("admin_block_welcome.html");
$blocks[] = $block;
$block = new Block();
$block->id = "gPhotoStream";
- $block->title = _("Photo Stream");
+ $block->title = t("Photo Stream");
$block->content = new View("admin_block_photo_stream.html");
$block->content->photos =
ORM::factory("item")->where("type", "photo")->orderby("created", "desc")->find_all(10);
@@ -84,7 +84,7 @@ class core_block_Core {
$block = new Block();
$block->id = "gLogEntries";
- $block->title = _("Log Entries");
+ $block->title = t("Log Entries");
$block->content = new View("admin_block_log_entries.html");
$block->content->entries = ORM::factory("log")->orderby("timestamp", "DESC")->find_all(5);
$blocks[] = $block;
@@ -95,7 +95,7 @@ class core_block_Core {
public static function admin_sidebar_blocks($theme) {
$block = new Block();
$block->id = "gStats";
- $block->title = _("Gallery Stats");
+ $block->title = t("Gallery Stats");
$block->content = new View("admin_block_stats.html");
$block->content->album_count = ORM::factory("item")->where("type", "album")->count_all();
$block->content->photo_count = ORM::factory("item")->where("type", "photo")->count_all();
@@ -103,13 +103,13 @@ class core_block_Core {
$block = new Block();
$block->id = "gPlatform";
- $block->title = _("Platform Information");
+ $block->title = t("Platform Information");
$block->content = new View("admin_block_platform.html");
$blocks[] = $block;
$block = new Block();
$block->id = "gProjectNews";
- $block->title = _("Gallery Project News");
+ $block->title = t("Gallery Project News");
$block->content = new View("admin_block_news.html");
$block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3);
$blocks[] = $block;
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index 15b97809..043af641 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -122,7 +122,7 @@ class core_installer {
$db->query("CREATE TABLE `translations_incomings` (
`id` int(9) NOT NULL auto_increment,
- `key` char(32) NOT NULL,
+ `key` binary(16) NOT NULL,
`locale` char(10) NOT NULL,
`message` text NOT NULL,
`translation` text,
@@ -211,8 +211,8 @@ class core_installer {
}
if (!module::get_var("core", "graphics_toolkit")) {
site_status::warning(
- sprintf(_("Graphics toolkit missing! Please %schoose a toolkit%s."),
- "<a href=\"" . url::site("admin/graphics") . "\">", "</a>"),
+ t("Graphics toolkit missing! Please {{link_start}}choose a toolkit{{link_start}}.",
+ array("link_start" => "<a href=\"" . url::site("admin/graphics") . "\">", "link_end" => "</a>")),
"missing_graphics_toolkit");
}
diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php
index ef866c1a..9a35e244 100644
--- a/core/helpers/core_menu.php
+++ b/core/helpers/core_menu.php
@@ -22,11 +22,11 @@ class core_menu_Core {
$menu
->append(Menu::factory("link")
->id("home")
- ->label(_("Home"))
+ ->label(t("Home"))
->url(url::base()))
->append(Menu::factory("link")
->id("browse")
- ->label(_("Browse"))
+ ->label(t("Browse"))
->url(url::site("albums/1")));
$item = $theme->item();
@@ -34,31 +34,31 @@ class core_menu_Core {
if (!user::active()->guest) {
$menu->append($admin_menu = Menu::factory("submenu")
->id("admin_menu")
- ->label(_("Admin")));
+ ->label(t("Admin")));
}
if ($item && access::can("edit", $item)) {
$menu->append($options_menu = Menu::factory("submenu")
->id("options_menu")
- ->label(_("Options"))
+ ->label(t("Options"))
->append(Menu::factory("dialog")
->id("edit_item")
- ->label($item->type == "album" ? _("Edit album") : _("Edit photo"))
+ ->label($item->type == "album" ? t("Edit album") : t("Edit photo"))
->url(url::site("form/edit/{$item->type}s/$item->id"))));
if ($item->type == "album") {
$options_menu
->append(Menu::factory("dialog")
->id("add_item")
- ->label(_("Add a photo"))
+ ->label(t("Add a photo"))
->url(url::site("form/add/albums/$item->id?type=photo")))
->append(Menu::factory("dialog")
->id("add_album")
- ->label(_("Add an album"))
+ ->label(t("Add an album"))
->url(url::site("form/add/albums/$item->id?type=album")))
->append(Menu::factory("dialog")
->id("edit_permissions")
- ->label(_("Edit permissions"))
+ ->label(t("Edit permissions"))
->url(url::site("permissions/browse/$item->id")));
}
}
@@ -66,7 +66,7 @@ class core_menu_Core {
if (user::active()->admin) {
$admin_menu->append(Menu::factory("link")
->id("site_admin")
- ->label(_("Site Admin"))
+ ->label(t("Site Admin"))
->url(url::site("admin")));
}
}
@@ -75,7 +75,7 @@ class core_menu_Core {
$menu
->append(Menu::factory("link")
->id("hybrid")
- ->label(_("View album hybrid mode"))
+ ->label(t("View album hybrid mode"))
->url("#")
->css_id("gHybridLink"));
}
@@ -84,12 +84,12 @@ class core_menu_Core {
$menu
->append(Menu::factory("link")
->id("fullsize")
- ->label(_("View full size"))
+ ->label(t("View full size"))
->url("#")
->css_id("gFullsizeLink"))
->append(Menu::factory("link")
->id("album")
- ->label(_("Return to album"))
+ ->label(t("Return to album"))
->url($theme->item()->parent()->url("show={$theme->item->id}"))
->css_id("gAlbumLink"));
}
@@ -98,43 +98,43 @@ class core_menu_Core {
$menu
->append(Menu::factory("link")
->id("dashboard")
- ->label(_("Dashboard"))
+ ->label(t("Dashboard"))
->url(url::site("admin")))
->append(Menu::factory("submenu")
->id("settings_menu")
- ->label(_("Settings"))
+ ->label(t("Settings"))
->append(Menu::factory("link")
->id("graphics_toolkits")
- ->label(_("Graphics"))
+ ->label(t("Graphics"))
->url(url::site("admin/graphics"))))
->append(Menu::factory("link")
->id("modules")
- ->label(_("Modules"))
+ ->label(t("Modules"))
->url(url::site("admin/modules")))
->append(Menu::factory("submenu")
->id("content_menu")
- ->label(_("Content")))
+ ->label(t("Content")))
->append(Menu::factory("submenu")
->id("presentation_menu")
- ->label(_("Presentation"))
+ ->label(t("Presentation"))
->append(Menu::factory("link")
->id("themes")
- ->label(_("Themes"))
+ ->label(t("Themes"))
->url(url::site("admin/themes")))
->append(Menu::factory("link")
->id("image_sizes")
- ->label(_("Image Sizes"))
+ ->label(t("Image Sizes"))
->url("#")))
->append(Menu::factory("submenu")
->id("users_groups_menu")
- ->label(_("Users/Groups")))
+ ->label(t("Users/Groups")))
->append(Menu::factory("link")
->id("maintenance")
- ->label(_("Maintenance"))
+ ->label(t("Maintenance"))
->url(url::site("admin/maintenance")))
->append(Menu::factory("submenu")
->id("statistics_menu")
- ->label(_("Statistics"))
+ ->label(t("Statistics"))
->url("#"));
}
}
diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php
index 83a08004..847de665 100644
--- a/core/helpers/graphics.php
+++ b/core/helpers/graphics.php
@@ -217,10 +217,13 @@ class graphics_Core {
$count = self::find_dirty_images_query()->count();
if ($count) {
site_status::warning(
- sprintf(_("%d of your photos are out of date. %sClick here to fix them%s"),
- $count, "<a href=\"" .
- url::site("admin/maintenance/start/graphics::rebuild_dirty_images?csrf=__CSRF__") .
- "\" class=\"gDialogLink\">", "</a>"),
+ t(array("one" => "One of your photos is out of date. {{link_start}}Click here to fix it{{link_end}}",
+ "other" => "{{count}} of your photos are out of date. {{link_start}}Click here to fix them{{link_end}}"),
+ array("count" => $count,
+ "link_start" => "<a href=\"" .
+ url::site("admin/maintenance/start/graphics::rebuild_dirty_images?csrf=__CSRF__") .
+ "\" class=\"gDialogLink\">",
+ "link_end" => "</a>")),
"graphics_dirty");
}
}
@@ -251,8 +254,10 @@ class graphics_Core {
}
}
- $task->status = sprintf(
- _("Updated %d out of %d images"), $completed, $remaining + $completed);
+ $task->status = t(array("one" => "Updated: 1 image. Total: {{total_count}}.",
+ "other" => "Updated: {{count}} images. Total: {{total_count}}."),
+ array("count" => $completed,
+ "total_count" => ($remaining + $completed)));
if ($completed + $remaining > 0) {
$task->percent_complete = (int)(100 * $completed / ($completed + $remaining));
diff --git a/core/helpers/module.php b/core/helpers/module.php
index 9bce7a44..4b98674e 100644
--- a/core/helpers/module.php
+++ b/core/helpers/module.php
@@ -127,7 +127,7 @@ class module_Core {
}
self::load_modules();
- log::success("module", sprintf(_("Installed module %s"), $module_name));
+ log::success("module", t("Installed module {{module_name}}", array("module_name" => $module_name)));
}
/**
@@ -137,7 +137,7 @@ class module_Core {
$installer_class = "{$module_name}_installer";
Kohana::log("debug", "$installer_class uninstall");
call_user_func(array($installer_class, "uninstall"));
- log::success("module", sprintf(_("Uninstalled module %s"), $module_name));
+ log::success("module", t("Uninstalled module {{module_name}}", array("module_name" => $module_name)));
}
/**
diff --git a/core/helpers/photo.php b/core/helpers/photo.php
index 29f2ac6f..749efb87 100644
--- a/core/helpers/photo.php
+++ b/core/helpers/photo.php
@@ -96,13 +96,13 @@ class photo_Core {
static function get_add_form($parent) {
$form = new Forge("albums/{$parent->id}", "", "post", array("id" => "gAddPhotoForm"));
- $group = $form->group("add_photo")->label(sprintf(_("Add Photo to %s"), $parent->title));
- $group->input("name")->label(_("Name"));
- $group->input("title")->label(_("Title"));
- $group->textarea("description")->label(_("Description"));
- $group->upload("file")->label(_("File"))->rules("required|allow[jpg,png,gif]");
+ $group = $form->group("add_photo")->label(t("Add Photo to {{album_title}}", array("album_title" =>$parent->title)));
+ $group->input("name")->label(t("Name"));
+ $group->input("title")->label(t("Title"));
+ $group->textarea("description")->label(t("Description"));
+ $group->upload("file")->label(t("File"))->rules("required|allow[jpg,png,gif]");
$group->hidden("type")->value("photo");
- $group->submit(_("Upload"));
+ $group->submit(t("Upload"));
$form->add_rules_from(ORM::factory("item"));
return $form;
}
@@ -110,11 +110,11 @@ class photo_Core {
static function get_edit_form($photo) {
$form = new Forge("photos/$photo->id", "", "post", array("id" => "gEditPhotoForm"));
$form->hidden("_method")->value("put");
- $group = $form->group("edit_photo")->label(_("Edit Photo"));
- $group->input("name")->label(_("Name"))->value($photo->name);
- $group->input("title")->label(_("Title"))->value($photo->title);
- $group->textarea("description")->label(_("Description"))->value($photo->description);
- $group->submit(_("Modify"));
+ $group = $form->group("edit_photo")->label(t("Edit Photo"));
+ $group->input("name")->label(t("Name"))->value($photo->name);
+ $group->input("title")->label(t("Title"))->value($photo->title);
+ $group->textarea("description")->label(t("Description"))->value($photo->description);
+ $group->submit(t("Modify"));
$form->add_rules_from(ORM::factory("item"));
return $form;
}