cmdx-i18n 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c275e1af32039c765b8f70c38dd712807f96db533b312e69f9b0a2269313db13
4
- data.tar.gz: e14e66c415d94e187ebdc5ab6d32b202155757438893cc7652a948ae3e8154ac
3
+ metadata.gz: 330eb1ca9e8ca9a61a2073fa6efcbfe0b9b01f95938e2be371127e9d958e8550
4
+ data.tar.gz: 764bea625ce3edd4e85dc2d7273ef220a0c2d523598f9d9dcd8f35bc9874ed62
5
5
  SHA512:
6
- metadata.gz: b83a4177e7cb5717febec6fa3e1e46de66692933cdde97bd76ce02019ac13131f6ca2ff4a99499e6436e0a6d58dd8a9dc46f5dd4915f4d291942b38d7613c694
7
- data.tar.gz: 464967b66d95a8581d8eda4b79f4e3359c02c000686a02d49cf10e92292a126d49d16d4d14e4c873e009b645cc87de06b2fe4274f57925cdab5acc894d079f62
6
+ metadata.gz: 87f5e559e7bb2a45696596cfbb26b121db382dbc50789adb81839ae3aa7cebc067672908061a6c837f579a10cf26a6fadd35b99c7a35ed5202203c8e3e59be91
7
+ data.tar.gz: 725ae012e65190d74c691dfca4ba2668e3cea89590fd5950b4940bbb609324cbe5a1b7261fbc9831c030159e1702e922978b05f70554a5fcab563bcc07cfb27c
@@ -10,12 +10,13 @@ Follow the official Ruby gem guides for best practices.
10
10
  Reference the guides outlined in https://guides.rubygems.org
11
11
 
12
12
  ## Project Context
13
- CMDx provides a framework for designing and executing complex
14
- business logic within service/command objects.
13
+ CMDx::I18n is a collection of localized translations for the CMDx framework.
14
+ Reference the CMDx documentation in https://github.com/drexed/cmdx/blob/main/LLM.md
15
15
 
16
16
  ## Technology Stack
17
17
  - Ruby 3.4+
18
18
  - RSpec 3.1+
19
+ - CMDx 1.6+
19
20
 
20
21
  ## Code Style and Structure
21
22
  - Write concise, idiomatic Ruby code with accurate examples
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [TODO]
8
8
 
9
+ ## [0.2.0] - 2025-08-24
10
+
11
+ ### Added
12
+ - Generator to copy locales to `config/locales` in a Rails app
13
+
14
+ ### Changes
15
+ - Fix railtie requirement issue
16
+
9
17
  ## [0.1.1] - 2025-08-23
10
18
 
11
19
  ### Changes
data/README.md CHANGED
@@ -30,7 +30,16 @@ Or install it yourself as:
30
30
 
31
31
  ## Configuration
32
32
 
33
- By default, `cmdx-i18n` locales are automatically loaded and are managed through the `I18n.available_locales` option.
33
+ If the `I18n` gem is installed, `cmdx-i18n` locales are automatically loaded and are managed through the `I18n.available_locales` option.
34
+
35
+ Execute the following command to copy any locale to the applications `config/locales` directory:
36
+
37
+ ```bash
38
+ rails generate cmdx:i18n:locale [LOCALE]
39
+
40
+ # Eg: generate french locale
41
+ rails generate cmdx:i18n:locale fr
42
+ ```
34
43
 
35
44
  ## Locales
36
45
 
@@ -3,7 +3,7 @@
3
3
  module CMDx
4
4
  module I18n
5
5
 
6
- VERSION = "0.1.1"
6
+ VERSION = "0.2.0"
7
7
 
8
8
  end
9
9
  end
data/lib/cmdx/i18n.rb CHANGED
@@ -21,6 +21,9 @@ loader.inflector.inflect("cmdx" => "CMDx")
21
21
  loader.ignore("#{__dir__}/locales")
22
22
  loader.setup
23
23
 
24
+ # Conditionally load Rails components if Rails is available
25
+ require_relative "generators/cmdx/i18n/copy_generator" if defined?(Rails::Generators)
26
+
24
27
  # Load the Railtie last after everything else is required so we don't
25
28
  # need to load any CMDx::I18n components when we use this Railtie.
26
- require_relative "cmdx/i18n/railtie" if defined?(Rails::Railtie)
29
+ require_relative "i18n/railtie" if defined?(Rails::Railtie)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cmdx
4
+ module I18n
5
+ # Generates CMDx locale files for Rails applications
6
+ #
7
+ # Rails generator that copies CMDx::I18n locale files into the application's
8
+ # config/locales directory. This allows applications to customize and extend
9
+ # the default CMDx::I18n locale files.
10
+ class LocaleGenerator < Rails::Generators::Base
11
+
12
+ source_root File.expand_path("../../../locales", __dir__)
13
+
14
+ desc "Copies CMDx::I18n locale files into app"
15
+
16
+ argument :locale, type: :string, default: "en", banner: "Locale to copy"
17
+
18
+ # Copies the locale template to the Rails application
19
+ #
20
+ # Copies the specified locale file from the gem's locales directory to the
21
+ # application's config/locales directory. If the locale file doesn't exist
22
+ # in the gem, the generator will fail gracefully.
23
+ #
24
+ # @return [void]
25
+ #
26
+ # @example
27
+ # # Copy default (English) locale file
28
+ # rails generate cmdx:i18n:locale
29
+ # # => Creates config/locales/en.yml
30
+ #
31
+ # # Copy Spanish locale file
32
+ # rails generate cmdx:i18n:locale es
33
+ # # => Creates config/locales/es.yml
34
+ #
35
+ def copy_locale_files
36
+ copy_file("#{locale}.yml", "config/locales/#{locale}.yml")
37
+ end
38
+
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdx-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
@@ -173,6 +173,7 @@ files:
173
173
  - lib/cmdx/i18n.rb
174
174
  - lib/cmdx/i18n/railtie.rb
175
175
  - lib/cmdx/i18n/version.rb
176
+ - lib/generators/cmdx/i18n/locale_generator.rb
176
177
  - lib/locales/af.yml
177
178
  - lib/locales/ar.yml
178
179
  - lib/locales/az.yml