translation 1.40 → 1.41

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: e7ff12437624a9fc88ae0afe4581c25c51d816357036a917af5f5f662ab596ed
4
- data.tar.gz: ed5a5ccfa234ba638d2b3affe2c33650d821402ec8c9876f8d6d7d70f23767fc
3
+ metadata.gz: 9766fe39c1c7c38917d1c342ee336549774d9518401954de16a812b56616a70a
4
+ data.tar.gz: 1615db935264c7bc4e55a49242381f70fe2c3efd50522c79b52179d8964f2c18
5
5
  SHA512:
6
- metadata.gz: ba3cd367d5d1d67210974ebfc3cbf79934308cbff6610e5c4afe110eba5e48cef17d9aed4a172dad370f4abd37580948f3b50e4450c3c104a7e182372402f724
7
- data.tar.gz: 8ca2c66f2faf603eef2cff49ea6385941c57e47be5566209aeef5216c9fbf154382d3cc8e33ac54fa11dceff23cfbf37d177d8039881afe5c833529386d81262
6
+ metadata.gz: 51ee942b353b2cbaf1ebdfb420057711f448cdc4f57a9fbd0f140bafbcce681a83c176053ab3d5b26f71856eddf6b04c24637569c38f506f1e87eb5471a572ec
7
+ data.tar.gz: 21a7cc0907c3b61861af8c9dd0e3fe8c18b10eb4c850f52e35a80f09e923f390f9b61176eadf685eb38380cfdaad2fead8647cc3e4e46c404091b844e2183a44
data/README.md CHANGED
@@ -408,7 +408,9 @@ end
408
408
  ### Ignored YAML keys
409
409
 
410
410
  Sometimes you would like to ignore some YAML keys coming from gems or so.
411
- You can use the `ignored_key_prefixes` for that.
411
+
412
+ You can use the `ignored_key_prefixes` array with a mix or strings and
413
+ regular expressions.
412
414
 
413
415
  For example:
414
416
 
@@ -423,7 +425,8 @@ TranslationIO.configure do |config|
423
425
  'will_paginate',
424
426
  'helpers.page_entries_info',
425
427
  'views.pagination',
426
- 'enumerize.visibility'
428
+ 'enumerize.visibility',
429
+ /\.code$/
427
430
  ]
428
431
  ...
429
432
  end
@@ -31,7 +31,7 @@ module TranslationIO
31
31
  end
32
32
 
33
33
  def ignored?(key)
34
- key.present? && ignored_key_prefixes.any? { |prefix| key_without_locale(key).match(/^#{Regexp.escape(prefix)}\b/) != nil }
34
+ key.present? && ignored_key_prefixes.any? { |prefix| ignored_prefix?(key, prefix) || ignored_regex?(key, prefix) }
35
35
  end
36
36
 
37
37
  def localization?(key, value)
@@ -44,6 +44,23 @@ module TranslationIO
44
44
 
45
45
  private
46
46
 
47
+ def ignored_prefix?(key, prefix)
48
+ if prefix.is_a?(String)
49
+ regex = /^#{Regexp.escape(prefix)}\b/
50
+ key_without_locale(key).match(regex) != nil
51
+ else
52
+ false
53
+ end
54
+ end
55
+
56
+ def ignored_regex?(key, regex)
57
+ if regex.is_a?(Regexp)
58
+ key_without_locale(key).match(regex) != nil
59
+ else
60
+ false
61
+ end
62
+ end
63
+
47
64
  def localization_key_prefixes
48
65
  if TranslationIO.config
49
66
  LOCALIZATION_KEY_PREFIXES + TranslationIO.config.localization_key_prefixes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.40'
4
+ version: '1.41'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Hoste
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-02-09 00:00:00.000000000 Z
12
+ date: 2024-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gettext