44# License, v. 2.0. If a copy of the MPL was not distributed with this file,
55# You can obtain one at https://mozilla.org/MPL/2.0/.
66
7- # Push string changes to Transifex
7+ # Push string changes to Crowdin
88#
99# Error Codes:
1010# 0 = Success
@@ -24,12 +24,6 @@ report_error()
2424
2525cleanup ()
2626{
27- if [ -e transifex.log ] ; then
28- cat transifex.log >> output.log
29- echo >> output.log
30- rm transifex.log
31- fi
32-
3327 if [ -e ../../Client/en.xcloc ]; then
3428 rm -R ../../Client/en.xcloc
3529 fi
@@ -43,6 +37,10 @@ if [ "${TOKEN}" = "" ] ; then
4337 report_error 1 " TOKEN environment variable must be set to \" api\" "
4438fi
4539
40+ if [ " ${VERSION} " = " " ] ; then
41+ report_error 1 " VERSION environment variable must be set"
42+ fi
43+
4644cd $( dirname " $0 " )
4745
4846echo " Exporting strings from Xcode project..."
@@ -104,7 +102,7 @@ add_file()
104102 --data @- << EOF
105103 {
106104 "storageId": $crowdin_storage_id ,
107- "name": "en .xliff",
105+ "name": "${VERSION} .xliff",
108106 "type": "xliff"
109107 }
110108EOF
@@ -131,39 +129,13 @@ else
131129 echo " Crowdin Storage ID: $crowdin_storage_id "
132130fi
133131
134- echo " Checking if there is already a file id for our project in Crowdin..."
135- file_result=$( curl --silent \
136- -X " GET" " https://brave-software.crowdin.com/api/v2/projects/$crowdin_project_id /files" \
137- -H " Authorization: Bearer ${TOKEN} " \
138- -H " Content-Type: application/json"
139- )
140- file_id=$( echo " $file_result " | jq ' .data.[0].data.id' )
141- if [ " $file_id " == " null" ]
132+ echo " Adding a new source file..."
133+ add_file_http_code=$( add_file)
134+ if [ $add_file_http_code != 201 ]
142135then
143- echo " No, there is no file. Adding a new file..."
144- add_file_http_code=$( add_file)
145- if [ $add_file_http_code != 201 ]
146- then
147- report_error 5 " ERROR: Failed to add a file to the project in Crowdin"
148- else
149- echo " The new source file has been added to the project in Crowdin"
150- fi
136+ report_error 5 " ERROR: Failed to add a file to the project in Crowdin"
151137else
152- echo " Yes, there is a file id: $file_id . Deleting this file ..."
153- delete_file_http_code=$( delete_file $file_id )
154- if [ $delete_file_http_code != 204 ]
155- then
156- report_error 5 " ERROR: Failed to delete the existed file in Crowdin"
157- else
158- echo " Now, adding a new file ..."
159- add_file_http_code=$( add_file)
160- if [ $add_file_http_code != 201 ]
161- then
162- report_error 5 " ERROR: Failed to add a file to the project in Crowdin"
163- else
164- echo " The new source file has added to the project in Crowdin"
165- fi
166- fi
138+ echo " The new source file has been added to the project in Crowdin"
167139fi
168140
169141cleanup
0 commit comments