idiom 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/idiom.gemspec +2 -2
  3. data/lib/idiom.rb +1 -1
  4. data/lib/idiom/base.rb +16 -26
  5. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/idiom.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{idiom}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Coleman"]
12
- s.date = %q{2011-03-08}
12
+ s.date = %q{2011-04-29}
13
13
  s.default_executable = %q{idiom}
14
14
  s.description = %q{Takes a set of keys in Yaml format and translates them through Google Translate.}
15
15
  s.email = %q{progressions@gmail.com}
data/lib/idiom.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
3
-
3
+ require 'thread'
4
4
  require 'rubygems'
5
5
  require 'active_support'
6
6
  require 'active_support/core_ext/hash'
data/lib/idiom/base.rb CHANGED
@@ -35,34 +35,13 @@ module Idiom #:nodoc:
35
35
  end
36
36
 
37
37
  module Locales #:nodoc:
38
- # Mapping of the way I18n country codes with the Google Translate codes.
38
+ # Mapping of the I18n country codes with the Google Translate codes.
39
39
  #
40
40
  # The key is the I18n representation, and the value is the code Google Translate would expect.
41
41
  #
42
- LOCALES = {
43
- "de-DE" => "de",
44
- "en-MY" => "en",
45
- "en-SG" => "en",
46
- "es-AR" => "es",
47
- "es-MX" => "es",
48
- "es-US" => "es",
49
- "it-IT" => "it",
50
- "vi-VN" => "vi",
51
- "zh-Hant-TW" => "zh-TW",
52
- "en-AA" => "en",
53
- "en-NZ" => "en",
54
- "en-US" => "en",
55
- "fr-FR" => "fr",
56
- "ko-KR" => "ko",
57
- "zh-Hans-CN" => "zh-CN",
58
- "en-AU" => "en",
59
- "en-PH" => "en",
60
- "es-ES" => "es",
61
- "id-ID" => "id",
62
- "pt-BR" => "PORTUGUESE",
63
- "zh-Hant-HK" => "zh-TW",
64
- }
65
42
 
43
+ LOCALES = YAML.load_file("./config/locales.yml")
44
+
66
45
  # locales
67
46
 
68
47
  def non_us_locales
@@ -312,18 +291,29 @@ module Idiom #:nodoc:
312
291
 
313
292
  def translate_new_key(line, lang)
314
293
  k, v = key_and_value_from_line(line)
294
+
315
295
  if @overwrite || key_is_new?(k, lang)
316
- format(k, translate(v, lang))
296
+ translation = translate(v, lang)
297
+
298
+ if translation == "Error: invalid result data"
299
+ return nil
300
+ end
301
+
302
+ format(k, translation)
317
303
  else
318
304
  nil
319
305
  end
320
306
  end
321
307
 
322
308
  def translate(value, lang)
309
+ $stdout.puts("Translating #{value} into #{lang}...")
323
310
  code = LOCALES[lang]
324
311
  value = pre_process(value, lang)
325
312
  translation = Translate.t(value, "ENGLISH", code)
326
- post_process(translation, lang)
313
+ value = post_process(translation, lang)
314
+ $stdout.puts("value: #{value}")
315
+ sleep(5)
316
+ value
327
317
  end
328
318
 
329
319
  def format(key, value)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idiom
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Coleman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-08 00:00:00 -06:00
18
+ date: 2011-04-29 00:00:00 -05:00
19
19
  default_executable: idiom
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency