babelphish 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,6 @@ require 'ya2yaml'
3
3
  require 'babelphish/languages'
4
4
  require 'jcode'
5
5
 
6
- require 'ruby-debug'
7
-
8
6
  module Babelphish
9
7
  module Translator
10
8
  class << self
@@ -28,6 +26,9 @@ module Babelphish
28
26
  return if File.exist?(translated_filename) && !overwrite
29
27
  translated_yml = YAML.load_file(yml)
30
28
  translate_keys(translated_yml, to, from)
29
+ # change the top level key from the source language to the destination language
30
+ translated_yml[to] = translated_yml[from]
31
+ translated_yml.delete(from)
31
32
  File.open(translated_filename, 'w') { |f| f.write(translated_yml.ya2yaml) }
32
33
  end
33
34
 
@@ -36,14 +37,22 @@ module Babelphish
36
37
  if translate_hash[key].is_a?(Hash)
37
38
  translate_keys(translate_hash[key], to, from)
38
39
  else
39
- # pull out all the string substitutions so that google doesn't translate those
40
- pattern = /\{\{.+\}\}/
41
- holder = '{{---}}'
42
- replacements = translate_hash[key].scan(pattern)
43
- translate_hash[key].gsub!(pattern, holder)
44
- translate_hash[key] = translate(translate_hash[key], to, from)
45
- replacements.each do |r|
46
- translate_hash[key].sub!(holder, r)
40
+ if key == false
41
+ puts "Key #{key} was evaluated as false. Check your yml file and be sure to escape values like no with 'no'. ie 'no': 'No'"
42
+ elsif key == true
43
+ puts "Key #{key} was evaluated as true. Check your yml file and be sure to escape values like yes with 'yes'. ie 'yes': 'Yes'"
44
+ elsif translate_hash[key]
45
+ # pull out all the string substitutions so that google doesn't translate those
46
+ pattern = /\{\{.+\}\}/
47
+ holder = '{{---}}'
48
+ replacements = translate_hash[key].scan(pattern)
49
+ translate_hash[key].gsub!(pattern, holder)
50
+ translate_hash[key] = translate(translate_hash[key], to, from)
51
+ replacements.each do |r|
52
+ translate_hash[key].sub!(holder, r)
53
+ end
54
+ else
55
+ puts "Key #{key} contains no data"
47
56
  end
48
57
  end
49
58
  end
data/lib/babelphish.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module Babelphish
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
 
7
7
  def self.load_tasks
8
8
  if File.exists?('Rakefile')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babelphish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Ball
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-21 00:00:00 -06:00
12
+ date: 2009-06-18 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency