Skip to content

Commit

Permalink
Fix bin/fill-locales when the key in en is a hash and not in other
Browse files Browse the repository at this point in the history
The script would fail if the current `en` was a hash but `other` wasn't
because we would try to call `dig` on a string. In this case, return
`nil` so that we can recursively copy the shape of `en` to `other`
  • Loading branch information
albertchae authored and simi committed Feb 19, 2024
1 parent bf6c767 commit b9fe2d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/fill-locales
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ EN = YAML.safe_load_file(EN_PATH)
def fill(en, other)
if en.is_a?(Hash)
en.map do |key, _|
[key, fill(en[key], other&.dig(key))]
next_other = other.is_a?(Hash) ? other&.dig(key) : nil
[key, fill(en[key], next_other)]
end.to_h
elsif en.is_a?(String)
other
Expand Down

0 comments on commit b9fe2d7

Please sign in to comment.