diff --git a/Gemfile b/Gemfile index 1984fa7..4cd70f0 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,8 @@ gem 'rake', :require => false gem 'grape', '0.2.1' gem 'rest-client' gem 'exception_notification' +gem 'gettext_i18n_rails' +gem 'gettext', '>=3.0.2', :require => false, :group => :development # FIXME list here all actual dependencies (i.e. the ones in debian/control), # with their GEM names (not the Debian package names) diff --git a/Gemfile.lock b/Gemfile.lock index a585c84..c3b3677 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,22 +67,49 @@ GEM activesupport (>= 3.0.4) fast_gettext (0.6.8) ffi (1.0.11) + gettext (3.1.4) + locale (>= 2.0.5) + text + gettext_i18n_rails (1.0.5) + fast_gettext (>= 0.4.8) gherkin (2.4.21) json (>= 1.4.6) + gitlab (3.1.0) + httparty + terminal-table + grape (0.2.1) + hashie (~> 1.2) + multi_json + multi_xml + rack + rack-mount + hashie (1.2.0) hike (1.2.1) hpricot (0.8.6) + httparty (0.11.0) + multi_json (~> 1.0) + multi_xml (>= 0.5.2) i18n (0.6.0) + jenkins_api_client (0.14.1) + json + mixlib-shellout (>= 1.1.0) + nokogiri (~> 1.5.0) + terminal-table (>= 1.4.0) + thor (>= 0.16.0) journey (1.0.3) json (1.7.3) + locale (2.1.0) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) mime-types (1.19) + mixlib-shellout (1.4.0) mocha (0.11.3) metaclass (~> 0.0.1) multi_json (1.3.6) + multi_xml (0.5.5) nokogiri (1.5.5) pg (0.13.2) polyglot (0.3.3) @@ -91,6 +118,8 @@ GEM rack (1.4.1) rack-cache (1.2) rack (>= 0.4) + rack-mount (0.8.3) + rack (>= 1.0.0) rack-ssl (1.3.2) rack rack-test (0.6.1) @@ -143,11 +172,13 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) term-ansicolor (1.0.7) + terminal-table (1.4.5) + text (1.3.0) thin (1.3.1) daemons (>= 1.0.9) eventmachine (>= 0.12.6) rack (>= 1.0.0) - thor (0.15.3) + thor (0.19.1) tilt (1.3.3) treetop (1.4.10) polyglot @@ -172,7 +203,12 @@ DEPENDENCIES database_cleaner exception_notification fast_gettext + gettext (>= 3.0.2) + gettext_i18n_rails + gitlab (~> 3.1.0) + grape (= 0.2.1) hpricot + jenkins_api_client (~> 0.14.1) mocha nokogiri pg diff --git a/lib/noosfero/i18n.rb b/lib/noosfero/i18n.rb index 50227bc..46ac9c2 100644 --- a/lib/noosfero/i18n.rb +++ b/lib/noosfero/i18n.rb @@ -20,5 +20,5 @@ if File.exists?(locale_dir) repos << FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => locale_dir) end -FastGettext.add_text_domain 'noosferofull', :type => :chain, :chain => repos -FastGettext.default_text_domain = 'noosferofull' +FastGettext.add_text_domain 'noosfero', :type => :chain, :chain => repos +FastGettext.default_text_domain = 'noosfero' diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 21621ff..0597240 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -6,8 +6,8 @@ makemo_stamp = 'tmp/makemo.stamp' desc "Create mo-files for L10n" task :makemo => makemo_stamp file makemo_stamp => Dir.glob('po/*/noosfero.po') do - ruby '-I. -rconfig/boot -e \'require "gettext"; require "gettext/utils"; GetText.create_mofiles(true, "po", "locale")\'' Rake::Task['symlinkmo'].invoke + Rake::Task['gettext:pack'].invoke FileUtils.mkdir_p 'tmp' FileUtils.touch makemo_stamp end @@ -22,10 +22,12 @@ task :symlinkmo do 'pt' => 'pt_BR', } mkdir_p(Rails.root.join('locale')) - Dir.glob(Rails.root.join('locale/*')).each do |dir| + Dir.glob(Rails.root.join('po/*/')).each do |dir| lang = File.basename(dir) orig_lang = langmap[lang] || lang mkdir_p(Rails.root.join('locale', "#{lang}", 'LC_MESSAGES')) + ln_sf "../../po/#{lang}/noosfero.po", "locale/#{lang}/noosfero.po" + ln_sf "../../po/#{lang}/noosfero-doc.po", "locale/#{lang}/noosfero-doc.po" ['iso_3166'].each do |domain| origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo" target = Rails.root.join('locale', "#{lang}", 'LC_MESSAGES', "#{domain}.mo") @@ -36,23 +38,21 @@ task :symlinkmo do end end -desc "Update pot/po files to match new version." -task :updatepo do - require 'gettext_rails/tools' - require_dependency 'noosfero' - - GetText::RubyParser::ID << '__' - GetText::RubyParser::PLURAL_ID << 'n__' - GetText::ActiveRecordParser.init(:use_classname => false) +namespace :gettext do + def files_to_translate + sources = + Dir.glob("{app,lib}/**/*.{rb,rhtml,erb}") + + Dir.glob('config/initializers/*.rb') + + Dir.glob('public/*.html.erb') + + Dir.glob('public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}') + + Dir.glob('plugins/**/{controllers,models,lib,views}/**/*.{rhtml,html.erb,rb}') + end +end +desc "Update pot/po files to match new version." +task :updatepo => :symlinkmo do puts 'Extracting strings from source. This may take a while ...' - sources = - Dir.glob("{app,lib}/**/*.{rb,rhtml,erb}") + - Dir.glob('config/initializers/*.rb') + - Dir.glob('public/*.html.erb') + - Dir.glob('public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}') + - Dir.glob('plugins/**/{controllers,models,lib,views}/**/*.{rhtml,html.erb,rb}') - GetText.update_pofiles(Noosfero::PROJECT, sources, "#{Noosfero::PROJECT} #{Noosfero::VERSION}") + Rake::Task['gettext:find'].invoke end task :checkpo do diff --git a/test/unit/dates_helper_test.rb b/test/unit/dates_helper_test.rb index 238ae0d..9bf8002 100644 --- a/test/unit/dates_helper_test.rb +++ b/test/unit/dates_helper_test.rb @@ -57,7 +57,7 @@ class DatesHelperTest < ActiveSupport::TestCase end should 'not crash with events that have start_date and end_date' do - FastGettext.default_text_domain = 'noosferofull' + FastGettext.default_text_domain = 'noosfero' assert_nothing_raised do Noosfero.locales.keys.each do |key| Noosfero.with_locale(key) do -- libgit2 0.21.2