locallingo 0.4.0 → 0.4.1

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: 398a4540431fa5298a1eba1fedecef3c4b7344d2749f935a30882d8899ebcb69
4
- data.tar.gz: c854c5c26ebee79b0d5663614207e0f75368c973058a5ac320f58ec4e45e3835
3
+ metadata.gz: 566c302b3598359e622f4b6b98a59bf1a8b3487fc81b898ca93a2d0446c31c63
4
+ data.tar.gz: 9961bb74a9f23e2bebdaa4c64913723a195eaac89470a68e3f175b87f2a68e24
5
5
  SHA512:
6
- metadata.gz: 5969d9cac09643f81e6e37ae72ad79003373d1870bbaf37300c0e4c5a95449c6c422176aa6ea1938b66a53889669bbf3c0a0f5525e56d7f0afd0e8c9c2c33c44
7
- data.tar.gz: 22e5a7d6ff926e04baa3e0de58d7cea8d4993356a3ac931de745dbc8e817298b99b2ff591b4e353e1adc9052dd44307fce4cd957605fcd5527c448e83e8d40f4
6
+ metadata.gz: 441a84936ce9cb8cba5354bfc81ec49de1d498190b81c9020c52df3b4d7fa4ef15aefde5b6d9911e5dabf161227765f93aa75c6e99e677f61febb0dbfbd95a3e
7
+ data.tar.gz: 4d18fed67d04efb9750abb753fee743bd4a206bc9c396e95c882db5d2add9c948782cc65f38bb4b64f9f51018281d7c8af4b4130a37c8b36ddae420cd688f4db
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
  ## [Unreleased]
8
8
 
9
9
  ### Fixed
10
+ - `lingo sync` backfills a missing `target_hash` from the current target value,
11
+ so hand-added translations (written straight into the YAML, never passing
12
+ through `translate` or `accept-edits`) get a baseline and the `manual_edits`
13
+ validator can watch them. An existing `target_hash` is still never
14
+ recomputed — that would silently absorb hand-edit drift.
15
+
16
+ ### Fixed (0.4.0)
10
17
  - `lingo sync` no longer destroys hand-edit protection: it now only refreshes
11
18
  each entry's `source_hash` and preserves `target_hash` and `manual: true`
12
19
  (the pre-extraction `bin/translate` behavior). Previously a single sync wiped
@@ -134,11 +134,12 @@ module Locallingo
134
134
  format("%08x", Zlib.crc32(load_source_translations.to_json))
135
135
  end
136
136
 
137
- # Refresh source hashes from the current translation files and prune state
138
- # for keys that no longer exist. Existing `target_hash`/`manual` fields are
139
- # preserved hand-edit protection is never dropped by a sync; use
140
- # `accept_edits!` to resolve hand-edit drift explicitly. Returns the
141
- # combined state.
137
+ # Refresh source hashes from the current translation files, backfill a
138
+ # `target_hash` baseline for entries that lack one, and prune state for
139
+ # keys that no longer exist. An existing `target_hash` and the `manual`
140
+ # flag are never touched — hand-edit protection is never dropped by a
141
+ # sync; use `accept_edits!` to resolve hand-edit drift explicitly.
142
+ # Returns the combined state.
142
143
  def sync_state!
143
144
  source = load_source_translations
144
145
 
@@ -171,12 +172,16 @@ module Locallingo
171
172
  target = load_locale_translations(locale)
172
173
  locale_state = @state.load(locale)
173
174
 
174
- target.each_key do |key|
175
+ target.each do |key, value|
175
176
  next unless source[key]
176
177
 
177
178
  existing = locale_state[key]
178
179
  entry = existing.is_a?(Hash) ? existing.dup : {}
179
180
  entry["source_hash"] = @state.hash(source[key])
181
+ # Backfill a baseline for hand-added translations so the manual-edits
182
+ # validator can watch them; an existing target_hash is never recomputed —
183
+ # that would silently absorb hand-edit drift.
184
+ entry["target_hash"] ||= @state.hash(value)
180
185
  locale_state[key] = entry
181
186
  end
182
187
  locale_state.each_key { |key| locale_state.delete(key) unless target.key?(key) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Locallingo
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locallingo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson