Replace argfile by slurpfile (#8309)

This commit is contained in:
Max 2025-04-02 23:09:53 +02:00 committed by GitHub
parent 01845928b2
commit 4f02060fd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,7 @@
# by the corresponding values of target. If a key does not exist in target, # by the corresponding values of target. If a key does not exist in target,
# the value is set to null. # the value is set to null.
# #
# jq -n --argfile source en.json --argfile target es.json -f normalize-locales.jq # jq -n --slurpfile source en.json --slurpfile target es.json -f normalize-locales.jq
# #
# source should be primary or fallback locale file (here en.json) # source should be primary or fallback locale file (here en.json)
# taget is the locale file to normalize (here es.json) # taget is the locale file to normalize (here es.json)
@ -22,10 +22,10 @@ def keys_to_paths_recursive($path):
then with_entries( then with_entries(
($path + [.key]) as $path | ($path + [.key]) as $path |
if (.value | type == "string") if (.value | type == "string")
then .value |= ($target | find_key_by_path($path)) then .value |= ($target[0] | find_key_by_path($path))
else .value |= keys_to_paths_recursive($path) else .value |= keys_to_paths_recursive($path)
end) end)
else . else .
end; end;
$source | keys_to_paths_recursive([]) $source[0] | keys_to_paths_recursive([])

View File

@ -9,8 +9,8 @@ for locale_file in "${locale_list[@]}"
do do
jq -n \ jq -n \
-f $(dirname "$0")/normalize-locales.jq \ -f $(dirname "$0")/normalize-locales.jq \
--argfile source $ROOT_DIR/webapp/locales/en.json \ --slurpfile source $ROOT_DIR/webapp/locales/en.json \
--argfile target $ROOT_DIR/webapp/locales/$locale_file \ --slurpfile target $ROOT_DIR/webapp/locales/$locale_file \
> "$tmp" > "$tmp"
mv "$tmp" $ROOT_DIR/webapp/locales/$locale_file mv "$tmp" $ROOT_DIR/webapp/locales/$locale_file
done done