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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcbe962f4e3e2242c328f07eda929b4c3828ba6f
4
- data.tar.gz: 1a4dba2b494f81ca01b0b76ac94e4962c9df83b7
3
+ metadata.gz: 7ec4a21f65b47eb08464708ecc6a1277d37c19f7
4
+ data.tar.gz: c8ed1c2f9ec9f27281186d8775c0ae8e2cfeef91
5
5
  SHA512:
6
- metadata.gz: 9461cb5371faf1d74533199ae5a0de82086e58f769e786d08ec358801c2e5bb63035ec739c603ee203c137a3e67afc23219d9938bbae139970c59a26b4644ad6
7
- data.tar.gz: 7a236c9f260df49995835174be527cb5119a8a86d6ccb54b96a9975eb159cefa28606ad90b92c4c941cf62a5914e033045c1533fc8817c803fcfc71bd87fa00d
6
+ metadata.gz: 254f06fa3a526976a084164144131811fd6b0e2a5bbd272b4852c05133d8469ee23962777c2abb631f55a33858abbed66bd5b2b0d784ad60b4793ddafca756f1
7
+ data.tar.gz: 6529105353fcb938683054554aae6fea098ecf6422a368f60e8e5bf56cdec19ee200c5fd8b8ceab03749bb3599828e5c942a94fcae96f956c864be0f45abbe50
@@ -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 : "TRANSLATION_MISSING"
135
+ translation.present? ? translation : DUMMY_TEXT
132
136
  end
133
137
 
134
138
  def self.extract_text(string)
@@ -1,3 +1,3 @@
1
1
  module I18nScrewdriver
2
- VERSION = "7.3"
2
+ VERSION = "7.4"
3
3
  end
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 = I18nScrewdriver.load_translations(locale)
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
- translations.keys.sort.each do |key|
19
- next unless [dummy_text, "", nil].include?(translations[key])
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.3'
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-09 00:00:00.000000000 Z
12
+ date: 2015-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec