lokalise_rails 5.1.0 → 6.0.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: 22e008938f4d8c056bd3ab42087a3ea5a996e32e0c5fc1eb5fbcaab978235c42
4
- data.tar.gz: e2ca1a4c9a6888e357c660ec721c8d6cee37ce51297ed5afb3992b7cbaba6b64
3
+ metadata.gz: 14b031485e357b3c1b4d4aa5640f214ddcdb382fe53266de02d70b118867515d
4
+ data.tar.gz: e0b8070461e74fcdf9dd465335b60486d98dd80456b46934029ef5da23e60525
5
5
  SHA512:
6
- metadata.gz: 56a4e4b06697bb5b1ddf40f43792e75b2321028665059833c7986d41821717f64cb3ea950b19a05fc9434854c8bfec61e4dd84f895172e0b53ac985265a4ccbd
7
- data.tar.gz: 82c589564b69dbc2d2e6921e2f6e5164959bbcf08ea2a5dd9822de474fc6d11c27429f957a2d05128e3927b0ecbe9da5bcdc4d4a9de6081a6b5be42dce6841be
6
+ metadata.gz: 9aab358a2d9cb224c199a0b052d5749ffad9dc4c3a1e739ab6a1532a7303dd45d88ba1e9b242e3a1ce8b8c0ecef98288abf7049124d2ae56170ebf417573eb20
7
+ data.tar.gz: fa9ed8e36017819eeb00f712910d582fb13d2ca63a07fb62b85c561fd3edb8e93fe1275a4fcca5be80093a97c4f5dc2260305daf94afa96146a22dd001831a27
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.0 (27-Jul-2023)
4
+
5
+ * Use lokalise-manager v4 and ruby-lokalise-api v8. The latter is a major rewrite of the original SDK and has some breaking changes (however 95% of the methods have similar signatures). Therefore please make sure that your tests pass.
6
+ * Do not test with Ruby 2.7 (EOL)
7
+
8
+ ## 5.2.0 (26-Jan-2023)
9
+
10
+ * The gem can now be added to the `development` group instead of `production` to reduce the bundle size
11
+ * Update dependences, test with Ruby 3.2
12
+
3
13
  ## 5.1.0 (26-Aug-2022)
4
14
 
5
15
  * Fixed an issue with `\n` being improperly imported
data/Gemfile CHANGED
@@ -5,16 +5,15 @@ source 'http://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :test do
8
- gem 'codecov', '~> 0.2'
9
8
  gem 'dotenv', '~> 2.5'
10
- gem 'rails', '~> 7.0'
9
+ gem 'rails', '~> 7.0.4'
11
10
  gem 'rake', '~> 13.0'
12
11
  gem 'rspec', '~> 3.6'
13
12
  gem 'rubocop', '~> 1.0'
14
13
  gem 'rubocop-performance', '~> 1.5'
14
+ gem 'rubocop-rake', '~> 0.6'
15
15
  gem 'rubocop-rspec', '~> 2.6'
16
- gem 'simplecov', '~> 0.16'
17
- gem 'sprockets-rails', '~> 3'
18
- gem 'tzinfo-data' # , platforms: %i[mingw mswin x64_mingw jruby]
19
- gem 'vcr', '~> 6.1'
16
+ gem 'simplecov', '~> 0.22'
17
+ gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
18
+ gem 'webmock', '~> 3.14'
20
19
  end
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Lokalise team, Ilya Krukowski
3
+ Copyright (c) 2023 Ilya Krukowski
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  ![Gem](https://img.shields.io/gem/v/lokalise_rails)
4
4
  ![CI](https://github.com/bodrovis/lokalise_rails/actions/workflows/ci.yml/badge.svg)
5
- [![Test Coverage](https://codecov.io/gh/bodrovis/lokalise_rails/graph/badge.svg)](https://codecov.io/gh/bodrovis/lokalise_rails)
6
5
  ![Downloads total](https://img.shields.io/gem/dt/lokalise_rails)
7
6
 
8
7
  This gem provides [Lokalise](http://lokalise.com) integration for Ruby on Rails and allows to exchange translation files easily. It relies on [lokalise_manager](https://github.com/bodrovis/lokalise_manager) which perform the actual import/export and can be used to run this task in any Ruby script.
@@ -13,13 +12,13 @@ This gem provides [Lokalise](http://lokalise.com) integration for Ruby on Rails
13
12
 
14
13
  ### Requirements
15
14
 
16
- This gem requires Ruby 2.5+ and Rails 5.1+. It might work with older versions of Rails though. You will also need to [setup a Lokalise account](https://app.lokalise.com/signup) and create a [translation project](https://docs.lokalise.com/en/articles/1400460-projects). Finally, you will need to generate a [read/write API token](https://docs.lokalise.com/en/articles/1929556-api-tokens) at your Lokalise profile.
15
+ This gem requires Ruby 2.7+ and Rails 5.1+. It might work with older versions of Rails though. You will also need to [setup a Lokalise account](https://app.lokalise.com/signup) and create a [translation project](https://docs.lokalise.com/en/articles/1400460-projects). Finally, you will need to generate a [read/write API token](https://docs.lokalise.com/en/articles/1929556-api-tokens) at your Lokalise profile.
17
16
 
18
17
  Alternatively, you can utilize a token obtained via OAuth 2 flow. When using such a token, you'll have to set `:use_oauth2_token` option to `true` (please check [options docs](https://github.com/bodrovis/lokalise_manager#common-config) to learn more).
19
18
 
20
19
  ### Installation
21
20
 
22
- Add the gem to your `Gemfile`:
21
+ Add the gem to your `Gemfile` (it can be added to the `development` group if you're not planning to import/export translations in production):
23
22
 
24
23
  ```ruby
25
24
  gem 'lokalise_rails'
@@ -102,6 +101,30 @@ importer.import!
102
101
  exporter.export!
103
102
  ```
104
103
 
104
+ ### Example: Multiple translation paths
105
+
106
+ Creating custom import/export script can come in really handy if you have a non-standard setup, for instance, your translation files are stored in multiple directories (not only in the default `./config/locales`. To overcome this problem, create a custom Rake task and provide as many importers/exporters as needed:
107
+
108
+ ```ruby
109
+ require 'rake'
110
+ require 'lokalise_rails'
111
+ require "#{LokaliseRails::Utils.root}/config/lokalise_rails"
112
+
113
+ namespace :lokalise_custom do
114
+ task :export do
115
+ # importing from the default directory (./config/locales/)
116
+ exporter = LokaliseManager.exporter({}, LokaliseRails::GlobalConfig)
117
+ exporter.export!
118
+
119
+ # importing from the custom directory
120
+ exporter = LokaliseManager.exporter({locales_path: "#{Rails.root}/config/custom_locales"}, LokaliseRails::GlobalConfig)
121
+ exporter.export!
122
+ rescue StandardError => e
123
+ abort e.inspect
124
+ end
125
+ end
126
+ ```
127
+
105
128
  ## Configuration
106
129
 
107
130
  Options are specified in the `config/lokalise_rails.rb` file.
@@ -165,9 +188,9 @@ end
165
188
 
166
189
  ## Running tests
167
190
 
168
- 1. Copypaste `.env.example` file as `.env`. Put your Lokalise API token and project ID inside. The `.env` file is excluded from version control so your data is safe. All in all, we use pre-recorded VCR cassettes, so the actual API requests wont be sent. However, providing at least some values is required.
191
+ 1. Copypaste `.env.example` file as `.env`. Put your Lokalise API token and project ID inside. The `.env` file is excluded from version control so your data is safe. All in all, we use stubbed requests, so the actual API requests won't be sent. However, providing at least some values is required.
169
192
  2. Run `rspec .`. Observe test results and code coverage.
170
193
 
171
194
  ## License
172
195
 
173
- Copyright (c) [Lokalise team](http://lokalise.com), [Ilya Krukowski](http://bodrovis.tech). License type is [MIT](https://github.com/bodrovis/lokalise_rails/blob/master/LICENSE).
196
+ Copyright (c) [Ilya Krukowski](http://bodrovis.tech). License type is [MIT](https://github.com/bodrovis/lokalise_rails/blob/master/LICENSE).
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rake'
4
+ require 'rake/clean'
5
+ require 'rspec/core/rake_task'
6
+ require 'rubocop/rake_task'
4
7
 
5
8
  begin
6
9
  require 'bundler/setup'
@@ -9,13 +12,33 @@ rescue LoadError
9
12
  puts 'although not required, bundler is recommened for running the tests'
10
13
  end
11
14
 
12
- task default: :spec
13
-
14
- require 'rspec/core/rake_task'
15
15
  RSpec::Core::RakeTask.new(:spec)
16
16
 
17
- require 'rubocop/rake_task'
18
17
  RuboCop::RakeTask.new do |task|
19
18
  task.requires << 'rubocop-performance'
20
19
  task.requires << 'rubocop-rspec'
20
+ task.requires << 'rubocop-rake'
21
+ end
22
+
23
+ CLOBBER.include(FileList['./*.gem'])
24
+
25
+ namespace :lokalise do
26
+ desc 'Updates RubyGems, installs dependencies'
27
+ task :install do
28
+ puts 'Running bundle install'
29
+ sh 'gem update --system'
30
+ sh 'bundle'
31
+ end
32
+
33
+ desc 'Builds the gem'
34
+ task :build do
35
+ puts 'Building'
36
+ sh 'gem build lokalise_rails.gemspec'
37
+ end
21
38
  end
39
+
40
+ task rubospec: %w[rubocop spec]
41
+
42
+ task full_build: %w[clobber lokalise:install lokalise:build]
43
+
44
+ task default: :full_build
@@ -1,54 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- LokaliseRails::GlobalConfig.config do |c|
4
- # These are mandatory options that you must set before running rake tasks:
5
- # c.api_token = ENV['LOKALISE_API_TOKEN']
6
- # c.project_id = ENV['LOKALISE_PROJECT_ID']
3
+ if defined?(LokaliseRails) && defined?(LokaliseRails::GlobalConfig)
4
+ LokaliseRails::GlobalConfig.config do |c|
5
+ # These are mandatory options that you must set before running rake tasks:
6
+ # c.api_token = ENV['LOKALISE_API_TOKEN']
7
+ # c.project_id = ENV['LOKALISE_PROJECT_ID']
7
8
 
8
- # Provide a custom path to the directory with your translation files:
9
- # c.locales_path = "#{Rails.root}/config/locales"
9
+ # Provide a custom path to the directory with your translation files:
10
+ # c.locales_path = "#{Rails.root}/config/locales"
10
11
 
11
- # Provide a Lokalise project branch to use:
12
- # c.branch = ''
12
+ # Provide a Lokalise project branch to use:
13
+ # c.branch = ''
13
14
 
14
- # Provide request timeouts for the Lokalise API client:
15
- # c.timeouts = {open_timeout: nil, timeout: nil}
15
+ # Provide request timeouts for the Lokalise API client:
16
+ # c.timeouts = {open_timeout: nil, timeout: nil}
16
17
 
17
- # Provide maximum number of retries for file exporting:
18
- # c.max_retries_export = 5
18
+ # Provide maximum number of retries for file exporting:
19
+ # c.max_retries_export = 5
19
20
 
20
- # Provide maximum number of retries for file importing:
21
- # c.max_retries_import = 5
21
+ # Provide maximum number of retries for file importing:
22
+ # c.max_retries_import = 5
22
23
 
23
- # Import options have the following defaults:
24
- # c.import_opts = {
25
- # format: 'ruby_yaml',
26
- # placeholder_format: :icu,
27
- # yaml_include_root: true,
28
- # original_filenames: true,
29
- # directory_prefix: '',
30
- # indentation: '2sp'
31
- # }
24
+ # Import options have the following defaults:
25
+ # c.import_opts = {
26
+ # format: 'ruby_yaml',
27
+ # placeholder_format: :icu,
28
+ # yaml_include_root: true,
29
+ # original_filenames: true,
30
+ # directory_prefix: '',
31
+ # indentation: '2sp'
32
+ # }
32
33
 
33
- # Safe mode for imports is disabled by default:
34
- # c.import_safe_mode = false
34
+ # Safe mode for imports is disabled by default:
35
+ # c.import_safe_mode = false
35
36
 
36
- # Additional export options (only filename, contents, and lang_iso params are provided by default)
37
- # c.export_opts = {}
37
+ # Additional export options (only filename, contents, and lang_iso params are provided by default)
38
+ # c.export_opts = {}
38
39
 
39
- # Provide additional file exclusion criteria for exports (by default, any file with the proper extension will be exported)
40
- # c.skip_file_export = ->(file) { file.split[1].to_s.include?('fr') }
40
+ # Provide additional file exclusion criteria for exports (by default, any file with the proper extension will be exported)
41
+ # c.skip_file_export = ->(file) { file.split[1].to_s.include?('fr') }
41
42
 
42
- # Set the options below if you would like to work with format other than YAML
43
- ## Regular expression to use when choosing the files to extract from the downloaded archive and upload to Lokalise
44
- ## c.file_ext_regexp = /\.ya?ml\z/i
43
+ # Set the options below if you would like to work with format other than YAML
44
+ ## Regular expression to use when choosing the files to extract from the downloaded archive and upload to Lokalise
45
+ ## c.file_ext_regexp = /\.ya?ml\z/i
45
46
 
46
- ## Load translations data and make sure they are valid:
47
- ## c.translations_loader = ->(raw_data) { YAML.safe_load raw_data }
47
+ ## Load translations data and make sure they are valid:
48
+ ## c.translations_loader = ->(raw_data) { YAML.safe_load raw_data }
48
49
 
49
- ## Convert translations data to a proper format:
50
- ## c.translations_converter = ->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }
50
+ ## Convert translations data to a proper format:
51
+ ## c.translations_converter = ->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }
51
52
 
52
- ## Infer language ISO code for the translation file:
53
- ## c.lang_iso_inferer = ->(data) { YAML.safe_load(data)&.keys&.first }
53
+ ## Infer language ISO code for the translation file:
54
+ ## c.lang_iso_inferer = ->(data) { YAML.safe_load(data)&.keys&.first }
55
+ end
54
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseRails
4
- VERSION = '5.1.0'
4
+ VERSION = '6.0.0'
5
5
  end
@@ -5,6 +5,7 @@ require 'lokalise_rails'
5
5
  require "#{LokaliseRails::Utils.root}/config/lokalise_rails"
6
6
 
7
7
  namespace :lokalise_rails do
8
+ desc 'Imports translation files from Lokalise to the current Rails project'
8
9
  task :import do
9
10
  importer = LokaliseManager.importer({}, LokaliseRails::GlobalConfig)
10
11
  importer.import!
@@ -12,6 +13,7 @@ namespace :lokalise_rails do
12
13
  abort e.inspect
13
14
  end
14
15
 
16
+ desc 'Exports translation files from the current Rails project to Lokalise'
15
17
  task :export do
16
18
  exporter = LokaliseManager.exporter({}, LokaliseRails::GlobalConfig)
17
19
  exporter.export!
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.extra_rdoc_files = ['README.md']
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_dependency 'lokalise_manager', '~> 3.2'
25
+ spec.add_dependency 'lokalise_manager', '~> 4.0'
26
26
  spec.add_dependency 'zeitwerk', '~> 2.4'
27
27
 
28
28
  spec.metadata = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lokalise_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-26 00:00:00.000000000 Z
11
+ date: 2023-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lokalise_manager
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.3.21
87
+ rubygems_version: 3.4.17
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Lokalise integration for Ruby on Rails