Skip to content

Commit 5f17d34

Browse files
FilippoZazzeroniFilippo
and
Filippo
authored
Bugfix FXIOS-10933 String import failing to import new strings (#23879)
* Refactor import strings action to move repo clones and Xliff preprocessing to import-string.sh to enhance local testing * Restore Strings.bundle to default --------- Co-authored-by: Filippo <fzazzeroni@mozilla.com>
1 parent 50a0aef commit 5f17d34

File tree

4 files changed

+22
-30
lines changed

4 files changed

+22
-30
lines changed

.github/workflows/firefox-ios-import-strings.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
fi
6464
6565
- name: Run script to import strings
66-
run: sh ./bootstrap.sh --importLocales
66+
run: sh ./firefox-ios/import-strings.sh
6767

6868
- name: Update new strings
6969
run: |-

bootstrap.sh

-26
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,11 @@
66
# file, You can obtain one at http://mozilla.org/MPL/2.0/. */
77
#
88
# Use the --force option to force a re-build locales.
9-
# Use the --importLocales option to fetch and update locales only
10-
11-
getLocale() {
12-
echo "Getting locale..."
13-
rm -rf LocalizationTools
14-
git clone https://github.com/mozilla-mobile/LocalizationTools.git || exit 1
15-
16-
echo "Creating firefoxios-l10n Git repo"
17-
rm -rf firefoxios-l10n
18-
git clone --depth 1 https://github.com/mozilla-l10n/firefoxios-l10n firefoxios-l10n || exit 1
19-
}
209

2110
if [ "$1" == "--force" ]; then
22-
rm -rf firefoxios-l10n
23-
rm -rf LocalizationTools
2411
rm -rf build
2512
fi
2613

27-
if [ "$1" == "--importLocales" ]; then
28-
# Import locales
29-
if [ -d "/firefoxios-l10n" ] && [ -d "/LocalizationTools" ]; then
30-
echo "l10n directories found. Not downloading scripts."
31-
else
32-
echo "l10n directory not found. Downloading repo and scripts."
33-
getLocale
34-
fi
35-
36-
./firefox-ios/import-strings.sh
37-
exit 0
38-
fi
39-
4014
# Download the nimbus-fml.sh script from application-services.
4115
NIMBUS_FML_FILE=./firefox-ios/nimbus.fml.yaml
4216
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/mozilla/application-services/main/components/nimbus/ios/scripts/bootstrap.sh | bash -s -- --directory ./firefox-ios/bin $NIMBUS_FML_FILE

firefox-ios/Shared/Strings.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
// swiftlint:disable line_length
66
import Foundation
77

8+
// MARK: - Localization bundle setup
9+
class BundleClass {}
10+
811
public struct Strings {
9-
// This is a little workaround to get localizations
10-
// FXIOS-10838 will fix this by moving localizations or this struct into the appropriate place
11-
public static let bundle = Bundle(identifier: "org.mozilla.ios.Localizations") ?? .main
12+
public static let bundle = Bundle(for: BundleClass.self)
1213
}
1314

1415
// MARK: - Localization helper function

firefox-ios/import-strings.sh

+17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11

2+
echo "\n\n[*] Cloning required repo to import strings"
3+
4+
if [ -d "LocalizationTools" ] || [ -d "firefoxios-l10n" ]; then
5+
rm -rf LocalizationTools
6+
rm -rf firefoxios-l10n
7+
fi
8+
9+
git clone https://github.com/mozilla-mobile/LocalizationTools.git || exit 1
10+
git clone --depth 1 https://github.com/mozilla-l10n/firefoxios-l10n || exit 1
11+
12+
pip install -r firefoxios-l10n/.github/scripts/requirements.txt
13+
python3 firefoxios-l10n/.github/scripts/rewrite_original_attribute.py --path firefoxios-l10n
14+
215
echo "\n\n[*] Building tools/Localizations"
316
(cd LocalizationTools && swift build)
417

@@ -9,3 +22,7 @@ echo "\n\n[*] Importing Strings - takes a minute. (output in import-strings.log)
922
--l10n-project-path "$PWD/../firefoxios-l10n") > import-strings.log 2>&1
1023

1124
echo "\n\n[!] Strings have been imported. You can now create a PR."
25+
26+
echo "\n\n[*] Clean up cloned repos"
27+
rm -rf LocalizationTools
28+
rm -rf firefoxios-l10n

0 commit comments

Comments
 (0)