lokalise_rails 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +5 -6
- data/LICENSE +1 -1
- data/README.md +3 -4
- data/Rakefile +27 -4
- data/lib/generators/templates/lokalise_rails_config.rb +40 -38
- data/lib/lokalise_rails/version.rb +2 -2
- data/lib/tasks/lokalise_rails_tasks.rake +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f210fb25454eb844cf639a709f81271aad408589d9b0269e6553fcfc02d112c
|
4
|
+
data.tar.gz: c2063c8f253c577412797aad2e2299cde7c715439fb2ddfc34b27c2c592ba7d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef1fd7e991348827a51f221851a9343ce473b1c1c8b85b77b63feb70ed22d15231d1339c8371e3435fa59543c6a52448470e7800c03e8d54402464251263bfe0
|
7
|
+
data.tar.gz: bcb9c3741313418c3fc35c121071884cdd7083ad8d66fb1d8f41357d7df68cfbfefd65dae677a73ea5e5361d7b914e64751429a89221804bd65b1bf62879b06f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 5.2.0 (26-Jan-2023)
|
4
|
+
|
5
|
+
* The gem can now be added to the `development` group instead of `production` to reduce the bundle size
|
6
|
+
* Update dependences, test with Ruby 3.2
|
7
|
+
|
3
8
|
## 5.1.0 (26-Aug-2022)
|
4
9
|
|
5
10
|
* 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.
|
17
|
-
gem '
|
18
|
-
gem '
|
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
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.
|
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'
|
@@ -165,7 +164,7 @@ end
|
|
165
164
|
|
166
165
|
## Running tests
|
167
166
|
|
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
|
167
|
+
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
168
|
2. Run `rspec .`. Observe test results and code coverage.
|
170
169
|
|
171
170
|
## 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
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
9
|
-
|
9
|
+
# Provide a custom path to the directory with your translation files:
|
10
|
+
# c.locales_path = "#{Rails.root}/config/locales"
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
# Provide a Lokalise project branch to use:
|
13
|
+
# c.branch = ''
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
# Provide request timeouts for the Lokalise API client:
|
16
|
+
# c.timeouts = {open_timeout: nil, timeout: nil}
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
# Provide maximum number of retries for file exporting:
|
19
|
+
# c.max_retries_export = 5
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
# Provide maximum number of retries for file importing:
|
22
|
+
# c.max_retries_import = 5
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
34
|
-
|
34
|
+
# Safe mode for imports is disabled by default:
|
35
|
+
# c.import_safe_mode = false
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
# Additional export options (only filename, contents, and lang_iso params are provided by default)
|
38
|
+
# c.export_opts = {}
|
38
39
|
|
39
|
-
|
40
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
|
47
|
+
## Load translations data and make sure they are valid:
|
48
|
+
## c.translations_loader = ->(raw_data) { YAML.safe_load raw_data }
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
## Convert translations data to a proper format:
|
51
|
+
## c.translations_converter = ->(raw_data) { YAML.dump(raw_data).gsub(/\\\\n/, '\n') }
|
51
52
|
|
52
|
-
|
53
|
-
|
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
|
@@ -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!
|
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.
|
4
|
+
version: 5.2.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:
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lokalise_manager
|
@@ -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.
|
87
|
+
rubygems_version: 3.4.5
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Lokalise integration for Ruby on Rails
|