Skip to content

Commit

Permalink
Pontoon localization (#241)
Browse files Browse the repository at this point in the history
* Get building in Xcode 16.2

* Copy locales settings from ios-pontoon-test

* Add exported strings for all locales

* Fix nb naming

* Move locales to different repo

* Run initial import from l10n

(cd LocalizationTools &&swift run LocalizationTools --import --project-path ../giellakbd-ios/GiellaKeyboard.xcodeproj --l10n-project-path ../giellakbd-ios/locales)

* Split keyboard not supported message into two strings

* Consolidate strings into single Localizable.strings

These were previously separated by target; one for HostingApp and one for Keyboard. This doesn't play nice with Pontoon and doesn't add much for the added complexity.

* Update podfile.lock version

* Revert "Consolidate strings into single Localizable.strings"

This reverts commit 8575a7b.

* I hate that this is the fix for duplicate strings upon export to Pontoon

Turns out exporting strings will always add any discovered NSLocalizedStrings in code to the BaseKeyboard lproj, even if those strings are commented out in code, and even if a BaseKeyboard lproj doesn't exist. Since the Localizable.strings file is added to the Keyboard target, this means the export finds these strings twice: once for Keyboard and once for BaseKeyboard. The workaround is to add Localizable.strings to the BaseKeyboard target as well - then it considers the strings to only be a part of Keyboard, which results in no more duplicate strings showing up in Pontoon.

* Try again: consolidate strings into single Localizable.strings

* Revert "Try again: consolidate strings into single Localizable.strings"

This reverts commit c9820c4.

* Reapply "Try again: consolidate strings into single Localizable.strings"

This reverts commit 52ce46b.

* Revert "Get building in Xcode 16.2"

This reverts commit 9b4ade2.

* Add test workflow

* Do push-based sample gh-action instead

* First attempt at actual localization imports action

* Rename and try a push trigger

* Add temp logging

* Less verbose

* Attempt to fix path, remove logging

* Try only committing .lproj strings

* Update restore in case we ever need it

* Ignore import strings log
  • Loading branch information
dylanhand authored Feb 18, 2025
1 parent 915bdea commit 83df0c4
Show file tree
Hide file tree
Showing 24 changed files with 1,198 additions and 111 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/import-localizations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: "Import Localizations"
on:
# schedule:
# - cron: '0 11 * * 1'
push:
workflow_dispatch:
inputs:
branchName:
description: 'Branch used as target for automation'
required: true
default: 'main'
jobs:
build:
runs-on: macos-15
strategy:
max-parallel: 4
matrix:
xcode: ["16.2"]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.inputs.branchName }}

- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app

