i18n_screwdriver 7.3 → 7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18n_screwdriver.rb +8 -4
- data/lib/i18n_screwdriver/version.rb +1 -1
- data/lib/tasks/i18n.rake +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec4a21f65b47eb08464708ecc6a1277d37c19f7
|
4
|
+
data.tar.gz: c8ed1c2f9ec9f27281186d8775c0ae8e2cfeef91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 254f06fa3a526976a084164144131811fd6b0e2a5bbd272b4852c05133d8469ee23962777c2abb631f55a33858abbed66bd5b2b0d784ad60b4793ddafca756f1
|
7
|
+
data.tar.gz: 6529105353fcb938683054554aae6fea098ecf6422a368f60e8e5bf56cdec19ee200c5fd8b8ceab03749bb3599828e5c942a94fcae96f956c864be0f45abbe50
|
data/lib/i18n_screwdriver.rb
CHANGED
@@ -4,6 +4,10 @@ require "i18n_screwdriver/translation_helper"
|
|
4
4
|
require "i18n_screwdriver/rails"
|
5
5
|
|
6
6
|
module I18nScrewdriver
|
7
|
+
DUMMY_TEXT = "TRANSLATION_MISSING"
|
8
|
+
|
9
|
+
Error = Class.new(StandardError)
|
10
|
+
|
7
11
|
def self.filename_for_locale(locale)
|
8
12
|
File.join("config", "locales", "application.#{locale}.yml")
|
9
13
|
end
|
@@ -19,7 +23,7 @@ module I18nScrewdriver
|
|
19
23
|
|
20
24
|
def self.load_translations(locale)
|
21
25
|
path = filename_for_locale(locale)
|
22
|
-
raise "File #{path} not found!" unless File.exists?(path)
|
26
|
+
raise Error, "File #{path} not found!" unless File.exists?(path)
|
23
27
|
sanitize_hash(YAML.load_file(path)[locale])
|
24
28
|
end
|
25
29
|
|
@@ -96,14 +100,14 @@ module I18nScrewdriver
|
|
96
100
|
|
97
101
|
def self.default_locale
|
98
102
|
@default_locale ||= begin
|
99
|
-
raise "Please set I18.default_locale" unless I18n.default_locale.present?
|
103
|
+
raise Error, "Please set I18.default_locale" unless I18n.default_locale.present?
|
100
104
|
I18n.default_locale.to_s
|
101
105
|
end
|
102
106
|
end
|
103
107
|
|
104
108
|
def self.available_locales
|
105
109
|
@available_locales ||= begin
|
106
|
-
raise "Please set I18.available_locales" unless I18n.available_locales.count > 0
|
110
|
+
raise Error, "Please set I18.available_locales" unless I18n.available_locales.count > 0
|
107
111
|
I18n.available_locales.map(&:to_s)
|
108
112
|
end
|
109
113
|
end
|
@@ -128,7 +132,7 @@ module I18nScrewdriver
|
|
128
132
|
|
129
133
|
def self.translate(string, options = {})
|
130
134
|
translation = I18n.translate(generate_key(string), options)
|
131
|
-
translation.present? ? translation :
|
135
|
+
translation.present? ? translation : DUMMY_TEXT
|
132
136
|
end
|
133
137
|
|
134
138
|
def self.extract_text(string)
|
data/lib/tasks/i18n.rake
CHANGED
@@ -11,12 +11,19 @@ namespace :i18n do
|
|
11
11
|
task :translate => :environment do
|
12
12
|
raise "ERROR: usage: TRANSLATE=de rake i18n:translate" unless ENV['TRANSLATE']
|
13
13
|
locale = ENV['TRANSLATE']
|
14
|
+
default_locale = I18n.default_locale.to_s
|
14
15
|
|
15
16
|
texts = I18nScrewdriver.load_translations(default_locale)
|
16
|
-
translations =
|
17
|
+
translations = {}
|
18
|
+
begin
|
19
|
+
translations = I18nScrewdriver.load_translations(locale)
|
20
|
+
rescue I18nScrewdriver::Error => e
|
21
|
+
puts "WARNING: #{e.message}"
|
22
|
+
end
|
23
|
+
|
17
24
|
puts "Translating #{translations.keys.size} entries from <#{default_locale}> to <#{locale}> (enter :q to save and quit, ctrl-c to abort):"
|
18
|
-
|
19
|
-
next unless [
|
25
|
+
texts.keys.sort.each do |key|
|
26
|
+
next unless [I18nScrewdriver::DUMMY_TEXT, "", nil].include?(translations[key])
|
20
27
|
puts "> #{texts[key]}"
|
21
28
|
input = STDIN.gets.chomp
|
22
29
|
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: '7.
|
4
|
+
version: '7.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Miesel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|