copy_tuner_client 1.2.4 → 1.4.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 +4 -4
- data/.github/dependabot.yml +18 -0
- data/.github/workflows/rspec.yml +5 -7
- data/.rubocop.yml +5 -0
- data/.ruby-version +1 -1
- data/README.md +10 -0
- data/copy_tuner_client.gemspec +2 -2
- data/gemfiles/{7.1.gemfile → 8.1.gemfile} +1 -1
- data/lib/copy_tuner_client/cache.rb +10 -2
- data/lib/copy_tuner_client/configuration.rb +21 -2
- data/lib/copy_tuner_client/dotted_hash.rb +2 -20
- data/lib/copy_tuner_client/version.rb +1 -1
- data/skills/copy-tuner/SKILL.md +27 -2
- data/spec/copy_tuner_client/cache_spec.rb +12 -0
- data/spec/copy_tuner_client/configuration_spec.rb +34 -0
- data/spec/copy_tuner_client/dotted_hash_spec.rb +7 -60
- data/spec/copy_tuner_client/i18n_backend_spec.rb +19 -1
- metadata +7 -7
- data/gemfiles/7.2.gemfile +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10935db209e8b915ac8101dfa324bf5a40da15978124e8300746c0be13407862
|
|
4
|
+
data.tar.gz: faa6e39b7149540c342ec9fcefce9f0c47425614c4f361fa8b8b597ff932d69c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83ea46e846b20d110366e5d8d7ecb5c415a082a700e45682931e2303a7516e50c6d1b0fcdce5ea7deada42dd3ef7e6f9df07ff4084c3b211db0cb42d1de1d422
|
|
7
|
+
data.tar.gz: 194dc1188ab23b9776b030ec08c453444513a8f55d6b674d4b06b6953c652409951690bbfad569b1e2524a02c7951f5faeb55a4fe0d1eafbfd77c61d72cb2a45
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "github-actions"
|
|
4
|
+
directory: "/"
|
|
5
|
+
cooldown:
|
|
6
|
+
default-days: 5
|
|
7
|
+
ignore:
|
|
8
|
+
- dependency-name: "ruby/setup-ruby"
|
|
9
|
+
update-types:
|
|
10
|
+
- "version-update:semver-patch"
|
|
11
|
+
- "version-update:semver-minor"
|
|
12
|
+
- dependency-name: "actions/checkout"
|
|
13
|
+
update-types:
|
|
14
|
+
- "version-update:semver-patch"
|
|
15
|
+
- "version-update:semver-minor"
|
|
16
|
+
schedule:
|
|
17
|
+
# Check for updates to GitHub Actions every weekday
|
|
18
|
+
interval: "weekly"
|
data/.github/workflows/rspec.yml
CHANGED
|
@@ -22,14 +22,12 @@ jobs:
|
|
|
22
22
|
strategy:
|
|
23
23
|
fail-fast: false
|
|
24
24
|
matrix:
|
|
25
|
-
ruby: ["3.
|
|
26
|
-
gemfile: ["
|
|
25
|
+
ruby: ["3.3", "3.4", "4.0"]
|
|
26
|
+
gemfile: ["8.0", "8.1", "main"]
|
|
27
27
|
exclude:
|
|
28
|
-
- ruby: "3.
|
|
29
|
-
gemfile: "8.0"
|
|
30
|
-
- ruby: "3.1"
|
|
28
|
+
- ruby: "3.3"
|
|
31
29
|
gemfile: "main"
|
|
32
|
-
- ruby: "3.
|
|
30
|
+
- ruby: "3.4"
|
|
33
31
|
gemfile: "main"
|
|
34
32
|
steps:
|
|
35
33
|
- name: Install packages
|
|
@@ -37,7 +35,7 @@ jobs:
|
|
|
37
35
|
sudo apt update -y
|
|
38
36
|
sudo apt install -y libsqlite3-dev
|
|
39
37
|
|
|
40
|
-
- uses: actions/checkout@
|
|
38
|
+
- uses: actions/checkout@v6
|
|
41
39
|
|
|
42
40
|
- name: Set up Ruby
|
|
43
41
|
uses: ruby/setup-ruby@v1
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.5
|
data/README.md
CHANGED
|
@@ -53,6 +53,16 @@ CopyTuner で一元管理している翻訳を、`views.*` のような単位で
|
|
|
53
53
|
- ローカル YAML にも存在しない場合は未訳(`nil` / MissingTranslation)となります。CopyTuner へのフォールバックや新規キーのアップロードは行いません。これにより移行漏れを未訳として検知できます。
|
|
54
54
|
- マッチしたキーには、ビューヘルパー(`t` / `translate`)および SimpleForm のラベルで CopyRay オーバーレイマーカー(`<!--COPYRAY key-->`)を注入しません。これらのキーは CopyTuner 上で編集できないため、編集可能だと誤認させないためです。
|
|
55
55
|
|
|
56
|
+
### Rails 標準の数値フォーマットキーは常にローカル優先(組み込み)
|
|
57
|
+
|
|
58
|
+
`local_first_key_regexp` の設定有無にかかわらず、以下の Rails 標準キーは**常にローカル YAML 優先**になります(CopyTuner をバイパス)。
|
|
59
|
+
|
|
60
|
+
- `number.format` / `number.currency.format` / `number.percentage.format` / `number.human.format`(およびその配下)
|
|
61
|
+
|
|
62
|
+
これらは `precision`(整数)や `significant` / `strip_insignificant_zeros`(真偽値)といった非文字列値を含みます。CopyTuner は文字列値しか保持できないため、経由するとこれらが欠落し、`number_to_currency` などが意図しない表示(小数桁数や記号の崩れ)になります。これを防ぐため gem 側で固定的にローカル優先にしています。
|
|
63
|
+
|
|
64
|
+
アプリ独自の `number.*` キー(例 `number.gift_amount`)は対象外で、従来どおり CopyTuner で管理できます。
|
|
65
|
+
|
|
56
66
|
`exclude_key_regexp` との違い:
|
|
57
67
|
|
|
58
68
|
| オプション | 対象 | 作用するタイミング |
|
data/copy_tuner_client.gemspec
CHANGED
|
@@ -2,11 +2,11 @@ $LOAD_PATH.push File.expand_path('lib', __dir__)
|
|
|
2
2
|
require 'copy_tuner_client/version'
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
|
-
s.required_ruby_version = '>= 3.
|
|
5
|
+
s.required_ruby_version = '>= 3.3.0'
|
|
6
6
|
s.add_dependency 'i18n', '>= 0.5.0'
|
|
7
7
|
s.add_dependency 'json'
|
|
8
8
|
s.add_dependency 'nokogiri'
|
|
9
|
-
s.add_development_dependency 'rails', '~>
|
|
9
|
+
s.add_development_dependency 'rails', '~> 8.0'
|
|
10
10
|
s.add_development_dependency 'rake'
|
|
11
11
|
s.add_development_dependency 'rspec'
|
|
12
12
|
s.add_development_dependency 'sham_rack'
|
|
@@ -56,8 +56,8 @@ module CopyTunerClient
|
|
|
56
56
|
|
|
57
57
|
# NOTE: config/locales以下のファイルに除外キーが残っていた場合の対応
|
|
58
58
|
key_without_locale = key.split('.')[1..].join('.')
|
|
59
|
-
# NOTE:
|
|
60
|
-
return if
|
|
59
|
+
# NOTE: local_first キー(組み込みの Rails number.*.format + ユーザー設定)は copy_tuner と完全分離するためアップロードしない
|
|
60
|
+
return if local_first_key?(key_without_locale)
|
|
61
61
|
|
|
62
62
|
if @ignored_keys.include?(key_without_locale)
|
|
63
63
|
@ignored_key_handler.call(IgnoredKey.new("Ignored key: #{key_without_locale}"))
|
|
@@ -165,6 +165,14 @@ module CopyTunerClient
|
|
|
165
165
|
|
|
166
166
|
attr_reader :client, :logger
|
|
167
167
|
|
|
168
|
+
# NOTE: 組み込みの Rails number.*.format キーは lookup 経路(Configuration#local_first_key?)と
|
|
169
|
+
# アップロード抑止経路(ここ)で同じ判定を共有する。判定本体は Configuration に集約し付け忘れの穴を防ぐ。
|
|
170
|
+
def local_first_key?(key_without_locale)
|
|
171
|
+
return true if Configuration.builtin_local_first_key?(key_without_locale)
|
|
172
|
+
|
|
173
|
+
@local_first_key_regexp && key_without_locale.match?(@local_first_key_regexp)
|
|
174
|
+
end
|
|
175
|
+
|
|
168
176
|
def with_queued_changes
|
|
169
177
|
changes_to_push = nil
|
|
170
178
|
|
|
@@ -21,6 +21,21 @@ module CopyTunerClient
|
|
|
21
21
|
ca_file exclude_key_regexp local_first_key_regexp s3_host locales ignored_keys ignored_key_handler
|
|
22
22
|
download_cache_dir].freeze
|
|
23
23
|
|
|
24
|
+
# NOTE: Rails 標準ロケールで非文字列値(precision: Integer, significant: Boolean,
|
|
25
|
+
# strip_insignificant_zeros: Boolean)を含むのは number.*.format 配下のみ。store_item が文字列しか
|
|
26
|
+
# 保持できず lookup_in_tree_cache が tree cache をローカル YAML より優先するため、CopyTuner 経由だと
|
|
27
|
+
# precision 等が欠落し number_to_currency 等が壊れる。これらの Rails 標準 format キーだけを常にローカル
|
|
28
|
+
# 優先にする(number 全体ではなく、アプリ独自の number.* キーは対象外)。末尾 (\.|\z) で
|
|
29
|
+
# number.currency.format(ハッシュ lookup)と number.currency.format.precision(葉キー)の両方に対応する。
|
|
30
|
+
BUILTIN_LOCAL_FIRST_KEY_REGEXP =
|
|
31
|
+
/\Anumber\.(format|currency\.format|percentage\.format|human\.format)(\.|\z)/
|
|
32
|
+
|
|
33
|
+
# lookup 経路(Configuration#local_first_key?)と upload 抑止経路(Cache#[]=)で同じ組み込み判定を
|
|
34
|
+
# 共有する。判定を 1 箇所に集約することで number 以外を足す際の同期漏れを防ぐ。
|
|
35
|
+
def self.builtin_local_first_key?(key_without_locale)
|
|
36
|
+
key_without_locale.to_s.match?(BUILTIN_LOCAL_FIRST_KEY_REGEXP)
|
|
37
|
+
end
|
|
38
|
+
|
|
24
39
|
# @return [String] The API key for your project, found on the project edit form.
|
|
25
40
|
attr_reader :api_key
|
|
26
41
|
|
|
@@ -363,9 +378,13 @@ module CopyTunerClient
|
|
|
363
378
|
# @param key_without_locale [String, Symbol, nil] locale prefix を除いたキー(例: "views.foo.bar")
|
|
364
379
|
# @return [Boolean]
|
|
365
380
|
def local_first_key?(key_without_locale)
|
|
366
|
-
return false if
|
|
381
|
+
return false if key_without_locale.nil?
|
|
382
|
+
|
|
383
|
+
normalized = key_without_locale.to_s
|
|
384
|
+
return true if self.class.builtin_local_first_key?(normalized)
|
|
385
|
+
return false if local_first_key_regexp.nil?
|
|
367
386
|
|
|
368
|
-
|
|
387
|
+
normalized.match?(local_first_key_regexp)
|
|
369
388
|
end
|
|
370
389
|
|
|
371
390
|
private
|
|
@@ -3,9 +3,7 @@ module CopyTunerClient
|
|
|
3
3
|
def to_h(dotted_hash)
|
|
4
4
|
hash = {}
|
|
5
5
|
dotted_hash.to_h.transform_keys(&:to_s).sort.each do |key, value|
|
|
6
|
-
|
|
7
|
-
converted_value = convert_value_type(key, value)
|
|
8
|
-
_hash = key.split('.').reverse.inject(converted_value) { |memo, _key| { _key => memo } }
|
|
6
|
+
_hash = key.split('.').reverse.inject(value) { |memo, _key| { _key => memo } }
|
|
9
7
|
hash.deep_merge!(_hash)
|
|
10
8
|
end
|
|
11
9
|
hash
|
|
@@ -29,22 +27,6 @@ module CopyTunerClient
|
|
|
29
27
|
results
|
|
30
28
|
end
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def convert_value_type(key, value)
|
|
35
|
-
return value unless value.is_a?(String)
|
|
36
|
-
|
|
37
|
-
# Rails i18n標準で数値型として扱われるキー
|
|
38
|
-
if key.end_with?('.precision')
|
|
39
|
-
value.to_i
|
|
40
|
-
# Rails i18n標準で真偽値として扱われるキー
|
|
41
|
-
elsif key.end_with?('.significant', '.strip_insignificant_zeros')
|
|
42
|
-
value == 'true'
|
|
43
|
-
else
|
|
44
|
-
value
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
module_function :to_h, :conflict_keys, :convert_value_type # rubocop:disable Style/AccessModifierDeclarations
|
|
30
|
+
module_function :to_h, :conflict_keys # rubocop:disable Style/AccessModifierDeclarations
|
|
49
31
|
end
|
|
50
32
|
end
|
data/skills/copy-tuner/SKILL.md
CHANGED
|
@@ -18,7 +18,18 @@ license: MIT
|
|
|
18
18
|
| 判別 | 管理場所 | 操作 |
|
|
19
19
|
|---|---|---|
|
|
20
20
|
| マッチする | config/locales(copy_tuner と完全分離) | `config/locales/*.yml` を Read / Edit |
|
|
21
|
-
| マッチしない・未設定 | copy_tuner | MCP
|
|
21
|
+
| マッチしない・未設定 | copy_tuner | **MCP ツール経由でのみ探す**(下記) |
|
|
22
|
+
|
|
23
|
+
**copy_tuner 管理のキーは必ず MCP ツール経由で探すこと。** ローカルの `.yml` を grep して見つけたつもりになってはならない。
|
|
24
|
+
|
|
25
|
+
**例外(gem 組み込み・設定不要で常に config/locales 管理):** Rails 標準の `number.format` /
|
|
26
|
+
`number.currency.format` / `number.percentage.format` / `number.human.format`(およびその配下)。
|
|
27
|
+
`precision` 等の非文字列値を含み copy_tuner では正しく扱えないため、gem が常にバイパスする。
|
|
28
|
+
これらは `config/locales/*.yml` を見る・編集すること(アプリ独自の `number.gift_amount` 等は対象外で通常どおり copy_tuner)。
|
|
29
|
+
|
|
30
|
+
**`config/locales` 以外の export 済み yml は参照禁止:**
|
|
31
|
+
環境によっては copy_tuner から export したキャッシュ用の `.yml`(`config/locales` 配下以外、例: アプリ直下や `tmp/`、`db/` などに置かれた export ファイル)が存在することがある。
|
|
32
|
+
これらは古いスナップショットであり権威ある情報源ではない。**読んで判断材料にしてはならない。** copy_tuner 管理キーは常に MCP ツールで最新を確認する。
|
|
22
33
|
|
|
23
34
|
**config/locales 管理キーの落とし穴:**
|
|
24
35
|
- copy_tuner には存在しないので、MCP ツールで探しても見つからない。`config/locales` を見ること。
|
|
@@ -33,7 +44,8 @@ license: MIT
|
|
|
33
44
|
| キー名(一部)から翻訳を調べる | `search_key`(引数は英語キーワード) |
|
|
34
45
|
| 画面テキストからキーを逆引き | `search_translations` |
|
|
35
46
|
| 新しいキーを登録する | `create_i18n_key` |
|
|
36
|
-
|
|
|
47
|
+
| 既存キーのドラフト訳を更新する | `update_i18n_key` |
|
|
48
|
+
| 既存キーの翻訳を更新する(ブラウザ) | `get_edit_url` |
|
|
37
49
|
| 使用中ロケールを確認 | `get_locales` |
|
|
38
50
|
|
|
39
51
|
## 新規キー登録
|
|
@@ -41,6 +53,19 @@ license: MIT
|
|
|
41
53
|
1. `search_key` で関連キーを検索し、既存の命名パターンに合わせる(例: `search_key("move_out")`)。
|
|
42
54
|
2. ja は必須。他は `get_locales` で確認し、存在するロケール分を登録する。
|
|
43
55
|
|
|
56
|
+
## 既存キーの訳を更新する
|
|
57
|
+
|
|
58
|
+
`update_i18n_key` を使う。`key` と `translations`(ロケール・値のペア配列)は両方必須。
|
|
59
|
+
|
|
60
|
+
**制約**: ドラフト状態または未発行のキーのみ更新可能。発行済み(published)かどうかを事前に知る手段はなく、API にリクエストしてエラーが返るかどうかで初めてわかる。
|
|
61
|
+
|
|
62
|
+
**published キーへの対応方針**: 値を直接書き換えるのはリスクが高いため、原則として以下の手順を推奨する:
|
|
63
|
+
1. 新しいキーにバージョン番号を付けて登録する(例: `views.foo_v2`)→ **新規キー登録の手順に従う**
|
|
64
|
+
2. コード側の参照を新キーに差し替える
|
|
65
|
+
3. 古いキーを `config/initializers/copy_tuner.rb` の `ignored_keys` に追加する
|
|
66
|
+
|
|
67
|
+
どうしても既存キーを書き換えたい場合は `get_edit_url` でブラウザから編集する。
|
|
68
|
+
|
|
44
69
|
## 不要なキーの処理
|
|
45
70
|
|
|
46
71
|
削除せず `config/initializers/copy_tuner.rb` の `ignored_keys` に追加する。
|
|
@@ -55,6 +55,18 @@ describe 'CopyTunerClient::Cache' do
|
|
|
55
55
|
expect(cache.queued.keys).to match_array(%w[ja.views.foo ja.messages.bar])
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
it 'Rails標準の number.*.format キーは設定なしでもアップロードしないこと' do
|
|
59
|
+
cache = build_cache(local_first_key_regexp: nil)
|
|
60
|
+
cache['ja.number.currency.format.unit'] = '$'
|
|
61
|
+
cache['ja.number.gift_amount'] = 'app key'
|
|
62
|
+
cache['ja.messages.bar'] = 'copy tuner value'
|
|
63
|
+
|
|
64
|
+
cache.download
|
|
65
|
+
|
|
66
|
+
# number.*.format のみ抑止。アプリ独自 number キーと通常キーは従来どおりアップロード
|
|
67
|
+
expect(cache.queued.keys).to match_array(%w[ja.number.gift_amount ja.messages.bar])
|
|
68
|
+
end
|
|
69
|
+
|
|
58
70
|
it '変更がない場合はアップロードしないこと' do
|
|
59
71
|
cache = build_cache
|
|
60
72
|
cache.flush
|
|
@@ -217,6 +217,40 @@ describe CopyTunerClient::Configuration do
|
|
|
217
217
|
expect(config.local_first_key?(:'views.foo')).to eq true
|
|
218
218
|
end
|
|
219
219
|
end
|
|
220
|
+
|
|
221
|
+
# NOTE: Rails 標準の number.*.format 配下は precision 等の非文字列値を含み CopyTuner 経由だと壊れるため、
|
|
222
|
+
# ユーザー設定の有無によらず常にローカル優先(組み込み判定)になる
|
|
223
|
+
context 'with built-in Rails number format keys' do
|
|
224
|
+
it 'returns true for built-in number format keys even when local_first_key_regexp is nil' do
|
|
225
|
+
expect(config.local_first_key?('number.format')).to eq true
|
|
226
|
+
expect(config.local_first_key?('number.currency.format')).to eq true
|
|
227
|
+
expect(config.local_first_key?('number.currency.format.precision')).to eq true
|
|
228
|
+
expect(config.local_first_key?('number.percentage.format')).to eq true
|
|
229
|
+
expect(config.local_first_key?('number.human.format.significant')).to eq true
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it 'returns false for app-defined number keys (not Rails format subtrees)' do
|
|
233
|
+
expect(config.local_first_key?('number.gift_amount')).to eq false
|
|
234
|
+
expect(config.local_first_key?('number.my_currency.unit')).to eq false
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it 'returns false for string-only number subtrees and non-number keys' do
|
|
238
|
+
expect(config.local_first_key?('number.human.storage_units.units.byte.one')).to eq false
|
|
239
|
+
expect(config.local_first_key?('date.formats.default')).to eq false
|
|
240
|
+
expect(config.local_first_key?('time.formats.short')).to eq false
|
|
241
|
+
expect(config.local_first_key?('datetime.distance_in_words.x')).to eq false
|
|
242
|
+
expect(config.local_first_key?('views.foo')).to eq false
|
|
243
|
+
expect(config.local_first_key?('numbers.foo')).to eq false
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it 'keeps protecting built-in keys without breaking a user-set regexp' do
|
|
247
|
+
config.local_first_key_regexp = /\Aviews\./
|
|
248
|
+
|
|
249
|
+
expect(config.local_first_key?('number.currency.format')).to eq true
|
|
250
|
+
expect(config.local_first_key?('views.foo')).to eq true
|
|
251
|
+
expect(config.local_first_key?('models.foo')).to eq false
|
|
252
|
+
end
|
|
253
|
+
end
|
|
220
254
|
end
|
|
221
255
|
|
|
222
256
|
describe '#exclude_key_regexp= (deprecated)' do
|
|
@@ -59,75 +59,22 @@ describe CopyTunerClient::DottedHash do
|
|
|
59
59
|
it { is_expected.to eq({ 'en' => { 'test' => { 'key' => 'en test value' } } }) }
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
# NOTE: number.*.format 配下のキー(precision 等)は I18nBackend の local_first_key? ガードで
|
|
63
|
+
# tree_cache をバイパスしローカル YAML 優先になるため、ここで型変換せず文字列のまま保持する。
|
|
64
|
+
# (number_to_currency が壊れないことは i18n_backend_spec の number ローカル優先テストで担保)
|
|
65
|
+
context "number.*.format 配下の値を含む場合" do
|
|
63
66
|
let(:dotted_hash) do
|
|
64
67
|
{
|
|
65
68
|
'en.number.currency.format.precision' => '2',
|
|
66
|
-
'en.number.format.precision' => '3',
|
|
67
|
-
}
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "precision値を整数に変換する" do
|
|
71
|
-
is_expected.to eq({
|
|
72
|
-
'en' => {
|
|
73
|
-
'number' => {
|
|
74
|
-
'currency' => {
|
|
75
|
-
'format' => {
|
|
76
|
-
'precision' => 2,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
'format' => {
|
|
80
|
-
'precision' => 3,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
})
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
context "Rails i18nのbooleanキーの場合" do
|
|
89
|
-
let(:dotted_hash) do
|
|
90
|
-
{
|
|
91
|
-
'en.number.currency.format.significant' => 'false',
|
|
92
|
-
'en.number.format.strip_insignificant_zeros' => 'true',
|
|
93
|
-
}
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "boolean値を実際の真偽値に変換する" do
|
|
97
|
-
is_expected.to eq({
|
|
98
|
-
'en' => {
|
|
99
|
-
'number' => {
|
|
100
|
-
'currency' => {
|
|
101
|
-
'format' => {
|
|
102
|
-
'significant' => false,
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
'format' => {
|
|
106
|
-
'strip_insignificant_zeros' => true,
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
})
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
context "Rails i18n以外で似たパターンを含むキーの場合" do
|
|
115
|
-
let(:dotted_hash) do
|
|
116
|
-
{
|
|
117
69
|
'en.custom.precision' => 'custom_value',
|
|
118
|
-
'en.other.significant_value' => 'true',
|
|
119
70
|
}
|
|
120
71
|
end
|
|
121
72
|
|
|
122
|
-
it "
|
|
73
|
+
it "型変換せず値を文字列のまま保持する" do
|
|
123
74
|
is_expected.to eq({
|
|
124
75
|
'en' => {
|
|
125
|
-
'
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
'other' => {
|
|
129
|
-
'significant_value' => 'true', # no conversion for non-exact match
|
|
130
|
-
},
|
|
76
|
+
'number' => { 'currency' => { 'format' => { 'precision' => '2' } } },
|
|
77
|
+
'custom' => { 'precision' => 'custom_value' },
|
|
131
78
|
},
|
|
132
79
|
})
|
|
133
80
|
end
|
|
@@ -445,7 +445,7 @@ describe 'CopyTunerClient::I18nBackend' do
|
|
|
445
445
|
end
|
|
446
446
|
end
|
|
447
447
|
|
|
448
|
-
describe 'local_first_key_regexp(ローカル優先キー)' do
|
|
448
|
+
describe 'local_first_key_regexp(ローカル優先キー)' do # rubocop:disable Metrics/BlockLength
|
|
449
449
|
after { CopyTunerClient.configuration.local_first_key_regexp = nil }
|
|
450
450
|
|
|
451
451
|
# ローカル config/locales 相当のデータを I18n::Backend::Simple 側だけに格納する。
|
|
@@ -468,6 +468,24 @@ describe 'CopyTunerClient::I18nBackend' do
|
|
|
468
468
|
|
|
469
469
|
expect(subject.translate('ja', 'views.foo')).to eq('copy tuner value')
|
|
470
470
|
end
|
|
471
|
+
|
|
472
|
+
# NOTE: number.*.format は precision 等の非文字列値が store_item で落ちるため、
|
|
473
|
+
# tree cache を優先するとローカル YAML の正しい format が壊れる。組み込み判定で常にローカル優先にする。
|
|
474
|
+
it 'number.*.format は cache に値があってもローカル YAML を優先すること' do
|
|
475
|
+
CopyTunerClient.configuration.local_first_key_regexp = nil
|
|
476
|
+
cache['ja.number.currency.format.unit'] = '$'
|
|
477
|
+
store_local(subject, :ja, number: { currency: { format: { unit: '円' } } })
|
|
478
|
+
|
|
479
|
+
expect(subject.translate('ja', 'number.currency.format')).to eq(unit: '円')
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
it 'アプリ独自の number キーは従来どおり copy_tuner を優先すること' do
|
|
483
|
+
CopyTunerClient.configuration.local_first_key_regexp = nil
|
|
484
|
+
cache['ja.number.gift_amount'] = 'copy tuner value'
|
|
485
|
+
store_local(subject, :ja, number: { gift_amount: 'local value' })
|
|
486
|
+
|
|
487
|
+
expect(subject.translate('ja', 'number.gift_amount')).to eq('copy tuner value')
|
|
488
|
+
end
|
|
471
489
|
end
|
|
472
490
|
|
|
473
491
|
context 'local_first_key_regexp = /\Aviews\./ のとき' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: copy_tuner_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SonicGarden
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
60
|
+
version: '8.0'
|
|
61
61
|
type: :development
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
67
|
+
version: '8.0'
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: rake
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -185,6 +185,7 @@ files:
|
|
|
185
185
|
- ".babelrc"
|
|
186
186
|
- ".eslintrc.js"
|
|
187
187
|
- ".gitattributes"
|
|
188
|
+
- ".github/dependabot.yml"
|
|
188
189
|
- ".github/workflows/rspec.yml"
|
|
189
190
|
- ".gitignore"
|
|
190
191
|
- ".rspec"
|
|
@@ -200,9 +201,8 @@ files:
|
|
|
200
201
|
- app/assets/javascripts/copytuner.js
|
|
201
202
|
- app/assets/stylesheets/copytuner.css
|
|
202
203
|
- copy_tuner_client.gemspec
|
|
203
|
-
- gemfiles/7.1.gemfile
|
|
204
|
-
- gemfiles/7.2.gemfile
|
|
205
204
|
- gemfiles/8.0.gemfile
|
|
205
|
+
- gemfiles/8.1.gemfile
|
|
206
206
|
- gemfiles/main.gemfile
|
|
207
207
|
- index.html
|
|
208
208
|
- lib/copy_tuner_client.rb
|
|
@@ -288,14 +288,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
288
288
|
requirements:
|
|
289
289
|
- - ">="
|
|
290
290
|
- !ruby/object:Gem::Version
|
|
291
|
-
version: 3.
|
|
291
|
+
version: 3.3.0
|
|
292
292
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
293
|
requirements:
|
|
294
294
|
- - ">="
|
|
295
295
|
- !ruby/object:Gem::Version
|
|
296
296
|
version: '0'
|
|
297
297
|
requirements: []
|
|
298
|
-
rubygems_version:
|
|
298
|
+
rubygems_version: 4.0.10
|
|
299
299
|
specification_version: 4
|
|
300
300
|
summary: Client for the CopyTuner copy management service
|
|
301
301
|
test_files: []
|