| 11 | | |
|---|
| 12 | | ###### GETTEXT TASKS ##### |
|---|
| 13 | | # Taken from "Using Gettext To Translate Your Rails Application" at |
|---|
| 14 | | # http://www.digitale-wertschoepfung.de/artikel/gettext/gettext.html |
|---|
| 15 | | require 'gettext/utils' |
|---|
| 16 | | |
|---|
| 17 | | desc "Create mo-files for L10n" |
|---|
| 18 | | task :makemo do |
|---|
| 19 | | LOCALE_DIR = 'locale' |
|---|
| 20 | | GetText.create_mofiles(true, 'po', LOCALE_DIR) |
|---|
| 21 | | # Move rails.mo files to right places: locale/LANG/LC_MESSAGES/rails.mo -> locale/LANG/rails.mo |
|---|
| 22 | | Dir.new(LOCALE_DIR).each do |filename| |
|---|
| 23 | | next if ['.', '..'].include?(filename) |
|---|
| 24 | | dirname = File.join(LOCALE_DIR, filename) |
|---|
| 25 | | next unless File.directory?(dirname) |
|---|
| 26 | | file_to_move = File.join(dirname, 'LC_MESSAGES', 'rails.mo') |
|---|
| 27 | | puts "Moving #{file_to_move} -> #{dirname}/rails.mo" |
|---|
| 28 | | unless File.exists?(file_to_move) |
|---|
| 29 | | puts "File #{file_to_move} not found. So we can't move it!" |
|---|
| 30 | | next |
|---|
| 31 | | end |
|---|
| 32 | | File.move(file_to_move, dirname) |
|---|
| 33 | | end |
|---|
| 34 | | end |
|---|
| 35 | | |
|---|
| 36 | | desc "Update pot/po files to match new version." |
|---|
| 37 | | task :updatepo do |
|---|
| 38 | | TEXT_DOMAIN = "norfello_cmms" |
|---|
| 39 | | VERSION = "NorfelloCMMS SVN trunk" |
|---|
| 40 | | GetText.update_pofiles(TEXT_DOMAIN, |
|---|
| 41 | | Dir.glob("{app,lib,config,commercial/app,commercial/lib,commercial/config}/**/*.{rb,rhtml}"), |
|---|
| 42 | | VERSION) |
|---|
| 43 | | end |
|---|