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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +1 -3
- data/context/model-api.md +1 -3
- data/lib/internationalize/model.rb +6 -0
- data/lib/internationalize/rich_text.rb +9 -0
- data/lib/internationalize/version.rb +1 -1
- data/lib/internationalize.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a78574c3b203b7ae3dd699ab2c4c429503922d134f40c990e99dea103e241b12
|
|
4
|
+
data.tar.gz: 2c0ff80e85f73e66e9e04ad572d4b711150ce8853aab53880b326c65be8a551f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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` (
|
|
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` (
|
|
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}"
|
data/lib/internationalize.rb
CHANGED
|
@@ -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
|