This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
updateCopy.sh
executable file
·55 lines (48 loc) · 1.79 KB
/
updateCopy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
# ./updateCopy.sh <project_id> <branch> <api_token>
# Updates translations from Lokalise and creates a GitHub pull request to integrate these translations.
#
# You almost never have to do this manually—use the GitHub "Update Translations" action to do it for you.
#
#
# OH NO, THE SCRIPT/ACTION ISN'T WORKING!
# If the error looks like this:
#
# > Downloading translations...
# > curl: no URL specified!
#
# ...your API token is probably out of date, or has been removed (maybe the user who created it left.)
#
# Generate a new API token for a Lokalise user who will be here for a while. (See: https://docs.lokalise.com/en/articles/1929556-api-tokens)
# Then update the LOKALISE_API_TOKEN secret in the GitHub settings for the project (you need to be a maintainer to do this.)
# Then try re-running the Update Translations action again to see if it worked.
# Generate and upload zip for newest translations
echo "Requesting translations..."
response=$(curl --request POST \
--url "https://api.lokalise.com/api2/projects/$1:$2/files/download" \
--header 'content-type: application/json' \
--header "x-api-token: $3" \
--data '{
"format":"strings",
"original_filenames":true,
"directory_prefix":"",
"indentation":"tab",
"filter_langs": ["ar", "bn", "cy", "en", "gu", "pa", "ro", "tr", "ur", "zh", "pl", "so"],
"replace_breaks":true,
"export_sort":"first_added"
}'
)
# Clean link to generated zip file.
bundle_url=$(echo $response | sed 's/\\//g' | grep -oiE '\"https.*"' | sed 's/"//g')
# Download translations
echo "Downloading translations..."
curl $bundle_url -LO
echo "Unpacking..."
unzip NHS_COVID-19-Localizable.zip -d Localization
echo "Move files into the project"
cd Localization
cp -r * ..
cd ..
echo "Cleaning up..."
rm -rf Localization
rm NHS_COVID-19-Localizable.zip