i18n-one_sky 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ PATH
3
3
  specs:
4
4
  i18n-one_sky (0.0.1)
5
5
  i18n (~> 0.5.0)
6
- one_sky (~> 0.0.1)
6
+ one_sky (~> 0.0.2)
7
7
  thor (~> 0.14.4)
8
8
 
9
9
  GEM
@@ -13,7 +13,7 @@ GEM
13
13
  i18n (0.5.0)
14
14
  json (1.4.6)
15
15
  mime-types (1.16)
16
- one_sky (0.0.1)
16
+ one_sky (0.0.2)
17
17
  json (~> 1.4.6)
18
18
  rest-client (~> 1.6.1)
19
19
  rest-client (1.6.1)
@@ -35,6 +35,6 @@ DEPENDENCIES
35
35
  bundler (~> 1.0.0)
36
36
  i18n (~> 0.5.0)
37
37
  i18n-one_sky!
38
- one_sky (~> 0.0.1)
38
+ one_sky (~> 0.0.2)
39
39
  rspec (~> 2.2.0)
40
40
  thor (~> 0.14.4)
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rubyforge_project = "i18n-one_sky"
16
16
 
17
17
  s.add_dependency "i18n", "~> 0.5.0"
18
- s.add_dependency "one_sky", "~> 0.0.1"
18
+ s.add_dependency "one_sky", "~> 0.0.2"
19
19
  s.add_dependency "thor", "~> 0.14.4"
20
20
 
21
21
  s.add_development_dependency "rspec", "~> 2.2.0"
@@ -21,7 +21,8 @@ module I18n
21
21
  def initialize(options = {})
22
22
  options = default_options.merge!(options)
23
23
  @project = ::OneSky::Project.new(options[:api_key], options[:api_secret], options[:project])
24
- @one_sky_locale = @project.details["original_lang_code"].to_s
24
+ #@one_sky_locale = @project.details["base_locale"].gsub('_', '-')
25
+ @one_sky_locale = @project.details["base_locale"]
25
26
  check_default_locales_match
26
27
  @one_sky_languages = @project.languages
27
28
  end
@@ -64,7 +65,7 @@ module I18n
64
65
 
65
66
  # When your translators are done, call this method to download all available translations and save them as Simple backend *.yml files.
66
67
  # Outside of Rails, manually supply the path where downloaded files should be saved.
67
- def download_translations(path=nil)
68
+ def download_translations(path=nil, download_base_locale=false)
68
69
  if defined? Rails
69
70
  path ||= [Rails.root.to_s, "config", "locales"].join("/")
70
71
  else
@@ -88,7 +89,7 @@ module I18n
88
89
  File.delete(*Dir.glob("#{path}/*_one_sky.yml"))
89
90
 
90
91
  # Process each locale and save to file
91
- @translations.map { |k,v| save_locale(k, v, "#{path}/#{k}_one_sky.yml") unless k.to_s == @one_sky_locale }
92
+ @translations.map { |k,v| save_locale(k, v, "#{path}/#{k}_one_sky.yml") unless (k.to_s == @one_sky_locale and !download_base_locale)}
92
93
  end
93
94
 
94
95
  protected
@@ -101,13 +102,13 @@ module I18n
101
102
  parts.each_with_index { |segment,i| node[segment]; i == parts.size - 1 ? node[segment] = v : node = node[segment] }
102
103
  end
103
104
 
104
- lang = @one_sky_languages.find { |e| e["lang_code"] == lang_code }
105
+ lang = @one_sky_languages.find { |e| e["locale"] == lang_code }
105
106
 
106
107
  File.open(filename, 'w') do |f|
107
108
  f.puts "# PLEASE DO NOT EDIT THIS FILE."
108
109
  f.puts "# This was downloaded from OneSky. Log in to your OneSky account to manage translations on their website."
109
- f.puts "# Language code: #{lang['lang_code']}"
110
- f.puts "# Language name: #{lang['name']}"
110
+ f.puts "# Language code: #{lang['locale']}"
111
+ f.puts "# Language name: #{lang['local_name']}"
111
112
  f.puts "# Language English name: #{lang['eng_name']}"
112
113
  f.print(nested.to_yaml)
113
114
  end
@@ -124,7 +125,7 @@ module I18n
124
125
 
125
126
  def check_default_locales_match
126
127
  # Special case: i18n "en" is "en-us".
127
- i18n_default_locale = I18n.default_locale == :en ? "en-us" : I18n.default_locale.to_s.downcase
128
+ i18n_default_locale = I18n.default_locale == :en ? "en_us" : I18n.default_locale.to_s.downcase
128
129
  raise DefaultLocaleMismatchError, "I18n and OneSky have different default locale settings. #{I18n.default_locale.to_s} <> #{@one_sky_locale}" if i18n_default_locale != @one_sky_locale.downcase
129
130
  end
130
131
  end
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Onesky
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -50,7 +50,7 @@ describe "SimpleClient" do
50
50
  describe "#download_translations" do
51
51
  path = [File.dirname(__FILE__), 'data'].join('/')
52
52
  it "saves translation files." do
53
- @client.download_translations(path).should be_a_kind_of Array
53
+ @client.download_translations(path, true).should be_a_kind_of Array
54
54
  Dir.glob("#{path}/*_one_sky.yml").size.should >= 1
55
55
  end
56
56
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Junjun Olympia
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-03 00:00:00 +08:00
17
+ date: 2011-02-27 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -43,8 +43,8 @@ dependencies:
43
43
  segments:
44
44
  - 0
45
45
  - 0
46
- - 1
47
- version: 0.0.1
46
+ - 2
47
+ version: 0.0.2
48
48
  type: :runtime
49
49
  version_requirements: *id002
50
50
  - !ruby/object:Gem::Dependency