lokalise_rails 8.0.0 → 8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/lib/generators/lokalise_rails/install_generator.rb +4 -10
- data/lib/generators/templates/lokalise_rails_config.rb +3 -0
- data/lib/lokalise_rails/global_config.rb +6 -7
- data/lib/lokalise_rails/railtie.rb +7 -9
- data/lib/lokalise_rails/utils.rb +11 -12
- data/lib/lokalise_rails/version.rb +1 -1
- data/lib/lokalise_rails.rb +12 -9
- data/lib/tasks/lokalise_rails_tasks.rake +16 -14
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0e0ceba2e43e8a631a04292440c1513064b43555007dfb021dab3e913b94998
|
4
|
+
data.tar.gz: '091cc4d46c83da828e0b793975dd7c9dc03e10e0816b5505f4e66b6e0dac3b6f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '095af676b0d83e33331bfaf988cc60f84210247a059ad764ca55d1bef7643cc2ad7f14c9f01b50317d6765701011098c47943aed75a7d693b151a388129b25a7'
|
7
|
+
data.tar.gz: 0423e6defc5d17c908f7a566c0d10a1fc3137110aee6b5604e5ad732fc6cbf2611909fd65ada8bb97cbad895529543301b4e3fba89170f16feaacdd991852870
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 8.0.1 (19-Feb-2025)
|
4
|
+
|
5
|
+
* Minor code tweaks, use latest `lokalise_manager` that now enables asynchronous imports
|
6
|
+
|
3
7
|
## 8.0.0 (29-Nov-2024)
|
4
8
|
|
5
9
|
* **Breaking change**: rename the `timeouts` config option to `additional_client_opts`. It has the same usage but now enables you to set both client timeouts and override the API host to send requests to.
|
data/Gemfile
CHANGED
@@ -4,21 +4,15 @@ require 'rails/generators'
|
|
4
4
|
|
5
5
|
module LokaliseRails
|
6
6
|
module Generators
|
7
|
-
#
|
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.
|
7
|
+
# Installs the LokaliseRails configuration file in a Rails application.
|
10
8
|
class InstallGenerator < Rails::Generators::Base
|
11
|
-
# Sets the directory containing the template files relative to this file's location.
|
12
9
|
source_root File.expand_path('../templates', __dir__)
|
13
10
|
|
14
|
-
#
|
15
|
-
desc 'Creates a
|
11
|
+
# Adds a configuration file for LokaliseRails to the Rails application.
|
12
|
+
desc 'Creates a config/lokalise_rails.rb file for LokaliseRails.'
|
16
13
|
|
17
|
-
#
|
18
|
-
# from the gem to the Rails application's config directory. This is where users can customize
|
19
|
-
# their Lokalise settings.
|
14
|
+
# Copies the configuration template to the application's config directory.
|
20
15
|
def copy_config
|
21
|
-
# Copies the configuration template to the Rails application's config directory.
|
22
16
|
template 'lokalise_rails_config.rb', "#{Rails.root}/config/lokalise_rails.rb"
|
23
17
|
end
|
24
18
|
end
|
@@ -34,6 +34,9 @@ if defined?(LokaliseRails::GlobalConfig)
|
|
34
34
|
# Safe mode for imports is disabled by default:
|
35
35
|
# c.import_safe_mode = false
|
36
36
|
|
37
|
+
# Run imports asynchronously
|
38
|
+
# c.import_async = false
|
39
|
+
|
37
40
|
# Additional export options (only filename, contents, and lang_iso params are provided by default)
|
38
41
|
# c.export_opts = {}
|
39
42
|
|
@@ -1,17 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module LokaliseRails
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# within a Ruby on Rails application, particularly in managing locale paths.
|
4
|
+
# Extends `LokaliseManager::GlobalConfig` to provide a global configuration
|
5
|
+
# specific to the LokaliseRails gem in a Rails application.
|
7
6
|
class GlobalConfig < LokaliseManager::GlobalConfig
|
8
7
|
class << self
|
9
|
-
#
|
10
|
-
# it defaults to the `config/locales` directory within the root of the application using this gem.
|
8
|
+
# Returns the path to the directory where translation files are stored.
|
11
9
|
#
|
12
|
-
#
|
10
|
+
# Defaults to `config/locales` under the Rails application root if not explicitly set.
|
11
|
+
#
|
12
|
+
# @return [String] Absolute path to the locales directory.
|
13
13
|
def locales_path
|
14
|
-
# If @locales_path is not set, it defaults to a path under the application's root directory.
|
15
14
|
@locales_path || "#{LokaliseRails::Utils.root}/config/locales"
|
16
15
|
end
|
17
16
|
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module LokaliseRails
|
4
|
-
#
|
5
|
-
# a gem. This Railtie is specifically used to add custom Rake tasks from the
|
6
|
-
# LokaliseRails gem into the Rails application.
|
4
|
+
# Extends Rails via Railtie to integrate LokaliseRails functionalities.
|
7
5
|
#
|
8
|
-
#
|
9
|
-
#
|
6
|
+
# This Railtie ensures that custom Rake tasks from the LokaliseRails gem
|
7
|
+
# are automatically available within a Rails application.
|
10
8
|
class Railtie < Rails::Railtie
|
11
|
-
#
|
12
|
-
#
|
9
|
+
# Registers custom Rake tasks for LokaliseRails.
|
10
|
+
#
|
11
|
+
# This ensures that the tasks are loaded when the Rails application boots
|
12
|
+
# and Rake is invoked.
|
13
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.
|
16
14
|
load 'tasks/lokalise_rails_tasks.rake'
|
17
15
|
end
|
18
16
|
end
|
data/lib/lokalise_rails/utils.rb
CHANGED
@@ -3,31 +3,30 @@
|
|
3
3
|
require 'pathname'
|
4
4
|
|
5
5
|
module LokaliseRails
|
6
|
-
#
|
6
|
+
# Utility methods for LokaliseRails
|
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
10
|
#
|
13
|
-
#
|
11
|
+
# If Rails is available, it returns `Rails.root`. Otherwise, it defaults
|
12
|
+
# to the current working directory.
|
13
|
+
#
|
14
|
+
# @return [Pathname] Pathname object pointing to the project root.
|
14
15
|
def root
|
15
|
-
# Uses Pathname to create a robust path object from the rails_root or the current working directory.
|
16
16
|
Pathname.new(rails_root || Dir.getwd)
|
17
17
|
end
|
18
18
|
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
19
|
+
# Determines the root directory of a Rails project.
|
20
|
+
#
|
21
|
+
# - Uses `Rails.root` if available.
|
22
|
+
# - Falls back to `RAILS_ROOT` for older Rails versions.
|
23
|
+
# - Returns `nil` if Rails is not present.
|
22
24
|
#
|
23
|
-
# @return [String, nil]
|
25
|
+
# @return [String, nil] Path to the root directory or `nil` if not found.
|
24
26
|
def rails_root
|
25
|
-
# First, check if Rails.root is defined and return its path if available.
|
26
27
|
return ::Rails.root.to_s if defined?(::Rails.root) && ::Rails.root
|
27
|
-
# Fallback to the RAILS_ROOT constant from older Rails versions.
|
28
28
|
return RAILS_ROOT.to_s if defined?(RAILS_ROOT)
|
29
29
|
|
30
|
-
# Returns nil if none of the above are defined, indicating Rails is not present.
|
31
30
|
nil
|
32
31
|
end
|
33
32
|
end
|
data/lib/lokalise_rails.rb
CHANGED
@@ -3,19 +3,22 @@
|
|
3
3
|
require 'zeitwerk'
|
4
4
|
require 'lokalise_manager'
|
5
5
|
|
6
|
-
# Configure Zeitwerk
|
7
|
-
# that should not be autoloaded, such as Rails-specific files or templates which are not part of the main load path.
|
6
|
+
# Configure Zeitwerk for managing gem autoloading.
|
8
7
|
loader = Zeitwerk::Loader.for_gem
|
9
|
-
|
10
|
-
|
11
|
-
loader.ignore "#{__dir__}/
|
8
|
+
|
9
|
+
# Ignore files that should not be autoloaded.
|
10
|
+
loader.ignore "#{__dir__}/lokalise_rails/railtie.rb" # Exclude Railtie when not in a Rails app
|
11
|
+
loader.ignore "#{__dir__}/generators/templates/lokalise_rails_config.rb" # Ignore generator templates
|
12
|
+
loader.ignore "#{__dir__}/generators/lokalise_rails/install_generator.rb" # Ignore installation generator
|
13
|
+
|
12
14
|
loader.setup
|
13
15
|
|
14
|
-
# Main module for
|
15
|
-
#
|
16
|
-
#
|
16
|
+
# Main module for LokaliseRails.
|
17
|
+
#
|
18
|
+
# Serves as the namespace for all components of the LokaliseRails gem,
|
19
|
+
# providing tools for managing translations in Ruby on Rails applications.
|
17
20
|
module LokaliseRails
|
18
21
|
end
|
19
22
|
|
20
|
-
#
|
23
|
+
# Load Railtie if running within a Rails application.
|
21
24
|
require_relative 'lokalise_rails/railtie' if defined?(Rails)
|
@@ -2,33 +2,35 @@
|
|
2
2
|
|
3
3
|
require 'rake'
|
4
4
|
require 'lokalise_rails'
|
5
|
-
# Loads
|
6
|
-
require "#{LokaliseRails::Utils.root}/config/lokalise_rails"
|
5
|
+
require "#{LokaliseRails::Utils.root}/config/lokalise_rails" # Loads configuration settings for LokaliseRails
|
7
6
|
|
8
|
-
#
|
9
|
-
# These tasks facilitate the synchronization of localization files between the Rails project and the Lokalise platform.
|
7
|
+
# Rake tasks for syncing translation files between a Rails project and Lokalise.
|
10
8
|
namespace :lokalise_rails do
|
11
|
-
# Imports
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
9
|
+
# Imports translations from Lokalise into the current Rails project.
|
10
|
+
#
|
11
|
+
# Uses LokaliseManager to fetch translations based on the configuration
|
12
|
+
# defined in `LokaliseRails::GlobalConfig`.
|
13
|
+
#
|
14
|
+
# @raise [StandardError] Prints an error message and aborts if the import fails.
|
15
|
+
desc 'Import translations from Lokalise into the Rails project'
|
15
16
|
task :import do
|
16
17
|
importer = LokaliseManager.importer({}, LokaliseRails::GlobalConfig)
|
17
18
|
importer.import!
|
18
19
|
rescue StandardError => e
|
19
|
-
# Aborts the task and prints the error message.
|
20
|
-
# Ensures that any exceptions raised during import are handled gracefully.
|
21
20
|
abort "Import failed: #{e.message}"
|
22
21
|
end
|
23
22
|
|
24
|
-
# Exports
|
25
|
-
#
|
26
|
-
|
23
|
+
# Exports translations from the Rails project to Lokalise.
|
24
|
+
#
|
25
|
+
# Uses LokaliseManager to push localization files based on the configuration
|
26
|
+
# in `LokaliseRails::GlobalConfig`.
|
27
|
+
#
|
28
|
+
# @raise [StandardError] Prints an error message and aborts if the export fails.
|
29
|
+
desc 'Export translations from the Rails project to Lokalise'
|
27
30
|
task :export do
|
28
31
|
exporter = LokaliseManager.exporter({}, LokaliseRails::GlobalConfig)
|
29
32
|
exporter.export!
|
30
33
|
rescue StandardError => e
|
31
|
-
# Aborts the task and prints the error message. Provides clear feedback on why the export failed.
|
32
34
|
abort "Export failed: #{e.message}"
|
33
35
|
end
|
34
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lokalise_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Krukowski
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: lokalise_manager
|
@@ -69,7 +68,6 @@ licenses:
|
|
69
68
|
- MIT
|
70
69
|
metadata:
|
71
70
|
rubygems_mfa_required: 'true'
|
72
|
-
post_install_message:
|
73
71
|
rdoc_options: []
|
74
72
|
require_paths:
|
75
73
|
- lib
|
@@ -84,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
82
|
- !ruby/object:Gem::Version
|
85
83
|
version: '0'
|
86
84
|
requirements: []
|
87
|
-
rubygems_version: 3.
|
88
|
-
signing_key:
|
85
|
+
rubygems_version: 3.6.3
|
89
86
|
specification_version: 4
|
90
87
|
summary: Lokalise integration for Ruby on Rails
|
91
88
|
test_files: []
|