locallingo 0.4.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 398a4540431fa5298a1eba1fedecef3c4b7344d2749f935a30882d8899ebcb69
4
- data.tar.gz: c854c5c26ebee79b0d5663614207e0f75368c973058a5ac320f58ec4e45e3835
3
+ metadata.gz: 59b29821c8d0702b66bdbf3573565ed97b7ec1730091561bdab5d4c21fd8cecf
4
+ data.tar.gz: 1c3a26a753aa7fe3bf8f2c30c372caa8903f558b23ddb5cccd9f663f9cb6889b
5
5
  SHA512:
6
- metadata.gz: 5969d9cac09643f81e6e37ae72ad79003373d1870bbaf37300c0e4c5a95449c6c422176aa6ea1938b66a53889669bbf3c0a0f5525e56d7f0afd0e8c9c2c33c44
7
- data.tar.gz: 22e5a7d6ff926e04baa3e0de58d7cea8d4993356a3ac931de745dbc8e817298b99b2ff591b4e353e1adc9052dd44307fce4cd957605fcd5527c448e83e8d40f4
6
+ metadata.gz: 9e52e5fd9039c732daafbe32100dd51d14fc839b149da624d6da9f465a9b9adfefb0ee42f1cdf1705789b69cc103f83d25fe12e89cc80dbc1a24a0b85e642d59
7
+ data.tar.gz: 8869c511367af25968e6e18464b6ed8ff6eef74fc16de56b3d80a78842df521bcbb9487df92d429b731d917a167a19c9610571193313f4d2c096871c21e0dc3e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
  ## [Unreleased]
8
8
 
9
9
  ### Fixed
10
+ - State files are written with a trailing final newline, so the output is
11
+ POSIX-conformant and files that already end with a newline are no longer
12
+ rewritten with newline-only diffs. One-time effect after upgrading: each
13
+ state file gets a single newline-adding rewrite, then stabilizes. (#7)
14
+ - `lingo sync` backfills a missing `target_hash` from the current target value,
15
+ so hand-added translations (written straight into the YAML, never passing
16
+ through `translate` or `accept-edits`) get a baseline and the `manual_edits`
17
+ validator can watch them. An existing `target_hash` is still never
18
+ recomputed — that would silently absorb hand-edit drift.
19
+
20
+ ### Fixed (0.4.0)
10
21
  - `lingo sync` no longer destroys hand-edit protection: it now only refreshes
11
22
  each entry's `source_hash` and preserves `target_hash` and `manual: true`
12
23
  (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) }
@@ -51,7 +51,7 @@ module Locallingo
51
51
 
52
52
  by_namespace.each do |namespace, keys|
53
53
  state_file = File.join(state_dir, "#{namespace}.#{locale}.json")
54
- content = JSON.pretty_generate(keys.sort.to_h)
54
+ content = "#{JSON.pretty_generate(keys.sort.to_h)}\n"
55
55
  next if File.exist?(state_file) && File.read(state_file) == content
56
56
 
57
57
  File.write(state_file, content)
@@ -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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
@@ -90,13 +90,13 @@ files:
90
90
  - lib/locallingo/version.rb
91
91
  - lib/rubocop/cop/locallingo/relative_i18n_key.rb
92
92
  - lib/rubocop/cop/locallingo/strftime_in_view.rb
93
- homepage: https://github.com/mhenrixon/locallingo
93
+ homepage: https://github.com/zoolutions/locallingo
94
94
  licenses:
95
95
  - MIT
96
96
  metadata:
97
- source_code_uri: https://github.com/mhenrixon/locallingo
98
- changelog_uri: https://github.com/mhenrixon/locallingo/blob/main/CHANGELOG.md
99
- bug_tracker_uri: https://github.com/mhenrixon/locallingo/issues
97
+ source_code_uri: https://github.com/zoolutions/locallingo
98
+ changelog_uri: https://github.com/zoolutions/locallingo/blob/main/CHANGELOG.md
99
+ bug_tracker_uri: https://github.com/zoolutions/locallingo/issues
100
100
  rubygems_mfa_required: 'true'
101
101
  rdoc_options: []
102
102
  require_paths: