Skip to content

Commit

Permalink
Update the localization script instructions. (stripe#4039)
Browse files Browse the repository at this point in the history
  • Loading branch information
michelleb-stripe authored Jul 21, 2021
1 parent 3906192 commit 69652a5
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
9 changes: 9 additions & 0 deletions scripts/find_localize_key_for_value_regex.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#!/bin/bash

# This script will do a regular expression match to find the string value in the ios or
# android projects, regardless of the translation status
#
# The script can be run as ./find_localize_key_for_value_regex.sh <regular expression>
# For instance: ./find_localize_key_for_value_regex.sh ".*optional.*"

if [ -z "$API_TOKEN" ]; then
echo "You need to add the API_TOKEN to: localization_vars.sh"
exit
fi

echo "Searching for string value: $1"

Expand Down
24 changes: 14 additions & 10 deletions scripts/localize.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#!/bin/bash

#This script will pull down the strings for each of the modules and copies
#them into the respective string directories.
# This script will pull down the strings for each of the modules and copies
# them into the respective string directories.
#
# It will remove the android directory from which it works at the beginning
# It will not replace the default string value.
# It will do iso renames as needed.
# It will not perform a commit.
#
#It will remove the android directory from which it works at the beginning
#It will not replace the default string value.
#It will do iso renames as needed.
#It will not perform a commit.
# It does generate an android/$MODULE-strings.xml file for use by other scripts.
#
#It does generate an android/$MODULE-strings.xml file for use by other scripts.
# This script can be run with no arguments:
# ./localize.sh

#xml is for android, strings is for iOS
FORMAT=xml
if [ -z "$API_TOKEN" ]; then
echo "You need to add the API_TOKEN to: localization_vars.sh"
exit
fi

if [[ -z $(which lokalise2) ]]; then
echo "Installing lokalise2 via homebrew..."
Expand Down
17 changes: 13 additions & 4 deletions scripts/no_file_assigned.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/bin/bash

#This will download all the android files, and strings that are assigned to android
#but not to any files will be outputted. This indicates an error. It will cleanup
#files created at the end.
# This will download all the android files, and strings that are assigned to android
# but not to any files will be outputted. This indicates an error. It will cleanup
# files created at the end.
#
# This will not replace any files in the android project.
#
# This script can be run with no arguments:
# ./no_file_assigned.sh

if [ -z "$API_TOKEN" ]; then
echo "You need to add the API_TOKEN to: localization_vars.sh"
exit
fi

if [[ -z $(which lokalise2) ]]; then
echo "Installing lokalise2 via homebrew..."
Expand Down
18 changes: 13 additions & 5 deletions scripts/untranslated_project_keys.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash

#This script will go through each of the modules and verify that each string key is
#associated with android in localize. If it isn't the script will search for the string
#value in the localize android and ios project.
# This script will go through each of the modules and verify that each string key is
# associated with android in localize. If it isn't the script will search for the string
# value in the localize android and ios project.
#
# It will ignore strings in the project that have the translateable=false
# This script requires that localize.sh is run first, if it is not it will exit with an error.
#
# This script can be run with no arguments:
# ./untranslated_project_key.sh

if [ -z "$API_TOKEN" ]; then
echo "You need to add the API_TOKEN to: localization_vars.sh"
exit
fi

if [[ -z $(which lokalise2) ]]; then
echo "Installing lokalise2 via homebrew..."
Expand Down Expand Up @@ -34,7 +42,7 @@ do
sort -o android/$MODULE-localize_android_keys-sorted.txt android/$MODULE-localize_android_keys.txt

# List all the keys in the android project.
cat ../$MODULE/res/values/strings.xml | grep -v "translatable=\"false\"" | gsed -E -n "s/\s*<string name=\"([^ ]*)\".*>(.*)<\/string>/\1/pI" > android/$MODULE-project_keys.txt
cat ../$MODULE/res/values/strings.xml | gsed -E -n "s/\s*<string name=\"([^ ]*)\".*>(.*)<\/string>/\1/pI" > android/$MODULE-project_keys.txt
sort -o android/$MODULE-project_keys-sorted.txt android/$MODULE-project_keys.txt

diff -u android/$MODULE-localize_android_keys-sorted.txt android/$MODULE-project_keys-sorted.txt | grep -E "^[\+][a-z]" | sed 's/^+//g' > android/diff_keys-$MODULE.txt
Expand Down

0 comments on commit 69652a5

Please sign in to comment.