From b4f458641a99d3504539c530b07f0ef948477cab Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Mon, 21 Jul 2008 22:49:17 +0000 Subject: [PATCH] ActionItem523: adding __ as a shortcut for Noosfero.term plus translation --- app/views/shared/user_menu.rhtml | 2 +- lib/noosfero.rb | 4 +--- lib/noosfero/core_ext.rb | 1 + lib/noosfero/core_ext/object.rb | 5 +++++ lib/tasks/gettext.rake | 1 + lib/zen3_terminology.rb | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 lib/noosfero/core_ext/object.rb diff --git a/app/views/shared/user_menu.rhtml b/app/views/shared/user_menu.rhtml index 71b285f..9ba4b51 100644 --- a/app/views/shared/user_menu.rhtml +++ b/app/views/shared/user_menu.rhtml @@ -17,7 +17,7 @@
  • <%= Noosfero.term(N_('My Home Page')) %>
  • + ><%= __('My Home Page') %> diff --git a/lib/noosfero.rb b/lib/noosfero.rb index 0762da4..b9f8a8d 100644 --- a/lib/noosfero.rb +++ b/lib/noosfero.rb @@ -1,5 +1,3 @@ -require 'gettext' - module Noosfero PROJECT = 'noosfero' VERSION = '0.11.0' @@ -33,7 +31,7 @@ module Noosfero end def self.term(t) - gettext(self.terminology.get(t)) + self.terminology.get(t) end def self.terminology @terminology ||= Noosfero::Terminology::Default.new diff --git a/lib/noosfero/core_ext.rb b/lib/noosfero/core_ext.rb index 77e5530..2ee7dbf 100644 --- a/lib/noosfero/core_ext.rb +++ b/lib/noosfero/core_ext.rb @@ -1,2 +1,3 @@ require 'noosfero/core_ext/string' require 'noosfero/core_ext/integer' +require 'noosfero/core_ext/object' diff --git a/lib/noosfero/core_ext/object.rb b/lib/noosfero/core_ext/object.rb new file mode 100644 index 0000000..c7f3ba9 --- /dev/null +++ b/lib/noosfero/core_ext/object.rb @@ -0,0 +1,5 @@ +class Object + def __(*args) + gettext(Noosfero.term(*args)) + end +end diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index fc7e496..42d6bc5 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -13,6 +13,7 @@ end desc "Update pot/po files to match new version." task :updatepo do require 'gettext/utils' + GetText::RubyParser::ID << '__' GetText::ActiveRecordParser.init(:use_classname => false) GetText.update_pofiles(Noosfero::PROJECT, Dir.glob("{app,lib,public/designs}/**/*.{rb,rhtml}"), "#{Noosfero::PROJECT} #{Noosfero::VERSION}") diff --git a/lib/zen3_terminology.rb b/lib/zen3_terminology.rb index 1a5d772..4c3021d 100644 --- a/lib/zen3_terminology.rb +++ b/lib/zen3_terminology.rb @@ -4,6 +4,7 @@ class Zen3Terminology < Noosfero::Terminology::Custom include GetText def initialize + # NOTE: the hash values must be marked for translation!! super({ 'My Home Page' => N_('My ePortfolio'), }) -- libgit2 0.21.2