Commit 85411b0cbed634b390f220af4ce3b1028fff5fb8

Authored by Leandro Santos
1 parent 7e605ffd

hotfix for gettext tranlation

@@ -18,6 +18,8 @@ gem 'rake', :require => false @@ -18,6 +18,8 @@ gem 'rake', :require => false
18 gem 'grape', '0.2.1' 18 gem 'grape', '0.2.1'
19 gem 'rest-client' 19 gem 'rest-client'
20 gem 'exception_notification' 20 gem 'exception_notification'
  21 +gem 'gettext_i18n_rails'
  22 +gem 'gettext', '>=3.0.2', :require => false, :group => :development
21 23
22 # FIXME list here all actual dependencies (i.e. the ones in debian/control), 24 # FIXME list here all actual dependencies (i.e. the ones in debian/control),
23 # with their GEM names (not the Debian package names) 25 # with their GEM names (not the Debian package names)
@@ -67,22 +67,49 @@ GEM @@ -67,22 +67,49 @@ GEM
67 activesupport (>= 3.0.4) 67 activesupport (>= 3.0.4)
68 fast_gettext (0.6.8) 68 fast_gettext (0.6.8)
69 ffi (1.0.11) 69 ffi (1.0.11)
  70 + gettext (3.1.4)
  71 + locale (>= 2.0.5)
  72 + text
  73 + gettext_i18n_rails (1.0.5)
  74 + fast_gettext (>= 0.4.8)
70 gherkin (2.4.21) 75 gherkin (2.4.21)
71 json (>= 1.4.6) 76 json (>= 1.4.6)
  77 + gitlab (3.1.0)
  78 + httparty
  79 + terminal-table
  80 + grape (0.2.1)
  81 + hashie (~> 1.2)
  82 + multi_json
  83 + multi_xml
  84 + rack
  85 + rack-mount
  86 + hashie (1.2.0)
72 hike (1.2.1) 87 hike (1.2.1)
73 hpricot (0.8.6) 88 hpricot (0.8.6)
  89 + httparty (0.11.0)
  90 + multi_json (~> 1.0)
  91 + multi_xml (>= 0.5.2)
74 i18n (0.6.0) 92 i18n (0.6.0)
  93 + jenkins_api_client (0.14.1)
  94 + json
  95 + mixlib-shellout (>= 1.1.0)
  96 + nokogiri (~> 1.5.0)
  97 + terminal-table (>= 1.4.0)
  98 + thor (>= 0.16.0)
75 journey (1.0.3) 99 journey (1.0.3)
76 json (1.7.3) 100 json (1.7.3)
  101 + locale (2.1.0)
77 mail (2.4.4) 102 mail (2.4.4)
78 i18n (>= 0.4.0) 103 i18n (>= 0.4.0)
79 mime-types (~> 1.16) 104 mime-types (~> 1.16)
80 treetop (~> 1.4.8) 105 treetop (~> 1.4.8)
81 metaclass (0.0.1) 106 metaclass (0.0.1)
82 mime-types (1.19) 107 mime-types (1.19)
  108 + mixlib-shellout (1.4.0)
83 mocha (0.11.3) 109 mocha (0.11.3)
84 metaclass (~> 0.0.1) 110 metaclass (~> 0.0.1)
85 multi_json (1.3.6) 111 multi_json (1.3.6)
  112 + multi_xml (0.5.5)
86 nokogiri (1.5.5) 113 nokogiri (1.5.5)
87 pg (0.13.2) 114 pg (0.13.2)
88 polyglot (0.3.3) 115 polyglot (0.3.3)
@@ -91,6 +118,8 @@ GEM @@ -91,6 +118,8 @@ GEM
91 rack (1.4.1) 118 rack (1.4.1)
92 rack-cache (1.2) 119 rack-cache (1.2)
93 rack (>= 0.4) 120 rack (>= 0.4)
  121 + rack-mount (0.8.3)
  122 + rack (>= 1.0.0)