- name: Get PR info
run: |
current_date=$(date +"%Y-%m-%d")
# Use 'main' when triggered via cron
current_branch=${{ github.event.inputs.branchName || 'main' }}
echo "current_date=$current_date" >> $GITHUB_ENV
if [[ $current_branch == 'main' ]]; then
echo "branch_name=string-import-$current_date" >> $GITHUB_ENV
echo "pr_title=Import localizations $current_date" >> $GITHUB_ENV
echo "pr_body=This automated PR imports string changes" >> $GITHUB_ENV
else
# version: v105.0 -> v105
version=${current_branch%??}
echo "branch_name=string-import-$current_branch-$current_date" >> $GITHUB_ENV
echo "pr_title=[$version]: Import localizations $current_date" >> $GITHUB_ENV
echo "pr_body=This automated PR imports string changes into branch '$current_branch'" >> $GITHUB_ENV
fi
- name: Run script to import strings
run: |
echo "\n\n[*] Cloning required repo to import strings"
if [ -d "LocalizationTools" ] || [ -d "giellakbd-ios-l10n" ]; then
rm -rf LocalizationTools
rm -rf giellakbd-ios-l10n
fi
git clone --depth 1 https://github.com/divvun/LocalizationTools.git || exit 1
git clone --depth 1 https://github.com/divvun/giellakbd-ios-l10n || exit 1
echo "\n\n[*] Building tools/Localizations"
(cd LocalizationTools && swift build)
echo "\n\n[*] Importing Strings - takes a minute. (output in import-strings.log)"
(cd LocalizationTools && swift run LocalizationTools \
--import \
--project-path "$PWD/../GiellaKeyboard.xcodeproj" \
--l10n-project-path "$PWD/../giellakbd-ios-l10n") > import-strings.log 2>&1
echo "\n\n[!] Strings have been imported. You can now create a PR."
echo "\n\n[*] Clean up cloned repos"
rm -rf LocalizationTools
rm -rf giellakbd-ios-l10n
- name: Update new strings
run: |-
git diff || (git add HostingApp/*/*.lproj/* HostingApp/*.lproj/*)
# git restore GiellaKeyboard.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: ${{ env.pr_title }}
title: "Import Localizations ${{ env.current_date }}"
branch: ${{ env.branch_name }}
body: ${{ env.pr_body }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dicts.bundle
DerivedData/
Pods/
*.xcworkspace/
import-strings.log
26 changes: 4 additions & 22 deletions GiellaKeyboard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
999C30152428E70600E127A6 /* UpdateBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999C30142428E70600E127A6 /* UpdateBannerView.swift */; };
999C30172428E91000E127A6 /* BannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999C30162428E91000E127A6 /* BannerView.swift */; };
999C3019242A3FCF00E127A6 /* DownloadSimulator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999C3018242A3FCF00E127A6 /* DownloadSimulator.swift */; };
99B94C6323E0501F0076A786 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 99B94C6523E0501F0076A786 /* Localizable.strings */; };
99C12AE02D60C2C80096A499 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C655E85B1EC55D0800B12BE4 /* Localizable.strings */; };
99C12AE12D60C2C80096A499 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C655E85B1EC55D0800B12BE4 /* Localizable.strings */; };
99C4E5642431E89A005F8C8A /* PahkatWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99C4E5632431E89A005F8C8A /* PahkatWrapper.swift */; };
99C4E56724320F49005F8C8A /* IPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99C4E56524320CF0005F8C8A /* IPC.swift */; };
99C4E56824321740005F8C8A /* IPC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99C4E56524320CF0005F8C8A /* IPC.swift */; };
Expand Down Expand Up @@ -232,12 +233,6 @@
999C30142428E70600E127A6 /* UpdateBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateBannerView.swift; sourceTree = "<group>"; };
999C30162428E91000E127A6 /* BannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BannerView.swift; sourceTree = "<group>"; };
999C3018242A3FCF00E127A6 /* DownloadSimulator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadSimulator.swift; sourceTree = "<group>"; };
99B94C6423E0501F0076A786 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
99B94C6623E050280076A786 /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/Localizable.strings; sourceTree = "<group>"; };
99B94C6723E0502C0076A786 /* se */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = se; path = se.lproj/Localizable.strings; sourceTree = "<group>"; };
99B94C6823E0502C0076A786 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = "<group>"; };
99B94C6923E0502D0076A786 /* nn */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nn; path = nn.lproj/Localizable.strings; sourceTree = "<group>"; };
99B94C6A23E0502E0076A786 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = "<group>"; };
99C4E5632431E89A005F8C8A /* PahkatWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PahkatWrapper.swift; sourceTree = "<group>"; };
99C4E56524320CF0005F8C8A /* IPC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPC.swift; sourceTree = "<group>"; };
99DA18402408294A003E7353 /* WordContextTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordContextTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -471,7 +466,6 @@
isa = PBXGroup;
children = (
C6AEFD7B1EB0F5EA00316A2B /* Keyboard.entitlements */,
99B94C6523E0501F0076A786 /* Localizable.strings */,
4E807DBC19461DC700D875D1 /* Info.plist */,
C6D304A61BFD73750023EC5F /* Keyboard-Bridging-Header.h */,
9968D77D2BD684F900F7A4AC /* PrivacyInfo.xcprivacy */,
Expand Down Expand Up @@ -876,15 +870,16 @@
buildActionMask = 2147483647;
files = (
FD1387D7234CB95400C5B916 /* Images.xcassets in Resources */,
99C12AE12D60C2C80096A499 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FD1387DC234CBF2400C5B916 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
99B94C6323E0501F0076A786 /* Localizable.strings in Resources */,
FD1387DD234CBF2B00C5B916 /* Images.xcassets in Resources */,
99C12AE02D60C2C80096A499 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1166,19 +1161,6 @@
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
99B94C6523E0501F0076A786 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
99B94C6423E0501F0076A786 /* en */,
99B94C6623E050280076A786 /* fi */,
99B94C6723E0502C0076A786 /* se */,
99B94C6823E0502C0076A786 /* nb */,
99B94C6923E0502D0076A786 /* nn */,
99B94C6A23E0502E0076A786 /* sv */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
C655E85B1EC55D0800B12BE4 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
Expand Down
29 changes: 28 additions & 1 deletion HostingApp/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,31 @@
"userDefined" = "User-Defined";
"userDictionary" = "Your own words";
"whenYouHaveFinished" = "When you have finished, return to this app to continue.";
"word" = "Word";
"word" = "Word";

/* Spoken by VoiceOver when an element is selected */
"accessibility.space" = "space";

/* Spoken by VoiceOver when an element is selected */
"accessibility.backspace" = "delete";

/* Spoken by VoiceOver when an element is selected */
"accessibility.moreLetters" = "more: letters";

/* Spoken by VoiceOver when an element is selected */
"accessibility.moreNumbers" = "more: numbers";

/* Spoken by VoiceOver when an element is selected */
"accessibility.moreSymbols" = "more: symbols";

/* Spoken by VoiceOver when an element is selected */
"accessibility.shift" = "shift";

/* Spoken by VoiceOver when an element is selected */
"accessibility.nextKeyboard" = "next keyboard";

/* Shown inside the keyboard view when keyboard doesn't support current device */
"The %@ keyboard is currently not supported on this device." = "The %@ keyboard is currently not supported on this device.";

/* Shown inside the keyboard view when keyboard doesn't support current device */
"You can submit a request for support with one of the following options:" = "You can submit a request for support with one of the following options:";
105 changes: 102 additions & 3 deletions HostingApp/fi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,39 +1,138 @@
/* (No Comment) */
"about" = "Tietoja näppäimistösovelluksesta";

/* Spoken by VoiceOver when an element is selected */
"accessibility.backspace" = "askelpalautin";

/* Spoken by VoiceOver when an element is selected */
"accessibility.moreLetters" = "enemmän: kirjaimia";

/* Spoken by VoiceOver when an element is selected */
"accessibility.moreNumbers" = "enemmän: numeroita";

/* Spoken by VoiceOver when an element is selected */
"accessibility.moreSymbols" = "enemmän: symboleja";

/* Spoken by VoiceOver when an element is selected */
"accessibility.nextKeyboard" = "seuraava näppäimistö";

/* Spoken by VoiceOver when an element is selected */
"accessibility.shift" = "vaihto";

/* Spoken by VoiceOver when an element is selected */
"accessibility.space" = "väli";

/* (No Comment) */
"add" = "Lisää";

/* (No Comment) */
"addNewKeyboard" = "Lisää uusi näppäimistö…";

/* (No Comment) */
"addWord" = "Lisää sana";

/* (No Comment) */
"addWordMessage" = "Tätä sanaa ehdotetaan oikolukubannerissa samankaltaisille syötteille";

/* (No Comment) */
"allowFullAccess" = "Salli kaikki oikeudet";

/* (No Comment) */
"attributions" = "Attribuutiot";

/* (No Comment) */
"block" = "Estä";

/* (No Comment) */
"blocked" = "Estetyt sanat";

/* (No Comment) */
"cancel" = "Peru";

/* (No Comment) */
"contextsFor" = "Kontekstit sanalle \"%1$@\"";

/* (No Comment) */
"delete" = "Poista";

/* (No Comment) */
"detected" = "Tunnistetut sanat";

/* (No Comment) */
"downloading" = "Ladataan pakettia \"%1$@\"…";

/* (No Comment) */
"enableKeyboards" = "Enable the keyboards that you want to use.";

/* (No Comment) */
"enableTapSoundsPlain" = "Jos haluat näppäinäänet käyttöön, paina nappia %0$@ ja vaihda asetusta %1$@.";

/* (No Comment) */
"general" = "General";

/* (No Comment) */
"installingPackages" = "Asennetaan paketteja…";

/* (No Comment) */
"installingSpellers" = "Asennetaan oikaisulukimia…";

/* (No Comment) */
"keyboard" = "Näppäimistö";

/* (No Comment) */
"keyboards" = "Näppäimistöt";

/* (No Comment) */
"language" = "Appikieli";

/* (No Comment) */
"layouts" = "Asetelmat";

/* (No Comment) */
"localeSjd" = "Kiltinänsaame";

/* (No Comment) */
"noUserWords" = "Omia sanoja ei ole vielä.";

/* (No Comment) */
"noUserWordsDescription" = "Sanat joita oikoluku ei tunnista ja joita käytetään usein näkyvät täällä.";

/* (No Comment) */
"openAppPlain" = "Avaa sovellus %1$@";

/* (No Comment) */
"openSettings" = "Avaa asetukset";

/* (No Comment) */
"save" = "Tallenna";
"setUp" = "Aseta %1$@";
"settingUp" = "Asetetaan";

/* (No Comment) */
"settings" = "Asetukset";

/* (No Comment) */
"settingUp" = "Asetetaan";

/* (No Comment) */
"setUp" = "Aseta %1$@";

/* (No Comment) */
"skip" = "Ohita";

/* (No Comment) */
"tapPlain" = "Paina %1$@";

/* (No Comment) */
"unblock" = "Poista estot";

/* (No Comment) */
"userDefined" = "Omat sanat";

/* (No Comment) */
"userDictionary" = "Oma sanakirja";

/* (No Comment) */
"whenYouHaveFinished" = "Palaa takaisin tähän sovellukseen lopetettuasi.";
"word" = "Sana";

/* (No Comment) */
"word" = "Sana";

Loading

0 comments on commit 83df0c4

Please sign in to comment.