Commit 85411b0cbed634b390f220af4ce3b1028fff5fb8

Authored by Leandro Santos
1 parent 7e605ffd

hotfix for gettext tranlation

Gemfile
... ... @@ -18,6 +18,8 @@ gem 'rake', :require => false
18 18 gem 'grape', '0.2.1'
19 19 gem 'rest-client'
20 20 gem 'exception_notification'
  21 +gem 'gettext_i18n_rails'
  22 +gem 'gettext', '>=3.0.2', :require => false, :group => :development
21 23  
22 24 # FIXME list here all actual dependencies (i.e. the ones in debian/control),
23 25 # with their GEM names (not the Debian package names)
... ...
Gemfile.lock
... ... @@ -67,22 +67,49 @@ GEM
67 67 activesupport (>= 3.0.4)
68 68 fast_gettext (0.6.8)
69 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 75 gherkin (2.4.21)
71 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 87 hike (1.2.1)
73 88 hpricot (0.8.6)
  89 + httparty (0.11.0)
  90 + multi_json (~> 1.0)
  91 + multi_xml (>= 0.5.2)
74 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 99 journey (1.0.3)
76 100 json (1.7.3)
  101 + locale (2.1.0)
77 102 mail (2.4.4)
78 103 i18n (>= 0.4.0)
79 104 mime-types (~> 1.16)
80 105 treetop (~> 1.4.8)
81 106 metaclass (0.0.1)
82 107 mime-types (1.19)
  108 + mixlib-shellout (1.4.0)
83 109 mocha (0.11.3)
84 110 metaclass (~> 0.0.1)
85 111 multi_json (1.3.6)
  112 + multi_xml (0.5.5)
86 113 nokogiri (1.5.5)
87 114 pg (0.13.2)
88 115 polyglot (0.3.3)
... ... @@ -91,6 +118,8 @@ GEM
91 118 rack (1.4.1)
92 119 rack-cache (1.2)
93 120 rack (>= 0.4)
  121 + rack-mount (0.8.3)
  122 + rack (>= 1.0.0)
94 123 rack-ssl (1.3.2)
95 124 rack
96 125 rack-test (0.6.1)
... ... @@ -143,11 +172,13 @@ GEM
143 172 rack (~> 1.0)
144 173 tilt (~> 1.1, != 1.3.0)
145 174 term-ansicolor (1.0.7)
  175 + terminal-table (1.4.5)
  176 + text (1.3.0)
146 177 thin (1.3.1)
147 178 daemons (>= 1.0.9)
148 179 eventmachine (>= 0.12.6)
149 180 rack (>= 1.0.0)
150   - thor (0.15.3)
  181 + thor (0.19.1)
151 182 tilt (1.3.3)
152 183 treetop (1.4.10)
153 184 polyglot
... ... @@ -172,7 +203,12 @@ DEPENDENCIES
172 203 database_cleaner
173 204 exception_notification
174 205 fast_gettext
  206 + gettext (>= 3.0.2)
  207 + gettext_i18n_rails
  208 + gitlab (~> 3.1.0)
  209 + grape (= 0.2.1)
175 210 hpricot
  211 + jenkins_api_client (~> 0.14.1)
176 212 mocha
177 213 nokogiri
178 214 pg
... ...
lib/noosfero/i18n.rb
... ... @@ -20,5 +20,5 @@ if File.exists?(locale_dir)
20 20 repos << FastGettext::TranslationRepository.build('iso_3166', :type => 'mo', :path => locale_dir)
21 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 6 desc "Create mo-files for L10n"
7 7 task :makemo => makemo_stamp
8 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 9 Rake::Task['symlinkmo'].invoke
  10 + Rake::Task['gettext:pack'].invoke
11 11 FileUtils.mkdir_p 'tmp'
12 12 FileUtils.touch makemo_stamp
13 13 end
... ... @@ -22,10 +22,12 @@ task :symlinkmo do
22 22 'pt' => 'pt_BR',
23 23 }
24 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 26 lang = File.basename(dir)
27 27 orig_lang = langmap[lang] || lang
28 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 31 ['iso_3166'].each do |domain|
30 32 origin = "/usr/share/locale/#{orig_lang}/LC_MESSAGES/#{domain}.mo"
31 33 target = Rails.root.join('locale', "#{lang}", 'LC_MESSAGES', "#{domain}.mo")
... ... @@ -36,23 +38,21 @@ task :symlinkmo do
36 38 end
37 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 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 56 end
57 57  
58 58 task :checkpo do
... ...
test/unit/dates_helper_test.rb
... ... @@ -57,7 +57,7 @@ class DatesHelperTest &lt; ActiveSupport::TestCase
57 57 end
58 58  
59 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 61 assert_nothing_raised do
62 62 Noosfero.locales.keys.each do |key|
63 63 Noosfero.with_locale(key) do
... ...