localeapp 3.0.1 → 3.2.0

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
  SHA256:
3
- metadata.gz: 187204f032c72f78eb45ace5926a7291cb493cf3b5912deb9c94a1625044127b
4
- data.tar.gz: aa94e545971bc4cd66007f20f0c488808774f3280857264e79190192a366cc1f
3
+ metadata.gz: 85de9c28ef6cb1e929598b0e15d57ad7c24096dcc69e58f5980381a2d3462402
4
+ data.tar.gz: 89c70dcc761979df1ead452d5063f412d3dfccf8238e331fb0c2f7a7e4f235c8
5
5
  SHA512:
6
- metadata.gz: 9c6d8ed04be34b75f34b83d517ce8dd16c4d436b1b03bdd7cfd73414f89677b75de47ec5df3e4eb842557aebd882bc81b905d5aeffae983f69ccc8e932d11e0b
7
- data.tar.gz: 6ac0d69eff3a388880ca32e03de49d0ef4030bee7af8d402e1aba40ffa69cf5dea1924e9548dc68f89a4a67f397e27e31dc8f13fec6eebfe265f570c54c46b9f
6
+ metadata.gz: 0b9ad084d7e4128a62a307c4b011b9267be038f21f32262608aa548f94c7325325d403eed5815c74ac018c4742ae6543a11bdde1a2ff1d1c4f8658ddfbc259dd
7
+ data.tar.gz: cdc7790c9f6d8a62c3f5db3af4a3d848a7cbda9a3dbe95cd47beee2381fb48dfac0e646db9a3891fadc28c8a5a3bfff2e959b84a5e2c51449e3e6bbbf1de8643
data/.travis.yml CHANGED
@@ -1,14 +1,15 @@
1
1
  sudo: required
2
2
  dist: trusty
3
3
  before_install:
4
- - gem install bundler
4
+ - gem install bundler -v '< 2'
5
5
  rvm:
6
- - 2.5.0
7
- - 2.4.3
8
- - 2.3.6
9
- - 2.2.9
6
+ - 2.6.0
7
+ - 2.5.3
8
+ - 2.4.5
9
+ - 2.3.8
10
+ - 2.2.10
10
11
  - 2.1.10
11
- - jruby-9.1.15.0
12
+ - jruby
12
13
  gemfile:
13
14
  - Gemfile
14
15
  - spec/gemfiles/i18n_0.7.gemfile
@@ -17,4 +18,4 @@ gemfile:
17
18
  - spec/gemfiles/i18n_1.0.gemfile
18
19
  notifications:
19
20
  slack:
20
- secure: JryUWfe2JR0cfNT+TIHwryy8NS8m9/hbRhg+5UqwuYWuEp6gtcWCA05wKsajQyRrGaNGYKu81RA9jpQrirgQWzDUJl5o3sEWbqKZv3pW0ybn8Tx52N1mxW3Puar5KLZ8TPRphKKIJ8/1EhAh4zpC5Mtxv8Sz1/AHuqnlu6l+bb4=
21
+ secure: dPiP4+6xO6L9/RfXyivr2X2UohSD8CDdnnY57BvNgGVvFtQ2LUP9s1mDxj7gbBGhRZJzTMZlM/PU7bT9O9JCJPcpUs4dWg748KZ0ZGOslnv8yfzNbRh9U5OzyEjch2PFkEhpQPnuVCiof+ahjfxQQSkokpsbNa9DLlDmUapXFPY=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # master
2
2
 
