loco_strings 0.1.6 → 0.1.9

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: 83291f99249e590483aa4c51d5710eada7bc80a910048bf0ba20b66a25ff187f
4
- data.tar.gz: 11a3bbb921de0df05fe594518b98a254dc27531a8c312e383827090fb6816391
3
+ metadata.gz: 45967a4d7a5f4a5ddc6d3fbeec661fcf7d9c096cade448616b7e096e3d41b3d5
4
+ data.tar.gz: e0f26ff5774aff74719a30811404f9834e26b3a96f0f800cb08a6a3f004a3f2b
5
5
  SHA512:
6
- metadata.gz: 36f248bd8877845fa3983df90cf0903ca7fb26df5fefaeff0a52c98a5b5393e0d1e9a7121bc068db6b0c169b78899796807dabc119c45616d5ce8d77096ba2e5
7
- data.tar.gz: 6df549b39d2ba998aff3899eb27729a988d428d76ad7c14789f5c0a1e64b920a1eb6f7f6a0051beb24754baf3825413fe2dad08519f6ffb02d7097af4255cb3b
6
+ metadata.gz: '08dfd0d814825888c048dcc6ed25900b4dc2c5e85e82411a447c4d17b562ba99b57f98af8e0b18466a73cac316161ec06e6e0b8877fa9fcf9b24e1e257ef84e7'
7
+ data.tar.gz: 95c99ae564c6624e653efc459b7d75c974024912ca68df84acaf548836471752c42ada4e47e73a0e4ebebf19395f51b82ede7a1093381689849b8bf1ba0e42e8
@@ -51,7 +51,7 @@ module LocoStrings
51
51
  @strings[key] = LocoString.new(key, key, value["comment"], "new") if val.nil?
52
52
  @strings[key].translatable = translatable
53
53
 
54
- decode_translations(key, value)
54
+ decode_translations(key, value, translatable)
55
55
  end
56
56
  end
57
57
 
@@ -100,9 +100,11 @@ module LocoStrings
100
100
  result
101
101
  end
102
102
 
103
- def decode_translations(key, value)
103
+ def decode_translations(key, value, translatable = true)
104
104
  @languages.each do |language|
105
105
  string = decode_string(key, value, language)
106
+ # Carry the shouldTranslate flag onto the per-language unit so it round-trips on encode.
107
+ string.translatable = translatable if string
106
108
  @translations[language] ||= {}
107
109
  @translations[language][key] = string
108
110
  end
@@ -44,6 +44,9 @@ module LocoStrings
44
44
  sorted_keys.each do |language|
45
45
  process_language(row, language, key)
46
46
  end
47
+ # Bare keys (no per-language unit, e.g. compiler-extracted source-only keys) have nothing for
48
+ # add_translation_flag to read — fall back to the source-string flag so shouldTranslate persists.
49
+ row["shouldTranslate"] = false if !row.key?("shouldTranslate") && @strings[key]&.translatable == false
47
50
  state = @extraction_states[key]
48
51
  return row if state.nil?
49
52
 
@@ -55,6 +55,11 @@ module LocoStrings
55
55
 
56
56
  def update_traslatability(key, translatable)
57
57
  @strings[key].translatable = translatable
58
+ # The encoder reads the flag from the per-language units, so set it there too.
59
+ @translations.each_value do |units|
60
+ unit = units[key]
61
+ unit.translatable = translatable if unit
62
+ end
58
63
  end
59
64
 
60
65
  def select_language(language)
@@ -120,7 +125,13 @@ module LocoStrings
120
125
  def make_variations(key, variant, value, comment = nil, state = nil, language = @language) # rubocop:disable Metrics/ParameterLists
121
126
  variants = @translations.dig(language, key)
122
127
 
123
- return make_strings(key, value, comment, state, language) if variants.is_a?(LocoString)
128
+ # Upgrade a plain (e.g. compiler-extracted) flat string into a plural variation set the first
129
+ # time a variant is written for it — carrying over its comment. Without this, writing a
130
+ # variation onto an extracted key would silently fall back to a flat string and drop the plural.
131
+ if variants.is_a?(LocoString)
132
+ state = "new" if state.nil?
133
+ return LocoVariantions.new(key, { variant => LocoString.new(variant, value, comment, state) }, variants.comment)
134
+ end
124
135
 
125
136
  if variants.nil?
126
137
  state = "new" if state.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LocoStrings
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.9"
5
5
  end
data/lib/loco_strings.rb CHANGED
@@ -46,7 +46,7 @@ module LocoStrings
46
46
  if strings.key? key
47
47
  strings[key].update(value, comment, state, translatable)
48
48
  else
49
- strings[key] = LocoString.new(key, value, comment, state, nil, translatable)
49
+ strings[key] = LocoString.new(key, value, comment, state, translatable)
50
50
  end
51
51
  end
52
52
 
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loco_strings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksei Cherepanov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
10
  date: 2026-06-07 00:00:00.000000000 Z
@@ -69,7 +68,6 @@ metadata:
69
68
  homepage_uri: https://github.com/ftp27/loco_strings
70
69
  source_code_uri: https://github.com/ftp27/loco_strings
71
70
  rubygems_mfa_required: 'true'
72
- post_install_message:
73
71
  rdoc_options: []
74
72
  require_paths:
75
73
  - lib
@@ -84,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
82
  - !ruby/object:Gem::Version
85
83
  version: '0'
86
84
  requirements: []
87
- rubygems_version: 3.5.22
88
- signing_key:
85
+ rubygems_version: 3.6.2
89
86
  specification_version: 4
90
87
  summary: LocoStrings is a Ruby gem for working with iOS and Android localization strings.
91
88
  test_files: []