internationalize 0.2.1 → 0.2.2

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: 25678f8238179260f1496807a1a68a20d86e09e72e7d7c4097c4b14f41b060ec
4
- data.tar.gz: b713e70a91f521041975b86e6e22be2239ebfddbd3c9867691c55ecf8fbfb380
3
+ metadata.gz: a78574c3b203b7ae3dd699ab2c4c429503922d134f40c990e99dea103e241b12
4
+ data.tar.gz: 2c0ff80e85f73e66e9e04ad572d4b711150ce8853aab53880b326c65be8a551f
5
5
  SHA512:
6
- metadata.gz: 433cc8be47c2df3d5e48abf8eaa6cd0550cbe4ceaaf3fde9700ad08c82be24488eb5b7a52d8ec4b6555880119d8c961a451841ddeed9a52d2a455792ae5eb69d
7
- data.tar.gz: e6656a5c811920e9e4b4b2184ee5b981496296f3588182d3ce2f53e6bcb9328b0051c210830c01d2eb23a9fea5fe3151181a5adb7d08c5222eac08a67c2661ac
6
+ metadata.gz: bbfe57de55d2e7f0d52b02c34eac3c79fa0a71c353dbccf0f65e1c82053e77f66f83ebe40fa69262a123d81bd4c7f78624bc15de6b5001d9227e7032d697633e
7
+ data.tar.gz: d45d9c2a223eb3e740e2da4e17266d4eb0a3590162425f9fb52620224cbe4844dfc987af7394893d42b1a601689f163fff3b05d0531009c296659efd74535162
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.2] - 2024-11-29
11
+
12
+ ### Added
13
+
14
+ - Validation for hyphenated locales (e.g., `zh-TW`) - raises helpful error suggesting underscore format (`zh_TW`)
15
+ - Auto-load `Internationalize::RichText` when ActionText is available (no manual require needed)
16
+
17
+ ## [0.2.1] - 2024-11-29
18
+
19
+ ### Added
20
+
21
+ - ActionText documentation in agent context files
22
+
10
23
  ## [0.2.0] - 2024-11-29
11
24
 
12
25
  ### Added
data/README.md CHANGED
@@ -175,11 +175,9 @@ article.title # => "Hello" (falls back to :en)
175
175
 
176
176
  ### ActionText Support
177
177
 
178
- For rich text with attachments, use `international_rich_text` (requires ActionText):
178
+ For rich text with attachments, use `international_rich_text` (auto-loaded when ActionText is available):
179
179
 
180
180
  ```ruby
181
- require "internationalize/rich_text"
182
-
183
181
  class Article < ApplicationRecord
184
182
  include Internationalize::Model
185
183
  include Internationalize::RichText
data/context/model-api.md CHANGED
@@ -82,11 +82,9 @@ article.title # => "Hello" (falls back to default locale)
82
82
 
83
83
  ## ActionText Support
84
84
 
85
- For rich text with attachments, use `international_rich_text` (requires ActionText):
85
+ For rich text with attachments, use `international_rich_text` (auto-loaded when ActionText is available):
86
86
 
87
87
  ```ruby
88
- require "internationalize/rich_text"
89
-
90
88
  class Article < ApplicationRecord
91
89
  include Internationalize::Model
92
90
  include Internationalize::RichText
@@ -348,6 +348,12 @@ module Internationalize
348
348
 
349
349
  Internationalize.locales.each do |locale|
350
350
  locale_str = locale.to_s
351
+
352
+ if locale_str.include?("-")
353
+ raise ArgumentError, "Locale '#{locale}' contains a hyphen which is invalid for Ruby method names. " \
354
+ "Use underscore format instead: :#{locale_str.tr('-', '_')}"
355
+ end
356
+
351
357
  getter_method = :"#{attr}_#{locale}"
352
358
 
353
359
  # Getter: article.title_en
@@ -26,6 +26,15 @@ module Internationalize
26
26
  # @param name [Symbol] the attribute name
27
27
  #
28
28
  def international_rich_text(name)
29
+ # Validate locales don't contain hyphens (invalid for Ruby method names)
30
+ Internationalize.locales.each do |locale|
31
+ locale_str = locale.to_s
32
+ if locale_str.include?("-")
33
+ raise ArgumentError, "Locale '#{locale}' contains a hyphen which is invalid for Ruby method names. " \
34
+ "Use underscore format instead: :#{locale_str.tr('-', '_')}"
35
+ end
36
+ end
37
+
29
38
  # Generate has_rich_text for each locale
30
39
  Internationalize.locales.each do |locale|
31
40
  rich_text_name = :"#{name}_#{locale}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Internationalize
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -6,6 +6,7 @@ require "active_record"
6
6
  require_relative "internationalize/version"
7
7
  require_relative "internationalize/adapters"
8
8
  require_relative "internationalize/model"
9
+ require_relative "internationalize/rich_text" if defined?(ActionText)
9
10
 
10
11
  module Internationalize
11
12
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: internationalize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen