File: makepot.rb

package info (click to toggle)
mikutter 5.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,780 kB
  • sloc: ruby: 22,912; sh: 186; makefile: 21
file content (56 lines) | stat: -rw-r--r-- 1,539 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
# 全プラグインにpot作成

require 'boot/delayer'
require "miquire_plugin"

require 'gettext/tools/task'
require 'rake'

mo_root = File.join(CHIConfig::CACHE, "uitranslator", "locale")

Environment::PLUGIN_PATH.each do |path|
  Miquire::Plugin.loadpath << path
end
Miquire::Plugin.loadpath << File.join(Environment::CONFROOT, 'plugin')

enable_plugins = ARGV[1,]
failed_plugins = []

Miquire::Plugin.each_spec do |spec|
  if (enable_plugins.empty? or enable_plugins.include? spec[:slug].to_s) and
      (defined?(spec[:depends][:plugin]) and spec[:depends][:plugin].include? "uitranslator")
    po_root = File.join spec[:path], "po"
    begin
      GetText::Tools::Task.define do |task|
        task.spec = Gem::Specification.new do |s|
          s.name = spec[:slug].to_s
          s.version = spec[:version].to_s
          s.files = Dir.glob("#{spec[:path]}/**/*.rb")
        end
        task.locales = ["ja"]
        task.po_base_directory = po_root
      end
    rescue Exception => e
      failed_plugins << spec[:slug]
    end
  end
end
notice Rake::Task.tasks.join("\n")

# gettext:po:updateがいちいち翻訳者名とか聞いてきてうざいので潰す。
# 本来はgettextにパッチを送るとかするべきな気がする。
class GetText::Tools::MsgInit
  def translator_full_name
    ""
  end

  def translator_mail
    ""
  end
end

Rake::Task["gettext:pot:create"].invoke
Rake::Task["gettext:po:update"].invoke

puts "failed plugins: #{failed_plugins}" unless failed_plugins.empty?