Skip to content

Commit

Permalink
- remove unused .github/workflows.inactive/normalizestrings.yml
Browse files Browse the repository at this point in the history
- ocstringstool: update to normalize xcstrings
- ownCloudSDK.xcodeproj: remove normalization step
- pull-transifex.yml: integrate updated ocstringstool
  • Loading branch information
felix-schwarz committed Dec 5, 2024
1 parent 44cd4b3 commit 54017be
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 55 deletions.
28 changes: 0 additions & 28 deletions .github/workflows.inactive/normalizestrings.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/pull-transifex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ jobs:
beautifyJSON "ownCloudSDK/Resources/Localizable.xcstrings"
beautifyJSON "ownCloudUI/Resources/Localizable.xcstrings"
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y clang libpython2.7 libpython2.7-dev

- name: Download Swift
run: wget https://download.swift.org/swift-6.0.2-release/ubuntu2004/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE-ubuntu20.04.tar.gz

- name: Extract Swift
run: tar xzf swift-6.0.2-RELEASE-ubuntu20.04.tar.gz

- name: Move Swift to /usr/share
run: sudo mv swift-6.0.2-RELEASE-ubuntu20.04 /usr/share/swift

- name: Add Swift to PATH
run: echo "export PATH=/usr/share/swift/usr/bin:\$PATH" >> $GITHUB_ENV

- name: Verify Swift installation
run: swift -v

- name: Show Swift file
run: cat tools/ocstringstool/ocstringstool/main.swift

- name: Compile Swift file
run: swiftc tools/ocstringstool/ocstringstool/main.swift -o ocstringstool

- name: Run compiled Swift program
run: ./ocstringstool normalize "ownCloudSDK/Resources" "ownCloudUI/Resources"

- name: Cleanup download and ocstringstool
run: |
rm swift-*-ubuntu20.04.tar.gz
rm ocstringstool
- uses: GuillaumeFalourd/[email protected]
with:
email: [email protected]
Expand Down
21 changes: 0 additions & 21 deletions ownCloudSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4902,7 +4902,6 @@
DCC8F9A8202852A200EB6701 /* Headers */,
DCC8F9A9202852A200EB6701 /* Resources */,
DC102FAD22D3E0F300DEBC38 /* Update LastGitCommit key in Info.plist */,
DC86F8572CF345AA00D757DA /* Normalize xcstrings files */,
);
buildRules = (
);
Expand Down Expand Up @@ -5113,26 +5112,6 @@
shellPath = /bin/sh;
shellScript = "LASTGITCOMMIT=$(git rev-parse --short HEAD)\ndefaults write \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}\" \"LastGitCommit\" \"${LASTGITCOMMIT}\"\n\nGITTAGS=$(git describe --tags)\ndefaults write \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}\" \"GitTags\" \"${GITTAGS}\"\n\nGITBRANCH=$(git branch --show-current)\ndefaults write \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH%.*}\" \"GitBranch\" \"${GITBRANCH}\"\n";
};
DC86F8572CF345AA00D757DA /* Normalize xcstrings files */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"$(SRCROOT)/ownCloudSDK/Resources/Localizable.xcstrings",
"$(SRCROOT)/ownCloudUI/Resources/Localizable.xcstrings",
);
name = "Normalize xcstrings files";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "if ! command -v jq 2>&1 >/dev/null\nthen\n echo \"jq could not be found\"\n exit 0\nfi\n\nbeautifyJSON() {\n jq --sort-keys 'walk(if type == \"object\" then del(.\"th_TH\", .\"pt_PT\", .\"pt_BR\", .\"nn_NO\", .\"nb_NO\", .\"en_GB\") else . end)' $1 >$1.tmp\n mv $1.tmp $1\n}\nbeautifyJSON \"ownCloudSDK/Resources/Localizable.xcstrings\"\nbeautifyJSON \"ownCloudUI/Resources/Localizable.xcstrings\"\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
25 changes: 19 additions & 6 deletions tools/ocstringstool/ocstringstool/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,25 @@ func commandNormalize(rootPath locRootPath: String) {

var encoding: String.Encoding = .utf8

if !isDirectory, fileName.hasSuffix(".strings"),
let strings = try? String(contentsOf: fileURL, usedEncoding: &encoding), encoding != .utf8 {
print("[normalize] converting \(fileURL.path(percentEncoded: false)) to UTF-8…")
if let utf8Data = strings.data(using: .utf8, allowLossyConversion: false) {
try? utf8Data.write(to: fileURL)
convertedFilesCount += 1
if !isDirectory {
if fileName.hasSuffix(".strings"),
let strings = try? String(contentsOf: fileURL, usedEncoding: &encoding), encoding != .utf8 {
print("[normalize] converting \(fileURL.absoluteString) to UTF-8…")
if let utf8Data = strings.data(using: .utf8, allowLossyConversion: false) {
try? utf8Data.write(to: fileURL)
convertedFilesCount += 1
}
}

if fileName.hasSuffix(".xcstrings"),
let data = try? Data(contentsOf: fileURL),
let jsonObj = try? JSONSerialization.jsonObject(with: data) {
print("[normalize] normalizing \(fileURL.absoluteString) to AppleJSON[sortedKeys,prettyPrinted,withoutEscapingSlashes]…")

if let reformattedJSONData = try? JSONSerialization.data(withJSONObject: jsonObj, options: [.sortedKeys, .prettyPrinted, .withoutEscapingSlashes]) {
try? reformattedJSONData.write(to: fileURL)
convertedFilesCount += 1
}
}
}
}
Expand Down

0 comments on commit 54017be

Please sign in to comment.