localeapp 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/.travis.yml +2 -11
- data/Appraisals +0 -5
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/README.md +3 -12
- data/bin/localeapp +1 -1
- data/gemfiles/i18n_0.4.gemfile +1 -1
- data/gemfiles/i18n_0.5.gemfile +1 -1
- data/gemfiles/i18n_0.6.gemfile +1 -1
- data/gemfiles/i18n_0.7.gemfile +1 -1
- data/lib/localeapp.rb +2 -23
- data/lib/localeapp/cli/install.rb +1 -1
- data/lib/localeapp/rails.rb +0 -4
- data/lib/localeapp/rails/controller.rb +7 -2
- data/lib/localeapp/routes.rb +0 -2
- data/lib/localeapp/routes/base.rb +1 -1
- data/lib/localeapp/version.rb +1 -1
- data/localeapp.gemspec +5 -5
- data/spec/localeapp/cli/install_spec.rb +2 -1
- data/spec/localeapp/rails/controller_spec.rb +37 -0
- data/spec/localeapp/routes_spec.rb +6 -0
- metadata +26 -28
- data/gemfiles/i18n_0.3.gemfile +0 -12
- data/lib/localeapp/rails/2_3_translation_helper_monkeypatch.rb +0 -36
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmVhOTI1MWRmMGYwM2YzNWYyNDU4NmM4N2Y1NGJkYWZjNTkxMmZmYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDQ5NmMyYjJkNjk5OWNjNjAyZjhjNGEzNmFkN2VkNjM4NjQzYjJlNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDAyMDU3Y2NiMjYxYzE1N2Q0OGE5ZjdlYjY5NWYxZTM0MGQzMmRiOGM5M2Rj
|
10
|
+
MzEwYzVmYjhhNTRkNGZmOWNiODFlN2VkNTk0NThjYmIyZDBhNTkxNTIyMDZm
|
11
|
+
MWQzYWZjZmIzYjVlZTljMTJmMDI5Y2M3YmQ2NTU4Njk5MmRmZjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDQxNDMwZjg3MzA2MjYyODAwOWU0ZTgwMTJiYWQ0MGRjN2JhNjIyZDEwYThm
|
14
|
+
YjVmYzkwODUwY2IwNTg3NjRjNjZlYjFmMzI0YjEzMzQyODU0NzBiMzkwOTc1
|
15
|
+
YTZkNDc4ODEwNWU3ZGRlNzc1NzNkYmI4Y2Y3ZWMxMmRhZDQ5OWY=
|
data/.travis.yml
CHANGED
@@ -1,28 +1,19 @@
|
|
1
1
|
before_install:
|
2
|
+
- gem install bundler
|
2
3
|
- gem update bundler
|
3
4
|
rvm:
|
4
5
|
- 1.9.3
|
5
6
|
- 2.0
|
6
7
|
- 2.1
|
7
8
|
- 2.2
|
9
|
+
- 2.3.1
|
8
10
|
- jruby
|
9
11
|
- jruby-head
|
10
12
|
gemfile:
|
11
|
-
- gemfiles/i18n_0.3.gemfile
|
12
13
|
- gemfiles/i18n_0.4.gemfile
|
13
14
|
- gemfiles/i18n_0.5.gemfile
|
14
15
|
- gemfiles/i18n_0.6.gemfile
|
15
16
|
- gemfiles/i18n_0.7.gemfile
|
16
|
-
matrix:
|
17
|
-
exclude:
|
18
|
-
- rvm: 2.0
|
19
|
-
gemfile: gemfiles/i18n_0.3.gemfile
|
20
|
-
- rvm: 2.1
|
21
|
-
gemfile: gemfiles/i18n_0.3.gemfile
|
22
|
-
- rvm: 2.2
|
23
|
-
gemfile: gemfiles/i18n_0.3.gemfile
|
24
|
-
- rvm: jruby-head
|
25
|
-
gemfile: gemfiles/i18n_0.3.gemfile
|
26
17
|
notifications:
|
27
18
|
slack:
|
28
19
|
secure: JryUWfe2JR0cfNT+TIHwryy8NS8m9/hbRhg+5UqwuYWuEp6gtcWCA05wKsajQyRrGaNGYKu81RA9jpQrirgQWzDUJl5o3sEWbqKZv3pW0ybn8Tx52N1mxW3Puar5KLZ8TPRphKKIJ8/1EhAh4zpC5Mtxv8Sz1/AHuqnlu6l+bb4=
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Add the localeapp gem to your `Gemfile` and install it:
|
|
21
21
|
echo "gem 'localeapp'" >> Gemfile
|
22
22
|
bundle install
|
23
23
|
|
24
|
-
Create a project on [Locale](https://localeapp.com) and get the api key. Then run:
|
24
|
+
Create a project on [Locale](https://www.localeapp.com) and get the api key. Then run:
|
25
25
|
|
26
26
|
bundle exec localeapp install <YOUR_API_KEY>
|
27
27
|
|
@@ -29,17 +29,8 @@ This will check everything looks good and create `config/initializers/localeapp.
|
|
29
29
|
|
30
30
|
### Rails 2.3
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
config.gem 'localeapp'
|
35
|
-
|
36
|
-
Install the gem:
|
37
|
-
|
38
|
-
rake gems:install
|
39
|
-
|
40
|
-
Create a project on localeapp.com and get the api key. Then run:
|
41
|
-
|
42
|
-
localeapp install <YOUR_API_KEY>
|
32
|
+
Rails 2.3 support has been discontinued after 1.0.2. Please use this
|
33
|
+
version at your own risk if you really want to.
|
43
34
|
|
44
35
|
### Non rails projects
|
45
36
|
|
data/bin/localeapp
CHANGED
@@ -127,7 +127,7 @@ arg_name "<file>"
|
|
127
127
|
command :push do |c|
|
128
128
|
c.action do |global_options, options, args|
|
129
129
|
if args.empty?
|
130
|
-
exit_now! "localeapp push requires
|
130
|
+
exit_now! "localeapp push requires a file or directory to push", 1
|
131
131
|
else
|
132
132
|
path = args.first
|
133
133
|
pusher = Localeapp::CLI::Push.new(global_options)
|
data/gemfiles/i18n_0.4.gemfile
CHANGED
data/gemfiles/i18n_0.5.gemfile
CHANGED
data/gemfiles/i18n_0.6.gemfile
CHANGED
data/gemfiles/i18n_0.7.gemfile
CHANGED
data/lib/localeapp.rb
CHANGED
@@ -1,26 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'i18n'
|
4
|
-
rescue LoadError
|
5
|
-
# we're in 2.3 and we need to load rails to get the vendored i18n
|
6
|
-
require 'thread' # for rubygems > 1.6.0 support
|
7
|
-
require 'active_support'
|
8
|
-
# This ugliness so we can load AS in the travis env
|
9
|
-
@loaded_active_support = true
|
10
|
-
end
|
11
|
-
|
12
|
-
begin
|
13
|
-
require 'i18n/core_ext/hash'
|
14
|
-
rescue LoadError
|
15
|
-
# This ugliness so we can load AS in the travis env
|
16
|
-
# Assume that we're in rails 2.3 and AS supplies deep_merge
|
17
|
-
# Load AS if we need to
|
18
|
-
unless @loaded_active_support
|
19
|
-
# we're in 2.3 and we need to load rails to get the vendored i18n
|
20
|
-
require 'thread' # for rubygems > 1.6.0 support
|
21
|
-
require 'active_support'
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require 'i18n'
|
2
|
+
require 'i18n/core_ext/hash'
|
24
3
|
|
25
4
|
require 'localeapp/i18n_shim'
|
26
5
|
require 'localeapp/version'
|
@@ -65,7 +65,7 @@ module Localeapp
|
|
65
65
|
localeapp_default_code = project_data['default_locale']['code']
|
66
66
|
@output.puts "Default Locale: #{localeapp_default_code} (#{project_data['default_locale']['name']})"
|
67
67
|
if I18n.default_locale.to_s != localeapp_default_code
|
68
|
-
@output.puts "WARNING: I18n.default_locale is #{I18n.default_locale}, change in config/
|
68
|
+
@output.puts "WARNING: I18n.default_locale is #{I18n.default_locale}, change in config/application.rb (Rails 3+)"
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
data/lib/localeapp/rails.rb
CHANGED
@@ -6,10 +6,6 @@ module Localeapp
|
|
6
6
|
|
7
7
|
ActionController::Base.send(:include, Localeapp::Rails::Controller)
|
8
8
|
|
9
|
-
if rails_version_matches? '~> 2.3' # TODO: Check previous rails versions if required
|
10
|
-
require 'localeapp/rails/2_3_translation_helper_monkeypatch'
|
11
|
-
end
|
12
|
-
|
13
9
|
# match all versions between https://github.com/rails/rails/commit/d57ce232a885b21e1d6d1f9fbf60bc5908ad880d and https://github.com/rails/rails/commit/4dbce79e95e3f56a9b48992dea4531493a5008cc on all branches
|
14
10
|
if rails_version_matches_all?('~> 4.0.10.rc1') |
|
15
11
|
rails_version_matches_all?('~> 4.1.0.rc1', '< 4.1.10.rc1') |
|
@@ -2,8 +2,13 @@ module Localeapp
|
|
2
2
|
module Rails
|
3
3
|
module Controller
|
4
4
|
def self.included(base)
|
5
|
-
base.
|
6
|
-
|
5
|
+
if base.respond_to? :before_action
|
6
|
+
base.before_action :handle_translation_updates
|
7
|
+
base.after_action :send_missing_translations
|
8
|
+
else
|
9
|
+
base.before_filter :handle_translation_updates
|
10
|
+
base.after_filter :send_missing_translations
|
11
|
+
end
|
7
12
|
end
|
8
13
|
|
9
14
|
def handle_translation_updates
|
data/lib/localeapp/routes.rb
CHANGED
data/lib/localeapp/version.rb
CHANGED
data/localeapp.gemspec
CHANGED
@@ -20,17 +20,17 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
|
-
s.add_dependency('
|
24
|
-
s.add_dependency('
|
25
|
-
s.add_dependency('
|
26
|
-
s.add_dependency('
|
23
|
+
s.add_dependency('mime-types', '~> 2.6')
|
24
|
+
s.add_dependency('i18n', '~> 0.4')
|
25
|
+
s.add_dependency('json', '~> 1.8')
|
26
|
+
s.add_dependency('rest-client', '~> 1.8')
|
27
27
|
s.add_dependency('ya2yaml')
|
28
28
|
s.add_dependency('gli')
|
29
29
|
|
30
30
|
s.add_development_dependency('rake')
|
31
31
|
s.add_development_dependency('rspec', '~> 3.3')
|
32
32
|
s.add_development_dependency('yard')
|
33
|
-
s.add_development_dependency('RedCloth')
|
33
|
+
s.add_development_dependency('RedCloth', '< 4.3')
|
34
34
|
s.add_development_dependency('aruba', '~> 0.8')
|
35
35
|
s.add_development_dependency('cucumber', '~> 2.0')
|
36
36
|
s.add_development_dependency('fakeweb')
|
@@ -126,7 +126,8 @@ describe Localeapp::CLI::Install::DefaultInstaller, '#check_default_locale' do
|
|
126
126
|
it "displays warning if I18n.default_locale doesn't match what's configured on localeapp.com" do
|
127
127
|
allow(I18n).to receive(:default_locale).and_return(:es)
|
128
128
|
installer.check_default_locale
|
129
|
-
expect(output.string)
|
129
|
+
expect(output.string)
|
130
|
+
.to match(%r{WARNING: I18n\.default_locale is es, change in config/application\.rb \(Rails 3\+\)})
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
@@ -7,6 +7,13 @@ class TestController
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
class TestActionController
|
11
|
+
def self.before_action(*options)
|
12
|
+
end
|
13
|
+
def self.after_action(*options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
require 'localeapp/rails/controller'
|
11
18
|
|
12
19
|
describe Localeapp::Rails::Controller, '#handle_translation_updates' do
|
@@ -143,3 +150,33 @@ describe Localeapp::Rails::Controller, '#send_missing_translations' do
|
|
143
150
|
@controller.send_missing_translations
|
144
151
|
end
|
145
152
|
end
|
153
|
+
|
154
|
+
describe Localeapp::Rails::Controller, 'Rails 5 before_action support' do
|
155
|
+
before do
|
156
|
+
TestActionController.send(:include, Localeapp::Rails::Controller)
|
157
|
+
configuration = {
|
158
|
+
:synchronization_data_file => LocaleappSynchronizationData::setup,
|
159
|
+
:api_key => "my_key"
|
160
|
+
}
|
161
|
+
with_configuration(configuration) do
|
162
|
+
@controller = TestActionController.new
|
163
|
+
end
|
164
|
+
now = Time.now; allow(Time).to receive(:now).and_return(now)
|
165
|
+
Localeapp.configuration.environment_name = 'development'
|
166
|
+
end
|
167
|
+
|
168
|
+
context "#handle_translation_updates" do
|
169
|
+
it "calls poller.poll! when the synchronization file's polled_at has changed" do
|
170
|
+
Localeapp.poller.write_synchronization_data!(01234, 56789)
|
171
|
+
expect(Localeapp.poller).to receive(:poll!)
|
172
|
+
@controller.handle_translation_updates
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context "#send_missing_translations" do
|
177
|
+
it "proceeds when configuration is enabled" do
|
178
|
+
expect(Localeapp.sender).to receive(:post_missing_translations)
|
179
|
+
@controller.send_missing_translations
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -98,6 +98,12 @@ describe Localeapp::Routes do
|
|
98
98
|
expect(@routes.remove_url(:key => 'test.key')).to eq("https://test.host/v1/projects/API_KEY/translations/test%2Ekey")
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
it "URL encodes the key name" do
|
103
|
+
with_configuration @config do
|
104
|
+
expect(@routes.remove_url key: "some key").to include "some+key"
|
105
|
+
end
|
106
|
+
end
|
101
107
|
end
|
102
108
|
|
103
109
|
describe "#rename_endpoint(options = {})" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localeapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Dell
|
@@ -10,64 +10,64 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: mime-types
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '2.6'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '2.6'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
30
|
+
name: i18n
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '0'
|
35
|
+
version: '0.4'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ~>
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0'
|
42
|
+
version: '0.4'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
44
|
+
name: json
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '1.8'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ~>
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '1.8'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: rest-client
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ~>
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '1.8'
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '
|
70
|
+
version: '1.8'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: ya2yaml
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,16 +142,16 @@ dependencies:
|
|
142
142
|
name: RedCloth
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- -
|
145
|
+
- - <
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version: '
|
147
|
+
version: '4.3'
|
148
148
|
type: :development
|
149
149
|
prerelease: false
|
150
150
|
version_requirements: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- -
|
152
|
+
- - <
|
153
153
|
- !ruby/object:Gem::Version
|
154
|
-
version: '
|
154
|
+
version: '4.3'
|
155
155
|
- !ruby/object:Gem::Dependency
|
156
156
|
name: aruba
|
157
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,7 +244,6 @@ files:
|
|
244
244
|
- features/support/env.rb
|
245
245
|
- features/support/hooks.rb
|
246
246
|
- features/update.feature
|
247
|
-
- gemfiles/i18n_0.3.gemfile
|
248
247
|
- gemfiles/i18n_0.4.gemfile
|
249
248
|
- gemfiles/i18n_0.5.gemfile
|
250
249
|
- gemfiles/i18n_0.6.gemfile
|
@@ -270,7 +269,6 @@ files:
|
|
270
269
|
- lib/localeapp/missing_translations.rb
|
271
270
|
- lib/localeapp/poller.rb
|
272
271
|
- lib/localeapp/rails.rb
|
273
|
-
- lib/localeapp/rails/2_3_translation_helper_monkeypatch.rb
|
274
272
|
- lib/localeapp/rails/backport_translation_helper_fix_to_honor_raise_option.rb
|
275
273
|
- lib/localeapp/rails/controller.rb
|
276
274
|
- lib/localeapp/rails/flatten.rb
|
data/gemfiles/i18n_0.3.gemfile
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# We're replacing the original method with one that doesn't set the :raise option.
|
2
|
-
# This means the exception handler will be called and missing translations get sent to
|
3
|
-
# localeapp. It's ugly but there's no other way to do it :(
|
4
|
-
|
5
|
-
module Localeapp::TranslationHelperRails23MonkeyPatch
|
6
|
-
# Delegates to I18n#translate but also performs two additional functions. First, it'll catch MissingTranslationData exceptions
|
7
|
-
# and turn them into inline spans that contains the missing key, such that you can see in a view what is missing where.
|
8
|
-
#
|
9
|
-
# Second, it'll scope the key by the current partial if the key starts with a period. So if you call translate(".foo") from the
|
10
|
-
# people/index.html.erb template, you'll actually be calling I18n.translate("people.index.foo"). This makes it less repetitive
|
11
|
-
# to translate many keys within the same partials and gives you a simple framework for scoping them consistently. If you don't
|
12
|
-
# prepend the key with a period, nothing is converted.
|
13
|
-
def translate(keys, options = {})
|
14
|
-
if multiple_keys = keys.is_a?(Array)
|
15
|
-
ActiveSupport::Deprecation.warn "Giving an array to translate is deprecated, please give a symbol or a string instead", caller
|
16
|
-
end
|
17
|
-
|
18
|
-
keys = scope_keys_by_partial(keys)
|
19
|
-
|
20
|
-
translations = I18n.translate(keys, options)
|
21
|
-
translations = [translations] if !multiple_keys && translations.size > 1
|
22
|
-
translations = html_safe_translation_keys(keys, translations)
|
23
|
-
|
24
|
-
if multiple_keys || translations.size > 1
|
25
|
-
translations
|
26
|
-
else
|
27
|
-
translations.first
|
28
|
-
end
|
29
|
-
rescue I18n::MissingTranslationData => e
|
30
|
-
keys = I18n.send(:normalize_translation_keys, e.locale, e.key, e.options[:scope])
|
31
|
-
content_tag('span', keys.join(', '), :class => 'translation_missing')
|
32
|
-
end
|
33
|
-
alias :t :translate
|
34
|
-
end
|
35
|
-
|
36
|
-
ActionView::Base.send(:include, ::Localeapp::TranslationHelperRails23MonkeyPatch)
|