3
+ # Version 3.2.0
4
+
5
+ * Support ruby 3.0 (thanks to [@spilin](https://github.com/spilin))
6
+
7
+ # Version 3.1.3
8
+
9
+ * Fix deprecation warning in Rails 6 initialization (thanks to [@ryanb](https://github.com/ryanb) for [reporting it](https://github.com/Locale/localeapp/issues/276))
10
+
11
+ # Version 3.1.2
12
+
13
+ * Fix a bug when `.env` is a directory (thanks to [@xijo](https://github.com/xijo) for [reporting it](https://github.com/Locale/localeapp/pull/262))
14
+
15
+ # Version 3.1.1
16
+
17
+ * Remove I18n Hash#deep_merge! usage
18
+ * Support ruby 2.6
19
+
20
+ # Version 3.1.0
21
+
22
+ * add `localeapp cp`
23
+
3
24
  # Version 3.0.1
4
25
 
5
26
  * actually prevent `CVE-2013-0269 / OSVDB-101137` (3.0.0 was supposed to)
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Locale
2
2
 
3
- [![Build status](https://secure.travis-ci.org/Locale/localeapp.png)](http://travis-ci.org/Locale/localeapp)
4
- [![Code Climate](https://codeclimate.com/github/Locale/localeapp.png)](https://codeclimate.com/github/Locale/localeapp)
5
- [![Gem Version](https://badge.fury.io/rb/localeapp.png)](http://badge.fury.io/rb/localeapp)
3
+ [![Build status](https://secure.travis-ci.org/Locale/localeapp.svg)](http://travis-ci.org/Locale/localeapp)
4
+ [![Code Climate](https://codeclimate.com/github/Locale/localeapp.svg)](https://codeclimate.com/github/Locale/localeapp)
5
+ [![Security](https://hakiri.io/github/Locale/localeapp/master.svg)](https://hakiri.io/github/Locale/localeapp/master)
6
+ [![Gem Version](https://badge.fury.io/rb/localeapp.svg)](http://badge.fury.io/rb/localeapp)
6
7
 
7
- The localeapp gem connects your rails app to the Locale service on http://www.localeapp.com. Locale makes hand editing translation files something you don't have to do.
8
+ The `localeapp` gem connects your Rails app to the Locale service on https://www.localeapp.com. Locale makes hand editing translation files something you don't have to do.
8
9
 
9
10
  The gem hooks into the i18n exception mechanism to send missing translations to the app. When translated content has been added it's automatically pulled down so you can see it straight away.
10
11
 
@@ -91,6 +92,14 @@ You can create translations on the command line by running:
91
92
 
92
93
  You must provide at least one translation and the locale code must already exist in the project.
93
94
 
95
+ ## Copy a translation
96
+
97
+ You can copy a translation on the command line by running:
98
+
99
+ localeapp cp key.source_name key.destination_name
100
+
101
+ If the destination key name exists in the project the content is overwritten, otherwise a new key is created.
102
+
94
103
  ## Automatically pulling translations
95
104
 
96
105
  There are two ways to do this, one that suits a single developer working the code locally and one where the translations are being pulled down to a staging (or live) server.
@@ -169,6 +178,10 @@ You can contact us via the support link at the bottom of the page or emailing su
169
178
 
170
179
  See corresponding [contributing guidelines][3].
171
180
 
181
+ ## Known bugs
182
+
183
+ We are aware about a compatibility issue with JRuby 9.1 and i18n 1.3. Our recommandation so far is to use i18n < 1.3 if you are using JRuby 9.1.
184
+
172
185
  ## License
173
186
 
174
187
  Copyright (c) 2014 [Locale][5] and other [contributors][6], released under the [MIT License][4].
data/bin/localeapp CHANGED
@@ -34,7 +34,7 @@ module LocaleappGLIWrapper
34
34
  global_options[:k]
35
35
  elsif ENV['LOCALEAPP_API_KEY']
36
36
  ENV['LOCALEAPP_API_KEY']
37
- elsif File.exist?('.env') && IO.read('.env') =~ /^LOCALEAPP_API_KEY=(\w+)$/
37
+ elsif File.file?('.env') && IO.read('.env') =~ /^LOCALEAPP_API_KEY=(\w+)$/
38
38
  $1
39
39
  else
40
40
  nil
@@ -138,6 +138,20 @@ module LocaleappGLIWrapper
138
138
  end
139
139
  end
140
140
 
141
+ desc "copies a key in the project"
142
+ arg_name "<source key name> <dest key name>"
143
+ command :cp do |c|
144
+ c.action do |global_options, options, args|
145
+ source_name = args.shift
146
+ dest_name = args.shift
147
+ if source_name.nil? || dest_name.nil?
148
+ exit_now! "localeapp cp requires a source key name and a destination key name", 1
149
+ else
150
+ Localeapp::CLI::Copy.new(global_options).execute(source_name, dest_name, *args)
151
+ end
152
+ end
153
+ end
154
+
141
155
  desc "Pulls one or all translations from localeapp.com"
142
156
  arg_name "<key> (optional)"
143
157
  command :pull do |c|
@@ -0,0 +1,19 @@
1
+ Feature: `cp' command
2
+
3
+ Scenario: Copies the given translation
4
+ Given I have a valid project on localeapp.com with api key "MYAPIKEY" and the translation key "foo.bar"
5
+ And an initializer file
6
+ When I successfully run `localeapp cp foo.bar foo.baz`
7
+ Then the output should contain:
8
+ """
9
+ Localeapp cp
10
+
11
+ Copying key: foo.bar to foo.baz
12
+ Success!
13
+ """
14
+
15
+ Scenario: Reports an error when the given API key is incorrect
16
+ Given no project exist on localeapp.com with API key "MYAPIKEY"
17
+ When I run `localeapp -k MYAPIKEY cp foo.bar foo.baz`
18
+ Then the exit status must be 70
19
+ And the output must match /error.+404/i
@@ -56,6 +56,7 @@ When /^I have a valid project on localeapp\.com with api key "([^"]*)" and the t
56
56
  uri = "https://api.localeapp.com/v1/projects/#{api_key}/translations/#{key_name.gsub(/\./, '%2E')}"
57
57
  add_fake_web_uri(:delete, uri, ['200', 'OK'], '')
58
58
  add_fake_web_uri(:post, uri + '/rename', ['200', 'OK'], '')
59
+ add_fake_web_uri(:post, uri + '/copy', ['200', 'OK'], '')
59
60
  end
60
61
 
61
62
  When /^I have a LOCALEAPP_API_KEY env variable set to "(.*?)"$/ do |api_key|
data/lib/localeapp.rb CHANGED
@@ -24,6 +24,7 @@ require 'localeapp/cli/update'
24
24
  require 'localeapp/cli/add'
25
25
  require 'localeapp/cli/remove'
26
26
  require 'localeapp/cli/rename'
27
+ require 'localeapp/cli/copy'
27
28
  require 'localeapp/cli/daemon'
28
29
 
29
30
  module Localeapp
@@ -0,0 +1,28 @@
1
+ module Localeapp
2
+ module CLI
3
+ class Copy < Command
4
+ include ::Localeapp::ApiCall
5
+
6
+ def execute(source_name, dest_name, *rest)
7
+ @output.puts "Localeapp cp"
8
+ @output.puts ""
9
+ @output.puts "Copying key: #{source_name} to #{dest_name}"
10
+ api_call :copy,
11
+ :url_options => { :source_name => source_name },
12
+ :payload => { :dest_name => dest_name },
13
+ :success => :report_success,
14
+ :failure => :report_failure,
15
+ :max_connection_attempts => 1
16
+ end
17
+
18
+ def report_success(response)
19
+ @output.puts "Success!"
20
+ end
21
+
22
+ def report_failure(response)
23
+ @output.puts "Failed!"
24
+ fail APIResponseError, "API returned #{response.code} status code"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -4,7 +4,9 @@ module Localeapp
4
4
  module Rails
5
5
  def self.initialize
6
6
 
7
- ActionController::Base.send(:include, Localeapp::Rails::Controller)
7
+ ActiveSupport.on_load(:action_controller) do
8
+ ActionController::Base.send(:include, Localeapp::Rails::Controller)
9
+ end
8
10
 
9
11
  # match all versions between https://github.com/rails/rails/commit/d57ce232a885b21e1d6d1f9fbf60bc5908ad880d and https://github.com/rails/rails/commit/4dbce79e95e3f56a9b48992dea4531493a5008cc on all branches
10
12
  if rails_version_matches_all?('~> 4.0.10.rc1') |
@@ -16,9 +16,9 @@ module Localeapp
16
16
  def translate(key, options = {})
17
17
  full_key = [options[:scope], key].compact.join(".")
18
18
  if full_key =~ Localeapp.configuration.blacklisted_keys_pattern
19
- super(key, options)
19
+ super(key, **options)
20
20
  else
21
- super(key, {:raise => false}.merge(options))
21
+ super(key, **{:raise => false}.merge(options))
22
22
  end
23
23
  end
24
24
  alias :t :translate
@@ -6,6 +6,7 @@ require "localeapp/routes/remove"
6
6
  require "localeapp/routes/rename"
7
7
  require "localeapp/routes/missing_translations"
8
8
  require "localeapp/routes/import"
9
+ require "localeapp/routes/copy"
9
10
 
10
11
  module Localeapp
11
12
  module Routes
@@ -19,5 +20,6 @@ module Localeapp
19
20
  include Rename
20
21
  include MissingTranslations
21
22
  include Import
23
+ include Copy
22
24
  end
23
25
  end
@@ -0,0 +1,24 @@
1
+ module Localeapp
2
+ module Routes
3
+ module Copy
4
+ def copy_endpoint(options = {})
5
+ [:post, copy_url(options)]
6
+ end
7
+
8
+ def copy_url(options = {})
9
+ url = http_scheme.build(base_options.merge(:path => copy_path(options[:source_name], options[:format])))
10
+ url.to_s
11
+ end
12
+
13
+ private
14
+
15
+ def copy_path(source_name, format = nil)
16
+ raise "copy_path requires source name" if source_name.nil?
17
+ path = translations_path << "/#{escape_key(source_name)}" << "/copy"
18
+ path << ".#{format}" if format
19
+ path
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -11,7 +11,7 @@ module Localeapp
11
11
  translations = Localeapp.load_yaml_file(filename)
12
12
  if data['translations'] && data['translations'][short_code]
13
13
  new_data = { short_code => data['translations'][short_code] }
14
- translations.deep_merge!(new_data)
14
+ translations = deep_merge translations, new_data
15
15
  end
16
16
  else
17
17
  translations = { short_code => data['translations'][short_code] }
@@ -42,6 +42,16 @@ module Localeapp
42
42
 
43
43
  private
44
44
 
45
+ def deep_merge(original, other)
46
+ original.merge other do |_, a, b|
47
+ if Hash === a && Hash === b
48
+ deep_merge a, b
49
+ else
50
+ b
51
+ end
52
+ end
53
+ end
54
+
45
55
  def generate_yaml(translations)
46
56
  YAML.dump(translations, :line_width => -1)[4..-1]
47
57
  end
@@ -1,3 +1,3 @@
1
1
  module Localeapp
2
- VERSION = "3.0.1"
2
+ VERSION = "3.2.0"
3
3
  end
data/localeapp.gemspec CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = "localeapp"
7
7
  s.version = Localeapp::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Christopher Dell", "Chris McGrath", "Michael Baudino"]
10
- s.email = ["chris@tigrish.com", "chris@octopod.info", "michael.baudino@alpine-lab.com"]
9
+ s.authors = ["Christopher Dell", "Chris McGrath", "Michael Baudino", "Thibault Dalban"]
10
+ s.email = ["chris@tigrish.com", "chris@octopod.info", "michael.baudino@alpine-lab.com", "thibault.dalban@alpine-lab.com"]
11
11
  s.homepage = "http://www.localeapp.com"
12
12
  s.summary = %q{Easy i18n translation management with localeapp.com}
13
13
  s.description = %q{Synchronizes i18n translation keys and content with localeapp.com so you don't have to manage translations by hand.}
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe Localeapp::CLI::Copy, "#execute(source_name, dest_name, *rest)" do
4
+ def do_action(source_name = "test.source_name", dest_name = "test.dest_name")
5
+ @command.execute(source_name, dest_name)
6
+ end
7
+
8
+ before(:each) do
9
+ @output = StringIO.new
10
+ @command = Localeapp::CLI::Copy.new(:output => @output)
11
+ end
12
+
13
+ it "makes the api call to the translations endpoint with the destination name as the post body" do
14
+ with_configuration do
15
+ expect(@command).to receive(:api_call).with(
16
+ :copy,
17
+ :url_options => { :source_name => "test.source_name" },
18
+ :payload => { :dest_name => "test.dest_name" },
19
+ :success => :report_success,
20
+ :failure => :report_failure,
21
+ :max_connection_attempts => anything
22
+ )
23
+ do_action
24
+ end
25
+ end
26
+ end
@@ -124,6 +124,24 @@ describe Localeapp::Routes do
124
124
  end
125
125
  end
126
126
 
127
+ describe "#copy_endpoint(options = {})" do
128
+ it "returns :post and the copy url for the options" do
129
+ with_configuration(@config) do
130
+ options = { :source_name => "foo.bar" }
131
+ expect(@routes).to receive(:copy_url).with(options).and_return("url")
132
+ expect(@routes.copy_endpoint(options)).to eq([:post, "url"])
133
+ end
134
+ end
135
+ end
136
+
137
+ describe "#copy_url(options = {})" do
138
+ it "extends the project_url and includes the escaped key name" do
139
+ with_configuration(@config) do
140
+ expect(@routes.copy_url(:source_name => "test.key")).to eq("https://test.host/v1/projects/API_KEY/translations/test%2Ekey/copy")
141
+ end
142
+ end
143
+ end
144
+
127
145
  describe "#export_url" do
128
146
  it "it extends the project_url and defaults to yml" do
129
147
  with_configuration(@config) do
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localeapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Dell
8
8
  - Chris McGrath
9
9
  - Michael Baudino
10
+ - Thibault Dalban
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2018-03-12 00:00:00.000000000 Z
14
+ date: 2021-07-12 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: i18n
@@ -164,6 +165,7 @@ email:
164
165
  - chris@tigrish.com
165
166
  - chris@octopod.info
166
167
  - michael.baudino@alpine-lab.com
168
+ - thibault.dalban@alpine-lab.com
167
169
  executables:
168
170
  - localeapp
169
171
  extensions: []
@@ -181,6 +183,7 @@ files:
181
183
  - cucumber.yml
182
184
  - features/add.feature
183
185
  - features/bad_command.feature
186
+ - features/cp.feature
184
187
  - features/env_file.feature
185
188
  - features/environment.feature
186
189
  - features/help.feature
@@ -203,6 +206,7 @@ files:
203
206
  - lib/localeapp/api_caller.rb
204
207
  - lib/localeapp/cli/add.rb
205
208
  - lib/localeapp/cli/command.rb
209
+ - lib/localeapp/cli/copy.rb
206
210
  - lib/localeapp/cli/daemon.rb
207
211
  - lib/localeapp/cli/install.rb
208
212
  - lib/localeapp/cli/pull.rb
@@ -225,6 +229,7 @@ files:
225
229
  - lib/localeapp/rails/mimic_rails_missing_translation_display.rb
226
230
  - lib/localeapp/routes.rb
227
231
  - lib/localeapp/routes/base.rb
232
+ - lib/localeapp/routes/copy.rb
228
233
  - lib/localeapp/routes/export.rb
229
234
  - lib/localeapp/routes/import.rb
230
235
  - lib/localeapp/routes/missing_translations.rb
@@ -250,6 +255,7 @@ files:
250
255
  - spec/localeapp/api_call_spec.rb
251
256
  - spec/localeapp/api_caller_spec.rb
252
257
  - spec/localeapp/cli/add_spec.rb
258
+ - spec/localeapp/cli/copy_spec.rb
253
259
  - spec/localeapp/cli/daemon_spec.rb
254
260
  - spec/localeapp/cli/install_spec.rb
255
261
  - spec/localeapp/cli/pull_spec.rb
@@ -292,8 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
298
  - !ruby/object:Gem::Version
293
299
  version: '0'
294
300
  requirements: []
295
- rubyforge_project: localeapp
296
- rubygems_version: 2.7.6
301
+ rubygems_version: 3.0.3
297
302
  signing_key:
298
303
  specification_version: 4
299
304
  summary: Easy i18n translation management with localeapp.com