i18n_screwdriver 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  module I18nScrewdriver
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
4
4
 
data/lib/tasks/i18n.rake CHANGED
@@ -1,20 +1,27 @@
1
1
  namespace :i18n do
2
- desc 'Find all translations in views, helpers and controllers'
3
- task :update => :environment do
4
- raise "Please set I18.default_locale" unless I18n.default_locale.present?
5
- default_locale = I18n.default_locale.to_s
6
-
7
- raise "Please set I18.available_locales" unless I18n.available_locales.count > 0
8
- available_locales = I18n.available_locales.map(&:to_s)
2
+ def default_locale
3
+ @default_locale ||= begin
4
+ raise "Please set I18.default_locale" unless I18n.default_locale.present?
5
+ I18n.default_locale.to_s
6
+ end
7
+ end
9
8
 
10
- # parse all view files for texts to be translated
11
- texts = []
12
- Dir.glob("**/*.{haml,erb,slim}").each do |file|
13
- texts.concat(I18nScrewdriver.grab_texts_to_be_translated(File.read(file)))
9
+ def available_locales
10
+ @available_locales ||= begin
11
+ raise "Please set I18.available_locales" unless I18n.available_locales.count > 0
12
+ I18n.available_locales.map(&:to_s)
14
13
  end
14
+ end
15
15
 
16
- # also check helper files and controllers
17
- Dir.glob("**/*{_helper,_controller}.rb").each do |file|
16
+ def dummy_text
17
+ "TRANSLATION_MISSING"
18
+ end
19
+
20
+ desc 'Find all translations in views, helpers and controllers'
21
+ task :update => :environment do
22
+ # parse all files for texts to be translated
23
+ texts = []
24
+ Dir.glob("**/*.{haml,erb,slim,rb}").each do |file|
18
25
  texts.concat(I18nScrewdriver.grab_texts_to_be_translated(File.read(file)))
19
26
  end
20
27
 
@@ -28,6 +35,12 @@ namespace :i18n do
28
35
  # rewrite default language file with updated translations
29
36
  puts "Found #{translations.keys.size} unique translations"
30
37
  I18nScrewdriver.write_translations(default_locale, translations)
38
+ end
39
+
40
+ desc 'Write dummy translation files so they can manually be translated'
41
+ task :update_foreign => :environment do
42
+ # load translations from default locale
43
+ translations = I18nScrewdriver.load_translations(default_locale)
31
44
 
32
45
  # process each language we'd like to translate
33
46
  (available_locales - [default_locale]).each do |locale|
@@ -40,7 +53,7 @@ namespace :i18n do
40
53
  existing_translations.reject!{ |k| !translations.has_key?(k) }
41
54
 
42
55
  # add new translations
43
- translations.each_key{ |k| existing_translations[k] ||= "TRANSLATION_MISSING" }
56
+ translations.each_key{ |k| existing_translations[k] ||= dummy_text }
44
57
 
45
58
  # write the file
46
59
  I18nScrewdriver.write_translations(locale, existing_translations)
@@ -55,7 +68,7 @@ namespace :i18n do
55
68
  translations = I18nScrewdriver.load_translations(locale)
56
69
  puts "Translating #{translations.keys.size} entries to <#{locale}> (enter :q to save and quit):"
57
70
  translations.keys.sort.each do |key|
58
- next unless ["TRANSLATION_MISSING", ""].include?(translations[key])
71
+ next unless [dummy_text, ""].include?(translations[key])
59
72
  puts "> #{key}"
60
73
  input = STDIN.gets.chomp
61
74
  break if input == ":q"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_screwdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-10-26 00:00:00.000000000Z
13
+ date: 2011-10-31 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &9334380 !ruby/object:Gem::Requirement
17
+ requirement: &12479220 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *9334380
25
+ version_requirements: *12479220
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rails
28
- requirement: &9333120 !ruby/object:Gem::Requirement
28
+ requirement: &12478240 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 3.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *9333120
36
+ version_requirements: *12478240
37
37
  description: make translating with rails i18n fun again
38
38
  email:
39
39
  - agileapplications@gmail.com