Skip to content

Commit

Permalink
revised how we import locales into builds that are packaged for the c…
Browse files Browse the repository at this point in the history
…lient so that we are always pulling from CurseForge locale
  • Loading branch information
jahraphael committed Sep 20, 2020
1 parent f655f53 commit 35e9479
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ node_modules
# Client related files we don't need to commit back to git
CHANGES.txt
db_client_*.lua
.env
16 changes: 7 additions & 9 deletions create_merged_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ mkdir -p package

cd package

wget -O latest.zip "https://raiderio-assets.s3.amazonaws.com/addon-build/locale_ref.zip"

rm -rf addon
mkdir -p addon/RaiderIO/db
mkdir -p addon/RaiderIO/{db,locale}
find ../db -type d -name 'RaiderIO_DB_*' -exec cp -av {} addon \;
unzip -o -d addon latest.zip
if [ $? != 0 ]; then
echo "Zip file is invalid; aborting package"
exit 1
fi

find addon -name '*.xml' -exec rm -f {} \;
rm -rf addon/RaiderIO/db/RaiderIO_DB_* # leftovers that could be in config
echo "Manual build $NEW_VERSION" > addon/CHANGES.txt

echo "Overlaying latest DB..."
cp -v ../db/db_*.lua addon/RaiderIO/db
cp ../*.{lua,toc,xml} addon/RaiderIO
cp ../locale/enUS.lua addon/RaiderIO/locale

# setup the locale
cp ../locale/*.lua addon/RaiderIO/locale
bash ../update_locale.sh `pwd`/addon/RaiderIO/locale

cp -a ../libs addon/RaiderIO/
(cd .. ; tar cf - icons) | (cd addon/RaiderIO ; tar xvf -)

Expand Down
68 changes: 68 additions & 0 deletions update_locale.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
#
# Pull the localization data from CurseForge
#
# Setup:
# Ensure this environment variable is set!
#
# CF_API_TOKEN
#

# Raider.IO Project ID
CF_PROJECT_ID=279257

LOCALE_FOLDER=$1

if [ ! -d "$LOCALE_FOLDER" ]; then
echo "Usage: $0 <locale_folder>"
exit 1
fi

echo "Updating latest locale files from CurseForge..."

CF_LOCALE_FILE=locale_temp_cf.$$
for locale in deDE esES frFR itIT koKR ptBR ruRU zhCN zhTW ; do
# where we will write out the newly created locale file
NEW_LOCALE_FILE=locale_temp_new.$$

curl -s -H "x-api-token: $CF_API_TOKEN" -XGET "https://wow.curseforge.com/api/projects/$CF_PROJECT_ID/localization/export?table-name=L&export-type=TableAdditions&unlocalized=ShowBlankAsComment&lang=$locale" > $CF_LOCALE_FILE
if [ "x$?" != "x0" ]; then
echo "Failed to get locale $locale"
rm $CF_LOCALE_FILE
exit 1
fi

grep 'L = L or' $CF_LOCALE_FILE > /dev/null
if [ "x$?" != "x0" ]; then
echo "Invalid results from locale query $locale"
rm $CF_LOCALE_FILE
exit 1
fi

# where we are reading the source locale template file from
LOCALE_TEMPLATE_FILE=${LOCALE_FOLDER}/${locale}.lua

grep -- '--@localization' $LOCALE_TEMPLATE_FILE > /dev/null
if [ "x$?" != "x0" ]; then
echo "Failed to find localization tag in template file $LOCALE_TEMPLATE_FILE"
rm $CF_LOCALE_FILE
exit
fi

cat $CF_LOCALE_FILE | grep -v 'L = L or ' > $NEW_LOCALE_FILE

DATE_TAG=$(date)
echo "-- Generated from CurseForge on ${DATE_TAG}" > $NEW_LOCALE_FILE

# append lines before the localization tag
awk '/--@localization/ {exit} {print}' $LOCALE_TEMPLATE_FILE >> $NEW_LOCALE_FILE

cat $CF_LOCALE_FILE | grep -v 'L = L or ' >> $NEW_LOCALE_FILE

# append lines after the localization tag
awk 'x==1 {print} /--@localization/ {x=1}' $LOCALE_TEMPLATE_FILE >> $NEW_LOCALE_FILE

mv -v $NEW_LOCALE_FILE $LOCALE_TEMPLATE_FILE
done

rm $CF_LOCALE_FILE
25 changes: 0 additions & 25 deletions upload_locale.sh

This file was deleted.

0 comments on commit 35e9479

Please sign in to comment.