94 rack-ssl (1.3.2) 123 rack-ssl (1.3.2)
95 rack 124 rack
96 rack-test (0.6.1) 125 rack-test (0.6.1)
@@ -143,11 +172,13 @@ GEM @@ -143,11 +172,13 @@ GEM
143 rack (~> 1.0) 172 rack (~> 1.0)
144 tilt (~> 1.1, != 1.3.0) 173 tilt (~> 1.1, != 1.3.0)
145 term-ansicolor (1.0.7) 174 term-ansicolor (1.0.7)
  175 + terminal-table (1.4.5)
  176 + text (1.3.0)
146 thin (1.3.1) 177 thin (1.3.1)
147 daemons (>= 1.0.9) 178 daemons (>= 1.0.9)
148 eventmachine (>= 0.12.6) 179 eventmachine (>= 0.12.6)
149 rack (>= 1.0.0) 180 rack (>= 1.0.0)
150 - thor (0.15.3) 181 + thor (0.19.1)
151 tilt (1.3.3) 182 tilt (1.3.3)
152 treetop (1.4.10) 183 treetop (1.4.10)
153 polyglot 184 polyglot
@@ -172,7 +203,12 @@ DEPENDENCIES @@ -172,7 +203,12 @@ DEPENDENCIES
172 database_cleaner 203 database_cleaner
173 exception_notification 204 exception_notification
174 fast_gettext 205 fast_gettext
  206 + gettext (>= 3.0.2)
  207 + gettext_i18n_rails
  208 + gitlab (~> 3.1.0)
  209 + grape (= 0.2.1)
175 hpricot 210 hpricot
  211 + jenkins_api_client (~> 0.14.1)
176 mocha 212 mocha
177 nokogiri 213 nokogiri
178 pg 214 pg
lib/noosfero/i18n.rb
@@ -20,5 +20,5 @@ if File.exists?(locale_dir) @@ -20,5 +20,5 @@ if File.exists?(locale_dir)
20 repos << FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => locale_dir) 20 repos << FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => locale_dir)
21 end 21 end
22 22
23 -FastGettext.add_text_domain 'noosferofull', :type => :chain, :chain => repos  
24 -FastGettext.default_text_domain = 'noosferofull' 23 +FastGettext.add_text_domain 'noosfero', :type => :chain, :chain => repos
  24 +FastGettext.default_text_domain = 'noosfero'
lib/tasks/gettext.rake
@@ -6,8 +6,8 @@ makemo_stamp = &#39;tmp/makemo.stamp&#39; @@ -6,8 +6,8 @@ makemo_stamp = &#39;tmp/makemo.stamp&#39;
6 desc "Create mo-files for L10n" 6 desc "Create mo-files for L10n"
7 task :makemo => makemo_stamp 7 task :makemo => makemo_stamp
8 file makemo_stamp => Dir.glob('po/*/noosfero.po') do 8 file makemo_stamp => Dir.glob('po/*/noosfero.po') do
9 - ruby '-I. -rconfig/boot -e \'require "gettext"; require "gettext/utils"; GetText.create_mofiles(true, "po", "locale")\''  
10 Rake::Task['symlinkmo'].invoke 9 Rake::Task['symlinkmo'].invoke
  10 + Rake::Task['gettext:pack'].invoke
