noosfero | 2 new commits pushed to repository
Antonio Terceiro
gitlab at gitlab.com
Fri Mar 6 17:10:41 BRT 2015
Antonio Terceiro pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>
Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/7d06b77b49c6f473ca4f8c444f9d31cf0470bda6">7d06b77b</a> by Antonio Terceiro
Gemfile: remove gettext from group development
It is needed to compile translations, so not only in development
- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/6686f090f4f8e77d0215e1825bb62f29f4c0c054">6686f090</a> by Antonio Terceiro
Support compiling translations without Rails environment
$ rake -f Rakefile.translations
The above invocation will work without a full rails environment, which
requires a config/database.yml, an actual database to connect to, plus
loading all the Rails stack which is painfully slow.
This can now be used by distribution packages to compile translations
during package build without worrying much.
- - - - -
Changes:
=====================================
Gemfile
=====================================
--- a/Gemfile
+++ b/Gemfile
@@ -15,7 +15,7 @@ gem 'nokogiri', '~> 1.5.5'
gem 'rake', :require => false
gem 'rest-client', '~> 1.6.7'
gem 'exception_notification', '~> 4.0.1'
-gem 'gettext', '~> 2.2.1', :require => false, :group => :development
+gem 'gettext', '~> 2.2.1', :require => false
gem 'locale', '~> 2.0.5'
gem 'whenever', :require => false
gem 'eita-jrails', '>= 0.9.5', :require => 'jrails'
=====================================
Rakefile.translations
=====================================
--- /dev/null
+++ b/Rakefile.translations
@@ -0,0 +1,11 @@
+# This Rakefile is intentionally independent from Rails to it can be used to
+# handle translations without having to load the entire Rails environment
+# (which is slow, requires a database connection and several other
+# inconveniences).
+
+$: << 'lib'
+load 'lib/tasks/gettext.rake'
+load 'lib/tasks/doc.rake'
+load 'lib/tasks/translation.rake'
+
+task :default => 'noosfero:translations:compile'
=====================================
lib/noosfero/version.rb
=====================================
--- a/lib/noosfero/version.rb
+++ b/lib/noosfero/version.rb
@@ -3,6 +3,7 @@ module Noosfero
VERSION = '1.1~rc1'
end
-if File.exist?(File.join(Rails.root, '.git'))
- Noosfero::VERSION.clear << Dir.chdir(Rails.root) { `git describe --tags`.strip }
+root = File.expand_path(File.dirname(__FILE__) + '/../..')
+if File.exist?(File.join(root, '.git'))
+ Noosfero::VERSION.clear << Dir.chdir(root) { `git describe --tags`.strip }
end
=====================================
lib/tasks/doc.rake
=====================================
--- a/lib/tasks/doc.rake
+++ b/lib/tasks/doc.rake
@@ -1,3 +1,6 @@
+require 'noosfero'
+require 'pathname'
+
namespace :noosfero do
namespace :doc do
def plugins_textiles
@@ -9,8 +12,9 @@ namespace :noosfero do
end
end
task :unlink_plugins_textiles do
- rm_f Dir.glob(Rails.root.join('doc/noosfero/plugins/*.textile')) -
- [Rails.root.join('doc/noosfero/plugins/index.textile')]
+ root = Pathname.new(File.dirname(__FILE__) + '/../..').expand_path
+ rm_f Dir.glob(root.join('doc/noosfero/plugins/*.textile')) -
+ [root.join('doc/noosfero/plugins/index.textile')]
end
input = Dir.glob('doc/noosfero/**/*.textile') + plugins_textiles.map{|i| "doc/noosfero/plugins/#{File.basename(i)}"}
topics_xhtml = input.map { |item| item.sub('.textile', '.en.xhtml') }.uniq
=====================================
lib/tasks/gettext.rake
=====================================
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -2,6 +2,8 @@
# Added for Ruby-GetText-Package
#
+require 'pathname'
+
makemo_stamp = 'tmp/makemo.stamp'
desc "Create mo-files for L10n"
task :makemo => makemo_stamp
@@ -37,14 +39,15 @@ task :symlinkmo do
langmap = {
'pt' => 'pt_BR',
}
- mkdir_p(Rails.root.join('locale'))
- Dir.glob(Rails.root.join('po/*/')).each do |dir|
+ root = Pathname.new(File.dirname(__FILE__) + '/../..').expand_path
+ mkdir_p(root.join('locale'))
+ Dir.glob(root.join('po/*/')).each do |dir|
lang = File.basename(dir)
orig_lang = langmap[lang] || lang
- mkdir_p(Rails.root.join('locale', "#{lang}", 'LC_MESSAGES'))
+ mkdir_p(root.join('locale', "#{lang}", 'LC_MESSAGES'))
['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")
+ target = root.join('locale', "#{lang}", 'LC_MESSAGES', "#{domain}.mo")
if !File.symlink?(target)
ln_s origin, target
end
=====================================
lib/tasks/translation.rake
=====================================
--- a/lib/tasks/translation.rake
+++ b/lib/tasks/translation.rake
@@ -5,7 +5,7 @@ namespace :noosfero do
task :update => ['updatepo', 'noosfero:doc:rebuild']
desc 'Compiles all translations'
- task :compile => ['makemo', 'environment', 'noosfero:doc:translate']
+ task :compile => ['makemo', 'noosfero:doc:translate']
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150306/7bdc800f/attachment-0001.html>
More information about the Noosfero-dev
mailing list