i18n_screwdriver 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/i18n_screwdriver/version.rb +1 -1
- data/lib/tasks/i18n.rake +28 -15
- metadata +6 -6
data/lib/tasks/i18n.rake
CHANGED
@@ -1,20 +1,27 @@
|
|
1
1
|
namespace :i18n do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
17
|
-
|
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] ||=
|
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 [
|
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.
|
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-
|
13
|
+
date: 2011-10-31 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
17
|
-
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: *
|
25
|
+
version_requirements: *12479220
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rails
|
28
|
-
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: *
|
36
|
+
version_requirements: *12478240
|
37
37
|
description: make translating with rails i18n fun again
|
38
38
|
email:
|
39
39
|
- agileapplications@gmail.com
|