Class: Haml::MagicTranslations::Tasks::UpdatePoFiles

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/haml/magic_translations/tasks.rb

Overview

Rake task to generate and update PO files for a project using Haml::MagicTranslations

Example

Rakefile excerpt:

Haml::MagicTranslations::Tasks::UpdatePoFiles.new do |t|
  t.text_domain = 'my_project'
  t.files = Dir.glob("views/**/*.{rb,haml}") << "lib/my_project.rb"
  t.app_version = 'my_project 0.1'
end

Updating PO files in the po directory will be done by issuing:

rake update_pofiles

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :update_pofiles) {|_self| ... } ⇒ UpdatePoFiles

Returns a new instance of UpdatePoFiles.

Yields:

  • (_self)

Yield Parameters:



58
59
60
61
62
63
64
# File 'lib/haml/magic_translations/tasks.rb', line 58

def initialize(name = :update_pofiles)
  @name = name

  yield self if block_given?

  define
end

Instance Attribute Details

#app_versionObject

the application information which appears “Project-Id-Version: #app_version” in the pot/po-files



40
41
42
# File 'lib/haml/magic_translations/tasks.rb', line 40

def app_version
  @app_version
end

#filesObject

an Array of target files, that should be parsed for messages



37
38
39
# File 'lib/haml/magic_translations/tasks.rb', line 37

def files
  @files
end

#langObject

update files only for one language - the language specified by this option



43
44
45
# File 'lib/haml/magic_translations/tasks.rb', line 43

def lang
  @lang
end

#msgmergeObject

an array with the options, passed through to the gnu msgmerge tool

Symbols are automatically translated to options with dashes, example: ++[:no_wrap, :no_fuzzy_matching, :sort_output]++ translated to ++–no-fuzzy-matching –sort-output++.



53
54
55
# File 'lib/haml/magic_translations/tasks.rb', line 53

def msgmerge
  @msgmerge
end

#nameObject

The name of the task



31
32
33
# File 'lib/haml/magic_translations/tasks.rb', line 31

def name
  @name
end

#po_rootObject

the root directory of po-files



46
47
48
# File 'lib/haml/magic_translations/tasks.rb', line 46

def po_root
  @po_root
end

#text_domainObject

the textdomain name (see GetText.update_pofiles)



34
35
36
# File 'lib/haml/magic_translations/tasks.rb', line 34

def text_domain
  @text_domain
end

#verboseObject

true to show verbose messages. default is false



56
57
58
# File 'lib/haml/magic_translations/tasks.rb', line 56

def verbose
  @verbose
end