11 FileUtils.mkdir_p 'tmp' 11 FileUtils.mkdir_p 'tmp'
12 FileUtils.touch makemo_stamp 12 FileUtils.touch makemo_stamp
13 end 13 end
@@ -22,10 +22,12 @@ task :symlinkmo do @@ -22,10 +22,12 @@ task :symlinkmo do
22 'pt' => 'pt_BR', 22 'pt' => 'pt_BR',
23 } 23 }
24 mkdir_p(Rails.root.join('locale')) 24 mkdir_p(Rails.root.join('locale'))
25 - Dir.glob(Rails.root.join('locale/*')).each do |dir| 25 + Dir.glob(Rails.root.join('po/*/')).each do |dir|
26 lang = File.basename(dir) 26 lang = File.basename(dir)
27 orig_lang = langmap[lang] || lang 27 orig_lang = langmap[lang] || lang
28 mkdir_p(Rails.root.join('locale', "#{lang}", 'LC_MESSAGES')) 28 mkdir_p(Rails.root.join('locale', "#{lang}", 'LC_MESSAGES'))
  29 + ln_sf "../../po/#{lang}/noosfero.po", "locale/#{lang}/noosfero.po"
  30 + ln_sf "../../po/#{lang}/noosfero-doc.po", "locale/#{lang}/noosfero-doc.po"
29 ['iso_3166'].each do |domain| 31 ['iso_3166'].each do |domain|
30 origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo" 32 origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo"
31 target = Rails.root.join('locale', "#{lang}", 'LC_MESSAGES', "#{domain}.mo") 33 target = Rails.root.join('locale', "#{lang}", 'LC_MESSAGES', "#{domain}.mo")
@@ -36,23 +38,21 @@ task :symlinkmo do @@ -36,23 +38,21 @@ task :symlinkmo do
36 end 38 end
37 end 39 end
38 40
39 -desc "Update pot/po files to match new version."  
40 -task :updatepo do  
41 - require 'gettext_rails/tools'  
42 - require_dependency 'noosfero'  
43 -  
44 - GetText::RubyParser::ID << '__'  
45 - GetText::RubyParser::PLURAL_ID << 'n__'  
46 - GetText::ActiveRecordParser.init(:use_classname => false) 41 +namespace :gettext do
  42 + def files_to_translate
  43 + sources =
  44 + Dir.glob("{app,lib}/**/*.{rb,rhtml,erb}") +
  45 + Dir.glob('config/initializers/*.rb') +
  46 + Dir.glob('public/*.html.erb') +
  47 + Dir.glob('public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}') +
  48 + Dir.glob('plugins/**/{controllers,models,lib,views}/**/*.{rhtml,html.erb,rb}')
  49 + end
  50 +end
47 51
  52 +desc "Update pot/po files to match new version."
  53 +task :updatepo => :symlinkmo do
48 puts 'Extracting strings from source. This may take a while ...' 54 puts 'Extracting strings from source. This may take a while ...'
49 - sources =  
50 - Dir.glob("{app,lib}/**/*.{rb,rhtml,erb}") +  
51 - Dir.glob('config/initializers/*.rb') +  
52 - Dir.glob('public/*.html.erb') +  
53 - Dir.glob('public/designs/themes/{base,noosfero,profile-base}/*.{rhtml,html.erb}') +  
54 - Dir.glob('plugins/**/{controllers,models,lib,views}/**/*.{rhtml,html.erb,rb}')  
55 - GetText.update_pofiles(Noosfero::PROJECT, sources, "#{Noosfero::PROJECT} #{Noosfero::VERSION}") 55 + Rake::Task['gettext:find'].invoke
56 end 56 end
57 57
58 task :checkpo do 58 task :checkpo do
test/unit/dates_helper_test.rb
@@ -57,7 +57,7 @@ class DatesHelperTest &lt; ActiveSupport::TestCase @@ -57,7 +57,7 @@ class DatesHelperTest &lt; ActiveSupport::TestCase
57 end 57 end
58 58
59 should 'not crash with events that have start_date and end_date' do 59 should 'not crash with events that have start_date and end_date' do
60 - FastGettext.default_text_domain = 'noosferofull' 60 + FastGettext.default_text_domain = 'noosfero'
61 assert_nothing_raised do 61 assert_nothing_raised do
62 Noosfero.locales.keys.each do |key| 62 Noosfero.locales.keys.each do |key|
63 Noosfero.with_locale(key) do 63 Noosfero.with_locale(key) do