lokalise_rails 7.0.0 → 7.1.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 +9 -0
- data/Gemfile +3 -3
- data/{LICENSE → LICENSE.md} +1 -1
- data/README.md +1 -1
- data/lib/generators/lokalise_rails/install_generator.rb +10 -3
- data/lib/generators/templates/lokalise_rails_config.rb +1 -1
- data/lib/lokalise_rails/global_config.rb +8 -1
- data/lib/lokalise_rails/railtie.rb +10 -1
- data/lib/lokalise_rails/utils.rb +14 -2
- data/lib/lokalise_rails/version.rb +1 -1
- data/lib/lokalise_rails.rb +9 -4
- data/lib/tasks/lokalise_rails_tasks.rake +13 -2
- data/lokalise_rails.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adc84e45664149969dc3b43785c69dcc4c1a25de7758c69e5919fee2a6c05ca6
|
4
|
+
data.tar.gz: 9bc56d68d164f71817c01fa4c7ef7e9c32db55de2c36e1322554f768936ab9f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 075afa9c3de13cacf3b99066cd437fd34304ef85bcad5e016c9b7e41345d6f47d4fb3a55c34cbde60d95df59b2d1db22481c53c778276c1b736f733c4b20b255
|
7
|
+
data.tar.gz: 52f74f3f052b3cb3ab01aba2f899fb6434dc8614683bcd9fcbaab3cbf5bcf55c88a78b76d6b910aa4c24415743259b6ecd9e8feb5bdde7e76fcd58896bf0faa9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 7.1.0 (12-Nov-2024)
|
4
|
+
|
5
|
+
* Test with Rails 8
|
6
|
+
* Various updates
|
7
|
+
|
8
|
+
## 7.0.1 (10-May-2024)
|
9
|
+
|
10
|
+
* Update documentation, minor code tweaks
|
11
|
+
|
3
12
|
## 7.0.0 (09-Nov-2023)
|
4
13
|
|
5
14
|
* **Breaking change**: require Ruby 3+. Version 2.7 has reached end-of-life and thus we are not planning to support it anymore. If you need support for Ruby 2.7, please stay on 6.0.0.
|
data/Gemfile
CHANGED
@@ -5,14 +5,14 @@ source 'http://rubygems.org'
|
|
5
5
|
gemspec
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem 'dotenv', '~>
|
9
|
-
gem 'rails', '
|
8
|
+
gem 'dotenv', '~> 3.0'
|
9
|
+
gem 'rails', '8.0.0'
|
10
10
|
gem 'rake', '~> 13.0'
|
11
11
|
gem 'rspec', '~> 3.6'
|
12
12
|
gem 'rubocop', '~> 1.0'
|
13
13
|
gem 'rubocop-performance', '~> 1.5'
|
14
14
|
gem 'rubocop-rake', '~> 0.6'
|
15
|
-
gem 'rubocop-rspec', '~>
|
15
|
+
gem 'rubocop-rspec', '~> 3.0'
|
16
16
|
gem 'simplecov', '~> 0.22'
|
17
17
|
gem 'simplecov-lcov', '~> 0.8'
|
18
18
|
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
|
data/{LICENSE → LICENSE.md}
RENAMED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ This gem provides [Lokalise](http://lokalise.com) integration for Ruby on Rails
|
|
14
14
|
|
15
15
|
### Requirements
|
16
16
|
|
17
|
-
This gem requires Ruby
|
17
|
+
This gem requires Ruby 3.0+ 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.
|
18
18
|
|
19
19
|
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).
|
20
20
|
|
@@ -3,15 +3,22 @@
|
|
3
3
|
require 'rails/generators'
|
4
4
|
|
5
5
|
module LokaliseRails
|
6
|
-
# Generators for LokaliseRails
|
7
6
|
module Generators
|
8
|
-
#
|
7
|
+
# Generator that sets up the LokaliseRails configuration in a Rails application.
|
8
|
+
# It copies a predefined configuration template into the appropriate directory within the Rails application,
|
9
|
+
# making it easier for users to configure and use LokaliseRails.
|
9
10
|
class InstallGenerator < Rails::Generators::Base
|
11
|
+
# Sets the directory containing the template files relative to this file's location.
|
10
12
|
source_root File.expand_path('../templates', __dir__)
|
11
13
|
|
12
|
-
|
14
|
+
# Description of the generator's purpose, which is displayed in the Rails generators list.
|
15
|
+
desc 'Creates a LokaliseRails config file in your Rails application.'
|
13
16
|
|
17
|
+
# The primary method of this generator, responsible for copying the LokaliseRails configuration template
|
18
|
+
# from the gem to the Rails application's config directory. This is where users can customize
|
19
|
+
# their Lokalise settings.
|
14
20
|
def copy_config
|
21
|
+
# Copies the configuration template to the Rails application's config directory.
|
15
22
|
template 'lokalise_rails_config.rb', "#{Rails.root}/config/lokalise_rails.rb"
|
16
23
|
end
|
17
24
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
if defined?(LokaliseRails
|
3
|
+
if defined?(LokaliseRails::GlobalConfig)
|
4
4
|
LokaliseRails::GlobalConfig.config do |c|
|
5
5
|
# These are mandatory options that you must set before running rake tasks:
|
6
6
|
# c.api_token = ENV['LOKALISE_API_TOKEN']
|
@@ -1,10 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module LokaliseRails
|
4
|
-
#
|
4
|
+
# Inherits from LokaliseManager::GlobalConfig to provide a global configuration specific to the LokaliseRails gem.
|
5
|
+
# This class is primarily used to manage configuration settings that affect how the LokaliseRails gem operates
|
6
|
+
# within a Ruby on Rails application, particularly in managing locale paths.
|
5
7
|
class GlobalConfig < LokaliseManager::GlobalConfig
|
6
8
|
class << self
|
9
|
+
# Provides the path to the locales directory where translation files are stored. If not set explicitly,
|
10
|
+
# it defaults to the `config/locales` directory within the root of the application using this gem.
|
11
|
+
#
|
12
|
+
# @return [String] the path to the locales directory
|
7
13
|
def locales_path
|
14
|
+
# If @locales_path is not set, it defaults to a path under the application's root directory.
|
8
15
|
@locales_path || "#{LokaliseRails::Utils.root}/config/locales"
|
9
16
|
end
|
10
17
|
end
|
@@ -1,9 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module LokaliseRails
|
4
|
-
#
|
4
|
+
# The Railtie class in Rails is used to extend Rails' functionality within an application, or in this case,
|
5
|
+
# a gem. This Railtie is specifically used to add custom Rake tasks from the
|
6
|
+
# LokaliseRails gem into the Rails application.
|
7
|
+
#
|
8
|
+
# It leverages Rails' Railtie architecture to ensure the Rake
|
9
|
+
# tasks are loaded when the application boots up and Rake is invoked.
|
5
10
|
class Railtie < Rails::Railtie
|
11
|
+
# Register Rake tasks that are defined within this gem. This block is called by Rails during the initialization
|
12
|
+
# process and ensures that all Rake tasks specific to LokaliseRails are available to the application.
|
6
13
|
rake_tasks do
|
14
|
+
# Loads the Rake tasks from a file located relative to this file. Ensure this file exists and contains
|
15
|
+
# valid Rake task definitions specifically tailored for Lokalise integration.
|
7
16
|
load 'tasks/lokalise_rails_tasks.rake'
|
8
17
|
end
|
9
18
|
end
|
data/lib/lokalise_rails/utils.rb
CHANGED
@@ -6,16 +6,28 @@ module LokaliseRails
|
|
6
6
|
# Util methods
|
7
7
|
module Utils
|
8
8
|
class << self
|
9
|
-
#
|
9
|
+
# Retrieves the root directory of the current project.
|
10
|
+
# It attempts to find the Rails root directory if Rails is loaded.
|
11
|
+
# If Rails is not present, it defaults to the current working directory of the process.
|
12
|
+
#
|
13
|
+
# @return [Pathname] A Pathname object pointing to the root directory of the project.
|
10
14
|
def root
|
15
|
+
# Uses Pathname to create a robust path object from the rails_root or the current working directory.
|
11
16
|
Pathname.new(rails_root || Dir.getwd)
|
12
17
|
end
|
13
18
|
|
14
|
-
#
|
19
|
+
# Attempts to determine the root directory of a Rails
|
20
|
+
# project by checking the presence of Rails and its root method.
|
21
|
+
# If Rails is older and does not have the root method, it falls back to the RAILS_ROOT constant if defined.
|
22
|
+
#
|
23
|
+
# @return [String, nil] the path to the root directory if Rails is defined, or nil if it cannot be determined.
|
15
24
|
def rails_root
|
25
|
+
# First, check if Rails.root is defined and return its path if available.
|
16
26
|
return ::Rails.root.to_s if defined?(::Rails.root) && ::Rails.root
|
27
|
+
# Fallback to the RAILS_ROOT constant from older Rails versions.
|
17
28
|
return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
|
18
29
|
|
30
|
+
# Returns nil if none of the above are defined, indicating Rails is not present.
|
19
31
|
nil
|
20
32
|
end
|
21
33
|
end
|
data/lib/lokalise_rails.rb
CHANGED
@@ -3,14 +3,19 @@
|
|
3
3
|
require 'zeitwerk'
|
4
4
|
require 'lokalise_manager'
|
5
5
|
|
6
|
+
# Configure Zeitwerk loader specific for gem environments. This loader is set up to ignore certain files
|
7
|
+
# that should not be autoloaded, such as Rails-specific files or templates which are not part of the main load path.
|
6
8
|
loader = Zeitwerk::Loader.for_gem
|
7
|
-
loader.ignore "#{__dir__}/lokalise_rails/railtie.rb"
|
8
|
-
loader.ignore "#{__dir__}/generators/templates/lokalise_rails_config.rb"
|
9
|
-
loader.ignore "#{__dir__}/generators/lokalise_rails/install_generator.rb"
|
9
|
+
loader.ignore "#{__dir__}/lokalise_rails/railtie.rb" # Ignore the Railtie in non-Rails environments
|
10
|
+
loader.ignore "#{__dir__}/generators/templates/lokalise_rails_config.rb" # Ignore the generator templates
|
11
|
+
loader.ignore "#{__dir__}/generators/lokalise_rails/install_generator.rb" # Ignore installation generator scripts
|
10
12
|
loader.setup
|
11
13
|
|
12
|
-
# Main LokaliseRails module
|
14
|
+
# Main module for the LokaliseRails gem. This module serves as the namespace for all components
|
15
|
+
# related to the LokaliseRails integration. It provides a structured way to manage translations
|
16
|
+
# through the Lokalise platform within Ruby on Rails applications.
|
13
17
|
module LokaliseRails
|
14
18
|
end
|
15
19
|
|
20
|
+
# Require the Railtie only if Rails is defined to integrate with Rails without manual configuration.
|
16
21
|
require_relative 'lokalise_rails/railtie' if defined?(Rails)
|
@@ -2,22 +2,33 @@
|
|
2
2
|
|
3
3
|
require 'rake'
|
4
4
|
require 'lokalise_rails'
|
5
|
+
# Loads the configuration settings from the lokalise_rails configuration file within the Rails project.
|
5
6
|
require "#{LokaliseRails::Utils.root}/config/lokalise_rails"
|
6
7
|
|
8
|
+
# Namespace for Rake tasks related to the LokaliseRails gem.
|
9
|
+
# These tasks facilitate the synchronization of localization files between the Rails project and the Lokalise platform.
|
7
10
|
namespace :lokalise_rails do
|
11
|
+
# Imports translation files from Lokalise and integrates them into the current Rails project.
|
12
|
+
# This task utilizes the LokaliseManager to handle the import process according to the configuration specified
|
13
|
+
# in the GlobalConfig class.
|
8
14
|
desc 'Imports translation files from Lokalise to the current Rails project'
|
9
15
|
task :import do
|
10
16
|
importer = LokaliseManager.importer({}, LokaliseRails::GlobalConfig)
|
11
17
|
importer.import!
|
12
18
|
rescue StandardError => e
|
13
|
-
|
19
|
+
# Aborts the task and prints the error message.
|
20
|
+
# Ensures that any exceptions raised during import are handled gracefully.
|
21
|
+
abort "Import failed: #{e.message}"
|
14
22
|
end
|
15
23
|
|
24
|
+
# Exports translation files from the current Rails project to Lokalise.
|
25
|
+
# Similar to the import task, it leverages the LokaliseManager and uses the GlobalConfig for configuration settings.
|
16
26
|
desc 'Exports translation files from the current Rails project to Lokalise'
|
17
27
|
task :export do
|
18
28
|
exporter = LokaliseManager.exporter({}, LokaliseRails::GlobalConfig)
|
19
29
|
exporter.export!
|
20
30
|
rescue StandardError => e
|
21
|
-
|
31
|
+
# Aborts the task and prints the error message. Provides clear feedback on why the export failed.
|
32
|
+
abort "Export failed: #{e.message}"
|
22
33
|
end
|
23
34
|
end
|
data/lokalise_rails.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.platform = Gem::Platform::RUBY
|
15
15
|
spec.required_ruby_version = '>= 3.0'
|
16
16
|
|
17
|
-
spec.files = Dir['README.md', 'LICENSE',
|
17
|
+
spec.files = Dir['README.md', 'LICENSE.md',
|
18
18
|
'CHANGELOG.md', 'lib/**/*.rb',
|
19
19
|
'lib/**/*.rake',
|
20
20
|
'lokalise_rails.gemspec', '.github/*.md',
|
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: 7.
|
4
|
+
version: 7.1.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: 2024-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lokalise_manager
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
53
53
|
- CHANGELOG.md
|
54
54
|
- Gemfile
|
55
|
-
- LICENSE
|
55
|
+
- LICENSE.md
|
56
56
|
- README.md
|
57
57
|
- Rakefile
|
58
58
|
- lib/generators/lokalise_rails/install_generator.rb
|
@@ -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.5.23
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Lokalise integration for Ruby on Rails
|