ref: refs/heads/dmacvicar_log_viewer
commit 09d98e94e9b029410096e1e31e835243cb49aab0
Author: Stefan Schubert
Date: Thu Sep 3 17:10:21 2009 +0200
give the possibility to take vendor specific translations in order to change text
---
Rakefile | 2 +-
.../app/controllers/application_controller.rb | 20 ++++++++++++++++++++
webclient/public/vendor/text/Rakefile | 18 ++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/Rakefile b/Rakefile
index 9a59aa7..f549b0e 100644
--- a/Rakefile
+++ b/Rakefile
@@ -6,7 +6,7 @@ desc 'Run all tests by default'
task :default => :test
-%w(test test:ui rdoc pgem package release install install_policies check_syntax package-local buildrpm buildrpm-local test:test:rcov).each do |task_name|
+%w(makemo test test:ui rdoc pgem package release install install_policies check_syntax package-local buildrpm buildrpm-local test:test:rcov).each do |task_name|
desc "Run #{task_name} task for all projects"
task task_name do
PROJECTS.each do |project|
diff --git a/webclient/app/controllers/application_controller.rb b/webclient/app/controllers/application_controller.rb
index cfe4e97..23cb47b 100644
--- a/webclient/app/controllers/application_controller.rb
+++ b/webclient/app/controllers/application_controller.rb
@@ -63,6 +63,25 @@ class ApplicationController < ActionController::Base
end
end
+ def self.init_gettext(domainname, options = {})
+ locale_path = options[:locale_path]
+ unless locale_path
+ #If path of the translation has not been set we are trying to load
+ #vendor specific translations too
+ if Dir.glob(File.join("**", "public", "**", "#{domainname}.mo")).size > 0
+ locale_path = File.join(RAILS_ROOT, "public/vendor/text/locale")
+ opt = {:locale_path => locale_path}.merge(options)
+ ActionController::Base.init_gettext(domainname, opt)
+ else
+ #load default no vendor translation available
+ ActionController::Base.init_gettext(domainname, options)
+ end
+ else
+ #load default if the path has been given
+ ActionController::Base.init_gettext(domainname, options)
+ end
+ end
+
# Initialize GetText and Content-Type.
# You need to call this once a request from WWW browser.
# You can select the scope of the textdomain.
@@ -84,6 +103,7 @@ class ApplicationController < ActionController::Base
end
=end
+
=begin
# you can redefined the title/explanation of the top of the error message.
ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_title(N_("An error is occured on %{record}"), N_("%{num} errors are occured on %{record}"))
diff --git a/webclient/public/vendor/text/Rakefile b/webclient/public/vendor/text/Rakefile
new file mode 100644
index 0000000..9a0ee5e
--- /dev/null
+++ b/webclient/public/vendor/text/Rakefile
@@ -0,0 +1,18 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake.
+
+require 'rake'
+
+require 'gettext_rails/tools'
+desc "Create mo-files for L10n"
+task :makemo do
+ GetText.create_mofiles
+end
+
+desc "Update pot/po files to match new version."
+task :updatepo do
+ GetText.update_pofiles("lang_helper", Dir.glob("lib/*.{rb,rhtml}"),
+ "lang_helper 1.3.0")
+end
+
+task :default => :makemo
\ No newline at end of file
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org