diff --git a/Rakefile.translations b/Rakefile.translations new file mode 100644 index 0000000..e6d9d24 --- /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' diff --git a/lib/noosfero/version.rb b/lib/noosfero/version.rb index 0689835..6bf7f8b 100644 --- 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 diff --git a/lib/tasks/doc.rake b/lib/tasks/doc.rake index 2e85c98..8644bad 100644 --- 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 diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 0404663..3de77ee 100644 --- 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 diff --git a/lib/tasks/translation.rake b/lib/tasks/translation.rake index ed888de..00b6fcb 100644 --- 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 -- libgit2 0.21.2