Class: Rake::GettextTask
Instance Attribute Summary collapse
-
#name ⇒ Object
Name of gettext task.
-
#new_langs ⇒ Object
an array of languages (locales) for wich you want a new catalog.
-
#pattern ⇒ Object
Glob pattern to match source files.
-
#source_files ⇒ Object
an array of file names (a FileList is acceptable) that will be scanned for i18n strings.
-
#verbose ⇒ Object
True if verbose test output desired.
Instance Method Summary collapse
-
#define ⇒ Object
Create the tasks defined by this task lib.
-
#file_list ⇒ Object
:nodoc:.
-
#get_new_messages ⇒ Object
:nodoc:.
-
#initialize(name = :gettext) {|_self| ... } ⇒ GettextTask
constructor
Create a gettext task.
Constructor Details
#initialize(name = :gettext) {|_self| ... } ⇒ GettextTask
Create a gettext task.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gettext.rb', line 53 def initialize(name=:gettext) @name = name @pattern = nil @source_files = nil @new_langs = nil @verbose = false yield self if block_given? @pattern = '**/*.rb' if @pattern.nil? && @source_files.nil? define end |
Instance Attribute Details
#name ⇒ Object
Name of gettext task. (default is :gettext)
40 41 42 |
# File 'lib/gettext.rb', line 40 def name @name end |
#new_langs ⇒ Object
an array of languages (locales) for wich you want a new catalog
51 52 53 |
# File 'lib/gettext.rb', line 51 def new_langs @new_langs end |
#pattern ⇒ Object
Glob pattern to match source files. (default is ‘*/.rb’)
46 47 48 |
# File 'lib/gettext.rb', line 46 def pattern @pattern end |
#source_files ⇒ Object
an array of file names (a FileList is acceptable) that will be scanned for i18n strings
49 50 51 |
# File 'lib/gettext.rb', line 49 def source_files @source_files end |
#verbose ⇒ Object
True if verbose test output desired. (default is false)
43 44 45 |
# File 'lib/gettext.rb', line 43 def verbose @verbose end |
Instance Method Details
#define ⇒ Object
Create the tasks defined by this task lib.
65 66 67 68 69 70 71 72 73 |
# File 'lib/gettext.rb', line 65 def define desc "Ri18n gettext task" + (@name==:gettext ? "" : " for #{@name}") task @name do msg_list = I18nService.instance.update_catalogs(msg_list) I18nService.instance.create_catalogs(msg_list, new_langs ) end self end |
#file_list ⇒ Object
:nodoc:
75 76 77 78 79 80 |
# File 'lib/gettext.rb', line 75 def file_list # :nodoc: result = [] result += @source_files.to_a if @source_files result += FileList[ @pattern ].to_a if @pattern FileList[result] end |
#get_new_messages ⇒ Object
:nodoc:
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/gettext.rb', line 82 def # :nodoc: list = [] file_list.each{|fn| next unless test(?f, fn) File.open(fn) do |f| new_strings = GettextScanner::Gettext(f.read) if @verbose unless new_strings.empty? puts "I18n messages in #{fn}:" new_strings.each{|s| puts " * #{s}"} end end list += new_strings end } NewMsgList.new(list.uniq) end |