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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5acb05fa54c4ff1e243de21c053b5154e307709e1bd569fa3dbb363e147e1443
4
- data.tar.gz: 84714f2c2250a8d81a5671cc6bfaa6735151151bf5c5f6b38ae7f6e13579a3e3
3
+ metadata.gz: e0e0ceba2e43e8a631a04292440c1513064b43555007dfb021dab3e913b94998
4
+ data.tar.gz: '091cc4d46c83da828e0b793975dd7c9dc03e10e0816b5505f4e66b6e0dac3b6f'
5
5
  SHA512:
6
- metadata.gz: a457a3fcf4abe0783029f6458a4139b1d24c073b7480f59170f41eaf52fe9989735ffdb4f67ee0a829f29dfa65ca296debb8a32029079816dbfc9621fc8ef662
7
- data.tar.gz: eb21427d268d3ce61d7c87184f07bc2347174d4a9d54f556b64b87a284309b1d6a91324ade166d0abb6fa8db425e788e0add91b29cee3dc05e1f8d4aaf791c33
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
@@ -6,7 +6,7 @@ gemspec
6
6
 
7
7
  group :test do
8
8
  gem 'dotenv', '~> 3.0'
9
- gem 'rails', '8.0.0'
9
+ gem 'rails', '~> 8.0'
10
10
  gem 'rake', '~> 13.0'
11
11
  gem 'rspec', '~> 3.6'
12
12
  gem 'rubocop', '~> 1.0'
@@ -4,21 +4,15 @@ require 'rails/generators'
4
4
 
5
5
  module LokaliseRails
6
6
  module Generators
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.
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
- # 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.'
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
- # 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
+ # 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
- # 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.
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
- # 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.
8
+ # Returns the path to the directory where translation files are stored.
11
9
  #
12
- # @return [String] the path to the locales directory
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
- # 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.
4
+ # Extends Rails via Railtie to integrate LokaliseRails functionalities.
7
5
  #
8
- # It leverages Rails' Railtie architecture to ensure the Rake
9
- # tasks are loaded when the application boots up and Rake is invoked.
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
- # 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.
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
@@ -3,31 +3,30 @@
3
3
  require 'pathname'
4
4
 
5
5
  module LokaliseRails
6
- # Util methods
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
- # @return [Pathname] A Pathname object pointing to the root directory of the project.
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
- # 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.
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] the path to the root directory if Rails is defined, or nil if it cannot be determined.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LokaliseRails
4
- VERSION = '8.0.0'
4
+ VERSION = '8.0.1'
5
5
  end
@@ -3,19 +3,22 @@
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
+ # Configure Zeitwerk for managing gem autoloading.
8
7
  loader = Zeitwerk::Loader.for_gem
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
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 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.
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
- # Require the Railtie only if Rails is defined to integrate with Rails without manual configuration.
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 the configuration settings from the lokalise_rails configuration file within the Rails project.
6
- require "#{LokaliseRails::Utils.root}/config/lokalise_rails"
5
+ require "#{LokaliseRails::Utils.root}/config/lokalise_rails" # Loads configuration settings for LokaliseRails
7
6
 
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
+ # Rake tasks for syncing translation files between a Rails project and Lokalise.
10
8
  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.
14
- desc 'Imports translation files from Lokalise to the current Rails project'
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 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.
26
- desc 'Exports translation files from the current Rails project to Lokalise'
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.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: 2024-11-29 00:00:00.000000000 Z
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.5.23
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: []