X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=Rakefile;h=6b321fdc166d400fafa8911e802bdc92a885b292;hb=3b83d8870cc04a2b0eff4250dd8deef9ea1d697b;hp=f0a42717df5d410712f9120bd0d4affd182bc2ba;hpb=b233d010765808cfbf34dc763ab9013968212981;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/Rakefile b/Rakefile index f0a42717..6b321fdc 100644 --- a/Rakefile +++ b/Rakefile @@ -35,14 +35,64 @@ Rake::GemPackageTask.new(spec) do |pkg| pkg.need_tar = true end -desc "Update pot/po files." -task :updatepo do +PLUGIN_FILES = FileList['data/rbot/plugins/**/*.rb'] +NON_PLUGIN_FILES = FileList["{lib,bin,data}/**/*.{rb,rhtml}"] - PLUGIN_FILES +rgettext_proc = proc do |t| require 'gettext/utils' - GetText.update_pofiles("rbot", Dir.glob("{lib,bin,data}/**/*.{rb,rhtml}"), "rbot") + source_files, pot_file = t.prerequisites, t.name + puts "#{source_files.join(', ')} => #{pot_file}" + GetText.rgettext(source_files, pot_file) end -desc "Create mo-files" -task :makemo do +# generate pot file for non-plugin files +file('po/rbot.pot' => NON_PLUGIN_FILES, &rgettext_proc) + +# generate pot files for plugin files +rule(%r'^po/.+\.pot$' => proc {|fn| + PLUGIN_FILES.select {|f| f.pathmap('rbot-%n') == fn.pathmap('%n')} +}, &rgettext_proc) + +# update po files +# ruby-gettext treats empty output from msgmerge as error, causing this task to +# fail. we provide a wrapper to work around it. see bin/msgmerge-wrapper.rb for +# details +ENV['REAL_MSGMERGE_PATH'] = ENV['MSGMERGE_PATH'] +ENV['MSGMERGE_PATH'] = ENV['MSGMERGE_WRAPPER_PATH'] || 'ruby msgmerge-wrapper.rb' +rule(%r'^po/.+/.+\.po$' => proc {|fn| fn.pathmap '%{^po/.+/,po/}X.pot'}) do |t| + require 'gettext/utils' + po_file, pot_file = t.name, t.source + puts "#{pot_file} => #{po_file}" + GetText.msgmerge po_file, pot_file, 'rbot' +end + +# generate mo files +rule(%r'^data/locale/.+/LC_MESSAGES/.+\.mo$' => proc {|fn| + [ fn.pathmap('%{^data/locale,po;LC_MESSAGES/,}X.po'), + # the directory is created if not existing + fn.pathmap('%d') ] +}) do |t| + po_file, mo_file = t.source, t.name + puts "#{po_file} => #{mo_file}" require 'gettext/utils' - GetText.create_mofiles(true) + GetText.rmsgfmt po_file, mo_file end + +PLUGIN_BASENAMES = PLUGIN_FILES.map {|f| f.pathmap('%n')} +LOCALES = FileList['po/*/'].map {|d| d.pathmap('%n')} + +LOCALES.each do |l| + directory "data/locale/#{l}/LC_MESSAGES" +end + +desc 'Update po files' +task :updatepo => LOCALES.map {|l| + ["po/#{l}/rbot.po"] + + PLUGIN_BASENAMES.map {|n| "po/#{l}/rbot-#{n}.po"} +}.flatten + +desc 'Generate mo files' +task :makemo => LOCALES.map {|l| + ["data/locale/#{l}/LC_MESSAGES/rbot.mo"] + + PLUGIN_BASENAMES.map {|n| "data/locale/#{l}/LC_MESSAGES/rbot-#{n}.mo"} +}.flatten +