Skip to content

Commit

Permalink
Uplift of #27831 (squashed) to release
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-builds committed Feb 26, 2025
1 parent 0f92e80 commit bb19324
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 40 deletions.
3 changes: 2 additions & 1 deletion ios/brave-ios/App/l10n/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ Once your english strings are all up to date. These changes can be pushed to Cro

```
cd l10n/
TOKEN=<token> ./push-strings-to-crowdin.sh
TOKEN=<token> VERSION=<release_version> ./push-strings-to-crowdin.sh
```

If there any issues pushing strings to Crowdin then these issues are logged to ```output.log```
The `VERSION` is in the format of `version_number`. For example: `1_75_0`.

### Importing the latest translations from Crowdin

Expand Down
50 changes: 11 additions & 39 deletions ios/brave-ios/App/l10n/tools/push-strings-to-crowdin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

# Push string changes to Transifex
# Push string changes to Crowdin
#
# Error Codes:
# 0 = Success
Expand All @@ -24,12 +24,6 @@ report_error()

cleanup()
{
if [ -e transifex.log ] ; then
cat transifex.log >> output.log
echo >> output.log
rm transifex.log
fi

if [ -e ../../Client/en.xcloc ]; then
rm -R ../../Client/en.xcloc
fi
Expand All @@ -43,6 +37,10 @@ if [ "${TOKEN}" = "" ] ; then
report_error 1 "TOKEN environment variable must be set to \"api\""
fi

if [ "${VERSION}" = "" ] ; then
report_error 1 "VERSION environment variable must be set"
fi

cd $(dirname "$0")

echo "Exporting strings from Xcode project..."
Expand Down Expand Up @@ -104,7 +102,7 @@ add_file()
--data @- << EOF
{
"storageId": $crowdin_storage_id,
"name": "en.xliff",
"name": "${VERSION}.xliff",
"type": "xliff"
}
EOF
Expand All @@ -131,39 +129,13 @@ else
echo "Crowdin Storage ID: $crowdin_storage_id"
fi

echo "Checking if there is already a file id for our project in Crowdin..."
file_result=$(curl --silent \
-X "GET" "https://brave-software.crowdin.com/api/v2/projects/$crowdin_project_id/files" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json"
)
file_id=$(echo "$file_result" | jq '.data.[0].data.id')
if [ "$file_id" == "null" ]
echo "Adding a new source file..."
add_file_http_code=$(add_file)
if [ $add_file_http_code != 201 ]
then
echo "No, there is no file. Adding a new file..."
add_file_http_code=$(add_file)
if [ $add_file_http_code != 201 ]
then
report_error 5 "ERROR: Failed to add a file to the project in Crowdin"
else
echo "The new source file has been added to the project in Crowdin"
fi
report_error 5 "ERROR: Failed to add a file to the project in Crowdin"
else
echo "Yes, there is a file id: $file_id. Deleting this file ..."
delete_file_http_code=$(delete_file $file_id)
if [ $delete_file_http_code != 204 ]
then
report_error 5 "ERROR: Failed to delete the existed file in Crowdin"
else
echo "Now, adding a new file ..."
add_file_http_code=$(add_file)
if [ $add_file_http_code != 201 ]
then
report_error 5 "ERROR: Failed to add a file to the project in Crowdin"
else
echo "The new source file has added to the project in Crowdin"
fi
fi
echo "The new source file has been added to the project in Crowdin"
fi

cleanup
Expand Down

0 comments on commit bb19324

Please sign in to comment.