Package: ruby-gettext-i18n-rails
Version: 0.9.4-1
Severity: grave
Debian Release: 8.0
Tags: patch
The rake task is incompatible with with ruby-gettext version 3.
This was fixed in v1.0.0.
commit d1b02f734f9e0c96de50d1a58e8170ce6ec457ac
Author: Kouhei Sutou k...@clear-code.com
Date: Mon Sep 16 18:42:13 2013 +0900
Use GetText::Tools::Task introduced since gettext 3.0.0
and
commit 6c83ce9255122ddb0c28ec5ca96e5a1975a8e0c8
Author: grosser grosser.mich...@gmail.com
Date: Sun Sep 29 17:47:38 2013 -0700
bump gettext requirement
Attached is a squashed and (kind of) minimized patch of both commits.
As a site notice: the package needs to be rebuild for compatibility with
Ruby 2.1, as it just provides GEM specs for Ruby 1.9.1 and 1.8.
Jan-Marek
diff --git a/lib/gettext_i18n_rails/tasks.rb b/lib/gettext_i18n_rails/tasks.rb
index 4d1a0d0..2f7121f 100644
--- a/lib/gettext_i18n_rails/tasks.rb
+++ b/lib/gettext_i18n_rails/tasks.rb
@@ -1,55 +1,48 @@
+require gettext/tools/task
+gem gettext, = 3.0.2
+
namespace :gettext do
- def load_gettext
-require 'gettext'
-require 'gettext/utils'
+ def locale_path
+path = FastGettext.translation_repositories[text_domain].instance_variable_get(:@options)[:path] rescue nil
+path || File.join(Rails.root, locale)
end
- desc Create mo-files for L10n
- task :pack = :environment do
-load_gettext
-GetText.create_mofiles(true, locale_path, locale_path)
+ def text_domain
+# if your textdomain is not 'app': require the environment before calling e.g. gettext:find OR add TEXTDOMAIN=my_domain
+ENV['TEXTDOMAIN'] || (FastGettext.text_domain rescue nil) || app
end
- desc Update pot/po files.
- task :find = :environment do
-load_gettext
-$LOAD_PATH File.join(File.dirname(__FILE__),'..','..','lib') # needed when installed as plugin
-
-require gettext_i18n_rails/haml_parser
-require gettext_i18n_rails/slim_parser
+ # do not rename, gettext_i18n_rails_js overwrites this to inject coffee + js
+ def files_to_translate
+Dir.glob({app,lib,config,#{locale_path}}/**/*.{rb,erb,haml,slim})
+ end
-if GetText.respond_to? :update_pofiles_org
- if defined?(Rails.application)
-msgmerge = Rails.application.config.gettext_i18n_rails.msgmerge
- end
- msgmerge ||= %w[--sort-output --no-location --no-wrap]
+ $LOAD_PATH File.join(File.dirname(__FILE__),'..','..','lib') # needed when installed as plugin
+
+ require gettext_i18n_rails/haml_parser
+ require gettext_i18n_rails/slim_parser
+
+ GetText::Tools::Task.define do |task|
+task.package_name = text_domain
+task.package_version = 1.0.0
+task.domain = text_domain
+task.po_base_directory = locale_path
+task.mo_base_directory = locale_path
+task.files = files_to_translate
+task.enable_description = false
+if defined?(Rails.application)
+ msgmerge = Rails.application.config.gettext_i18n_rails.msgmerge
+end
+msgmerge ||= %w[--sort-output --no-location --no-wrap]
+task.msgmerge_options = msgmerge
+ end
- GetText.update_pofiles_org(
-text_domain,
-files_to_translate,
-version 0.0.1,
-:po_root = locale_path,
-:msgmerge = msgmerge
- )
-else #we are on a version 2.0
- puts install new GetText with gettext:install to gain more features...
- #kill ar parser...
- require 'gettext/parser/active_record'
- module GetText
-module ActiveRecordParser
- module_function
- def init(x);end
-end
- end
+ desc Create mo-files for L10n
+ task :pack = [:environment, gettext:gettext:mo:update] do
+ end
- #parse files.. (models are simply parsed as ruby files)
- GetText.update_pofiles(
-text_domain,
-files_to_translate,
-version 0.0.1,
-locale_path
- )
-end
+ desc Update pot/po files.
+ task :find = [:environment, gettext:gettext:po:update] do
end
# This is more of an example, ignoring
@@ -92,35 +84,9 @@ namespace :gettext do
puts You need to specify the language to add. Either 'LANGUAGE=eo rake gettext:add_languange' or 'rake gettext:add_languange[eo]'
next
end
-pot = File.join(locale_path, #{text_domain}.pot)
-if !File.exists? pot
- puts You don't have a pot file yet, you probably should run 'rake gettext:find' at least once. Tried '#{pot}'.
- next
-end
-
-# Create the directory for the new language.
-dir = File.join(locale_path, language)
-puts Creating directory #{dir}
-Dir.mkdir dir
-
-# Create the po file for the new language.
-new_po = File.join(locale_path, language, #{text_domain}.po)
-puts Initializing #{new_po} from #{pot}.
-system msginit --locale=#{language} --input=#{pot} --output=#{new_po}
- end
- def locale_path
-path = FastGettext.translation_repositories[text_domain].instance_variable_get(:@options)[:path] rescue nil
-path ||