From e4a9b19bf9997f46203fbc18c696c63703a72625 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Thu, 15 Jan 2009 10:02:41 +0000 Subject: Changing t() placeholder syntax from {{replace_me}} to %replace_me. --- core/controllers/admin_dashboard.php | 6 +++--- core/controllers/admin_graphics.php | 2 +- core/controllers/admin_maintenance.php | 14 +++++++------- core/controllers/admin_modules.php | 4 ++-- core/controllers/admin_themes.php | 6 +++--- core/controllers/albums.php | 6 +++--- core/controllers/photos.php | 2 +- core/helpers/album.php | 2 +- core/helpers/core_installer.php | 2 +- core/helpers/graphics.php | 8 ++++---- core/helpers/module.php | 4 ++-- core/helpers/photo.php | 2 +- core/libraries/I18n.php | 8 ++++++-- core/tests/I18n_Test.php | 16 ++++++++-------- core/views/admin_block_platform.html.php | 8 ++++---- core/views/admin_block_stats.html.php | 6 +++--- core/views/admin_block_welcome.html.php | 6 +++--- core/views/admin_graphics_gd.html.php | 6 +++--- core/views/admin_graphics_graphicsmagick.html.php | 4 ++-- core/views/admin_graphics_imagemagick.html.php | 4 ++-- core/views/admin_maintenance.html.php | 2 +- core/views/admin_themes.html.php | 4 ++-- core/views/admin_themes_preview.html.php | 2 +- 23 files changed, 64 insertions(+), 60 deletions(-) (limited to 'core') diff --git a/core/controllers/admin_dashboard.php b/core/controllers/admin_dashboard.php index 43b61868..15701417 100644 --- a/core/controllers/admin_dashboard.php +++ b/core/controllers/admin_dashboard.php @@ -42,12 +42,12 @@ class Admin_Dashboard_Controller extends Admin_Controller { if ($form->add_block->center->value) { dashboard::add_block("main", $module_name, $block_id); message::success( - t("Added {{title}} block to the main dashboard area", + t("Added %title block to the main dashboard area", array("title" => $available["$module_name:$id"]))); } else { dashboard::add_block("sidebar", $module_name, $block_id); message::success( - t("Added {{title}} to the dashboard sidebar", + t("Added %title to the dashboard sidebar", array("title" => $available["$module_name:$id"]))); } } @@ -68,7 +68,7 @@ class Admin_Dashboard_Controller extends Admin_Controller { if (!empty($deleted)) { $available = dashboard::get_available(); $title = $available[join(":", $deleted)]; - message::success(t("Removed {{title}} block", array("title" => $title))); + message::success(t("Removed %title block", array("title" => $title))); } url::redirect("admin"); diff --git a/core/controllers/admin_graphics.php b/core/controllers/admin_graphics.php index 69a83575..fe71a222 100644 --- a/core/controllers/admin_graphics.php +++ b/core/controllers/admin_graphics.php @@ -50,7 +50,7 @@ class Admin_Graphics_Controller extends Admin_Controller { site_status::clear("missing_graphics_toolkit"); message::success(t("Updated Graphics Toolkit")); - log::success("graphics", t("Changed graphics toolkit to: {{toolkit}}", + log::success("graphics", t("Changed graphics toolkit to: %toolkit", array("toolkit" => $toolkit))); } diff --git a/core/controllers/admin_maintenance.php b/core/controllers/admin_maintenance.php index 1c9b4164..6b344243 100644 --- a/core/controllers/admin_maintenance.php +++ b/core/controllers/admin_maintenance.php @@ -31,7 +31,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { "description" => ( $dirty_count ? t2("You have one image which is out of date", - "You have {{count}} out-of-date images", + "You have %count out-of-date images", $dirty_count) : t("All your images are up to date")), "severity" => $dirty_count ? log::WARNING : log::SUCCESS), @@ -51,9 +51,9 @@ class Admin_Maintenance_Controller extends Admin_Controller { if ($stalled_count) { log::warning("tasks", t2("One task is stalled", - "{{count}} tasks are stalled", + "%count tasks are stalled", $stalled_count), - t("{{link_start}}view{{link_end}}", + t("%link_startview%link_end", array("link_start" => "", "link_start" => ""))); } @@ -89,7 +89,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { $view->csrf = access::csrf_token(); $view->task = $task; - log::info("tasks", t("Task {{task_name}} started (task id {{task_id}})", + log::info("tasks", t("Task %task_name started (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor(url::site("admin/maintenance"), t("maintenance"))); print $view; @@ -110,7 +110,7 @@ class Admin_Maintenance_Controller extends Admin_Controller { $view->csrf = access::csrf_token(); $view->task = $task; - log::info("tasks", t("Task {{task_name}} resumed (task id {{task_id}})", + log::info("tasks", t("Task %task_name resumed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor(url::site("admin/maintenance"), t("maintenance"))); print $view; @@ -171,14 +171,14 @@ class Admin_Maintenance_Controller extends Admin_Controller { if ($task->done) { switch ($task->state) { case "success": - log::success("tasks", t("Task {{task_name}} completed (task id {{task_id}})", + log::success("tasks", t("Task %task_name completed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor(url::site("admin/maintenance"), t("maintenance"))); message::success(t("Task completed successfully")); break; case "error": - log::error("tasks", t("Task {{task_name}} failed (task id {{task_id}})", + log::error("tasks", t("Task %task_name failed (task id %task_id)", array("task_name" => $task->name, "task_id" => $task->id)), html::anchor(url::site("admin/maintenance"), t("maintenance"))); message::success(t("Task failed")); diff --git a/core/controllers/admin_modules.php b/core/controllers/admin_modules.php index e345f8c6..2cd56c85 100644 --- a/core/controllers/admin_modules.php +++ b/core/controllers/admin_modules.php @@ -34,10 +34,10 @@ class Admin_Modules_Controller extends Admin_Controller { $desired = $this->input->post($module_name) == 1; if ($info->installed && !$desired) { module::uninstall($module_name); - message::success(t("Uninstalled {{module_name}} module", array("module_name" => $info->name))); + message::success(t("Uninstalled %module_name module", array("module_name" => $info->name))); } else if (!$info->installed && $desired) { module::install($module_name); - message::success(t("Installed {{module_name}} module", array("module_name" => $info->name))); + message::success(t("Installed %module_name module", array("module_name" => $info->name))); } } url::redirect("admin/modules"); diff --git a/core/controllers/admin_themes.php b/core/controllers/admin_themes.php index b2e0b0e2..194b9d17 100644 --- a/core/controllers/admin_themes.php +++ b/core/controllers/admin_themes.php @@ -63,11 +63,11 @@ class Admin_Themes_Controller extends Admin_Controller { if ($type == "admin" && $info->admin) { module::set_var("core", "active_admin_theme", $theme_name); - message::success(t("Successfully changed your admin theme to {{theme_name}}", + message::success(t("Successfully changed your admin theme to %theme_name", array("theme_name" => $info->name))); } else if ($type == "site" && $info->site) { module::set_var("core", "active_site_theme", $theme_name); - message::success(t("Successfully changed your Gallery theme to {{theme_name}}", + message::success(t("Successfully changed your Gallery theme to %theme_name", array("theme_name" => $info->name))); } @@ -109,7 +109,7 @@ class Admin_Themes_Controller extends Admin_Controller { if ($theme != module::get_var("core", "active_theme")) { module::set_var("core", "active_theme", $theme); message::success(t("Updated Theme")); - log::success("graphics", t("Changed theme to {{theme_name}}", array("theme_name" => $theme))); + log::success("graphics", t("Changed theme to %theme_name", array("theme_name" => $theme))); } url::redirect("admin/themes"); } diff --git a/core/controllers/albums.php b/core/controllers/albums.php index 0150314c..39946e60 100644 --- a/core/controllers/albums.php +++ b/core/controllers/albums.php @@ -93,7 +93,7 @@ class Albums_Controller extends Items_Controller { log::success("content", "Created an album", html::anchor("albums/$new_album->id", "view album")); - message::success(t("Created album {{album_title}}", array("album_title" => $new_album->title))); + message::success(t("Created album %album_title", array("album_title" => $new_album->title))); print json_encode( array("result" => "success", @@ -123,7 +123,7 @@ class Albums_Controller extends Items_Controller { user::active()->id); log::success("content", "Added a photo", html::anchor("photos/$photo->id", "view photo")); - message::success(t("Added photo {{photo_title}}", array("photo_title" => $photo->title))); + message::success(t("Added photo %photo_title", array("photo_title" => $photo->title))); print json_encode( array("result" => "success", @@ -155,7 +155,7 @@ class Albums_Controller extends Items_Controller { module::event("item_updated", $orig, $album); log::success("content", "Updated album", "id\">view"); - message::success(t("Saved album {{album_title}}", array("album_title" => $album->title))); + message::success(t("Saved album %album_title", array("album_title" => $album->title))); print json_encode( array("result" => "success", diff --git a/core/controllers/photos.php b/core/controllers/photos.php index ae1c6a3b..829f391f 100644 --- a/core/controllers/photos.php +++ b/core/controllers/photos.php @@ -81,7 +81,7 @@ class Photos_Controller extends Items_Controller { module::event("item_updated", $orig, $photo); log::success("content", "Updated photo", "id\">view"); - message::success(t("Saved photo {{photo_title}}", array("photo_title" => $photo->title))); + message::success(t("Saved photo %photo_title", array("photo_title" => $photo->title))); print json_encode( array("result" => "success", diff --git a/core/helpers/album.php b/core/helpers/album.php index e1875b3a..223a057d 100644 --- a/core/helpers/album.php +++ b/core/helpers/album.php @@ -65,7 +65,7 @@ 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(t("Add Album to {{album_title}}", array("album_title" => $parent->title))); + $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")); diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index 3ee67358..b8f50561 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -219,7 +219,7 @@ class core_installer { } if (!module::get_var("core", "graphics_toolkit")) { site_status::warning( - t("Graphics toolkit missing! Please {{link_start}}choose a toolkit{{link_start}}.", + t("Graphics toolkit missing! Please %link_startchoose a toolkit%link_start.", array("link_start" => "", "link_end" => "")), "missing_graphics_toolkit"); } diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php index 7b13c55d..2edfb5f8 100644 --- a/core/helpers/graphics.php +++ b/core/helpers/graphics.php @@ -217,8 +217,8 @@ class graphics_Core { $count = self::find_dirty_images_query()->count(); if ($count) { site_status::warning( - t2("One of your photos is out of date. {{link_start}}Click here to fix it{{link_end}}", - "{{count}} of your photos are out of date. {{link_start}}Click here to fix them{{link_end}}", + t2("One of your photos is out of date. %link_startClick here to fix it%link_end", + "%count of your photos are out of date. %link_startClick here to fix them%link_end", $count, array("link_start" => "status = t2("Updated: 1 image. Total: {{total_count}}.", - "Updated: {{count}} images. Total: {{total_count}}.", + $task->status = t2("Updated: 1 image. Total: %total_count.", + "Updated: %count images. Total: %total_count.", $completed, array("total_count" => ($remaining + $completed))); diff --git a/core/helpers/module.php b/core/helpers/module.php index bded9dc6..b45f6c78 100644 --- a/core/helpers/module.php +++ b/core/helpers/module.php @@ -129,7 +129,7 @@ class module_Core { } self::load_modules(); - log::success("module", t("Installed module {{module_name}}", array("module_name" => $module_name))); + log::success("module", t("Installed module %module_name", array("module_name" => $module_name))); } /** @@ -140,7 +140,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", t("Uninstalled module {{module_name}}", array("module_name" => $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 74ef02e0..a2958aec 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -97,7 +97,7 @@ 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(t("Add Photo to {{album_title}}", array("album_title" =>$parent->title))); + $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")); diff --git a/core/libraries/I18n.php b/core/libraries/I18n.php index 0aa6652b..04176b75 100644 --- a/core/libraries/I18n.php +++ b/core/libraries/I18n.php @@ -68,7 +68,7 @@ class I18n_Core { /** * Translates a localizable message. * @param $message String|array The message to be translated. E.g. "Hello world" - * or array("one" => "One album", "other" => "{{count}} albums") + * or array("one" => "One album", "other" => "%count albums") * @param $options array (optional) Options array for key value pairs which are used * for pluralization and interpolation. Special keys are "count" and "locale", * the latter to override the currently configured locale. @@ -118,9 +118,13 @@ class I18n_Core { private function interpolate($locale, $string, $values) { // TODO: Handle locale specific number formatting. + + // Replace x_y before replacing x. + krsort($values, SORT_STRING); + $keys = array(); foreach (array_keys($values) as $key) { - $keys[] = "{{" . $key . "}}"; + $keys[] = "%$key"; } return str_replace($keys, array_values($values), $string); } diff --git a/core/tests/I18n_Test.php b/core/tests/I18n_Test.php index f99dd9c1..e621c0e3 100644 --- a/core/tests/I18n_Test.php +++ b/core/tests/I18n_Test.php @@ -34,10 +34,10 @@ class I18n_Test extends Unit_Test_Case { $messages_de_DE = array( array('Hello world', 'Hallo Welt'), array(array('one' => 'One item has been added', - 'other' => '{{count}} elements have been added'), + 'other' => '%count elements have been added'), array('one' => 'Ein Element wurde hinzugefuegt.', - 'other' => '{{count}} Elemente wurden hinzugefuegt.')), - array('Hello {{name}}, how are you today?', 'Hallo {{name}}, wie geht es Dir heute?')); + 'other' => '%count Elemente wurden hinzugefuegt.')), + array('Hello %name, how are you today?', 'Hallo %name, wie geht es Dir heute?')); foreach ($messages_de_DE as $data) { list ($message, $translation) = $data; @@ -65,25 +65,25 @@ class I18n_Test extends Unit_Test_Case { public function translate_plural_other_test() { $result = $this->i18n->translate(array('one' => 'One item has been added', - 'other' => '{{count}} items have been added.'), + 'other' => '%count items have been added.'), array('count' => 5)); $this->assert_equal('5 Elemente wurden hinzugefuegt.', $result); } public function translate_plural_one_test() { $result = $this->i18n->translate(array('one' => 'One item has been added', - 'other' => '{{count}} items have been added.'), + 'other' => '%count items have been added.'), array('count' => 1)); $this->assert_equal('Ein Element wurde hinzugefuegt.', $result); } public function translate_interpolate_test() { - $result = $this->i18n->translate('Hello {{name}}, how are you today?', array('name' => 'John')); + $result = $this->i18n->translate('Hello %name, how are you today?', array('name' => 'John')); $this->assert_equal('Hallo John, wie geht es Dir heute?', $result); } public function translate_interpolate_missing_value_test() { - $result = $this->i18n->translate('Hello {{name}}, how are you today?', array('foo' => 'bar')); - $this->assert_equal('Hallo {{name}}, wie geht es Dir heute?', $result); + $result = $this->i18n->translate('Hello %name, how are you today?', array('foo' => 'bar')); + $this->assert_equal('Hallo %name, wie geht es Dir heute?', $result); } } \ No newline at end of file diff --git a/core/views/admin_block_platform.html.php b/core/views/admin_block_platform.html.php index 2f13d5d9..09fc0515 100644 --- a/core/views/admin_block_platform.html.php +++ b/core/views/admin_block_platform.html.php @@ -1,15 +1,15 @@ diff --git a/core/views/admin_block_stats.html.php b/core/views/admin_block_stats.html.php index 42f34aa4..2d975073 100644 --- a/core/views/admin_block_stats.html.php +++ b/core/views/admin_block_stats.html.php @@ -1,12 +1,12 @@ diff --git a/core/views/admin_block_welcome.html.php b/core/views/admin_block_welcome.html.php index 35501ffc..89914fb3 100644 --- a/core/views/admin_block_welcome.html.php +++ b/core/views/admin_block_welcome.html.php @@ -4,15 +4,15 @@

diff --git a/core/views/admin_graphics_gd.html.php b/core/views/admin_graphics_gd.html.php index b238401f..8c645f4f 100644 --- a/core/views/admin_graphics_gd.html.php +++ b/core/views/admin_graphics_gd.html.php @@ -3,16 +3,16 @@ " alt="" />

- GD website for more information.", + GD website for more information.", array("url" => "http://www.boutell.com/gd")) ?>

gd["GD Version"] && function_exists('imagerotate')): ?>

- $tk->gd["GD Version"])) ?> + $tk->gd["GD Version"])) ?>

gd["GD Version"]): ?>

- $tk->gd["GD Version"])) ?>

diff --git a/core/views/admin_graphics_graphicsmagick.html.php b/core/views/admin_graphics_graphicsmagick.html.php index 8dc1d714..bb4f906d 100644 --- a/core/views/admin_graphics_graphicsmagick.html.php +++ b/core/views/admin_graphics_graphicsmagick.html.php @@ -3,12 +3,12 @@

" alt="" />

- GraphicsMagick website for more information.", + GraphicsMagick website for more information.", array("url" => "http://www.graphicsmagick.org")) ?>

graphicsmagick): ?>

- $tk->graphicsmagick)) ?> + $tk->graphicsmagick)) ?>

diff --git a/core/views/admin_graphics_imagemagick.html.php b/core/views/admin_graphics_imagemagick.html.php index 02a18ac8..7898a8d1 100644 --- a/core/views/admin_graphics_imagemagick.html.php +++ b/core/views/admin_graphics_imagemagick.html.php @@ -3,12 +3,12 @@

" alt="" />

- ImageMagick website for more information.", + ImageMagick website for more information.", array("url" => "http://www.imagemagick.org")) ?>

imagemagick): ?>

- $tk->imagemagick)) ?> + $tk->imagemagick)) ?>

diff --git a/core/views/admin_maintenance.html.php b/core/views/admin_maintenance.html.php index 1da87788..fd5f7a58 100644 --- a/core/views/admin_maintenance.html.php +++ b/core/views/admin_maintenance.html.php @@ -75,7 +75,7 @@ state == "stalled"): ?> - $task->percent_complete)) ?> + $task->percent_complete)) ?> diff --git a/core/views/admin_themes.html.php b/core/views/admin_themes.html.php index b0b4215d..43328b3a 100644 --- a/core/views/admin_themes.html.php +++ b/core/views/admin_themes.html.php @@ -31,7 +31,7 @@ site) continue ?>

- " class="gDialogLink" title=" $info->name)) ?>"> + " class="gDialogLink" title=" $info->name)) ?>"> " alt="name ?>" />

name ?>

@@ -69,7 +69,7 @@ admin) continue ?>