Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: remove new translation keys

FOLIO front-end code uses translation keys to fetch actual text in English or any other language.

...

Code Block
languagebash
titletranslations-upgrade
#!/bin/sh

# Before running this script change into the ./translations directory where the web server (nginx, ...)
# ships the /translations/*.json files from, for example
# cd /usr/folio/folio-testing-platform/output/translations

set -e

BUNDLE=$(curl -s https://folio-testing.dev.folio.org/ | sed -n -E '/.*"\/(bundle\.[0-9a-z]+\.js)".*/{s//\1/p;q}')
echo $BUNDLE

N=$(curl -s https://folio-testing.dev.folio.org/$BUNDLE | sed -n -E '/.*"\/translations\/en-([0-9]+)\.json".*/{s//\1/p;q}')

for file in ./*-*.json ; do
  if [ ! -e "$file" ] ; then
    continue
  fi
  LANG=$(echo "$file" | sed -n -E '/^.\/([^-]+)-[0-9]+\.json$/{s//\1/p;q}')
  if [ -z $LANG ] ; then
    continue
  fi
  echo "https://folio-testing.dev.folio.org/translations/$LANG-$N.json"
  curl -s https://folio-testing.dev.folio.org/translations/$LANG-$N.json > $LANG.json
  jq -s '.[0] * .[1]' $file $LANG.json > $LANG.json.new
  mv $LANG.json.new $file
  rm $LANG.json
done

To remove new translation keys replace
'.[0] * .[1]'
by
'.[0] as $old | .[0] * .[1] | with_entries( select( .key as $key | $old | has( $key ) ) )'
but this may remove a key that the old code uses and was forgotten to get added to the old language file.

Clean backport using yarn build

The backport method described above is a hack.

The clean way to use more recent translations is to replace them during the front-end build process.

After runningyarn install but before running yarn build copy the new translations into the node_modules/@folio/${application}/translations/ui-${application}/${locale}.json files.

We don't know of anyone that uses this method, no script is available for this yet.