-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created new Transifex Github action to automatically push and pull translations and normalise UTF-16 to UTF-8 strings.
- Loading branch information
Showing
6 changed files
with
200 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /bin/bash | ||
|
||
image="$1" | ||
shift | ||
|
||
commands="$@" | ||
|
||
if [[ "$image" == "" ]] || [[ "${commands[@]}" == "" ]]; then | ||
echo "Usage: bash $0 <image> <commands>" | ||
exit 1 | ||
fi | ||
|
||
set -exo pipefail | ||
|
||
extra_args=() | ||
|
||
if tty -s; then | ||
extra_args+=("-t") | ||
fi | ||
|
||
docker run \ | ||
--rm \ | ||
--user "$(id -u)" \ | ||
-i "${extra_args[@]}" \ | ||
-e TX_TOKEN \ | ||
-e HOME \ | ||
-v "$HOME:$HOME" \ | ||
-v "$(readlink -f .)":/ws \ | ||
--entrypoint sh \ | ||
-w /ws \ | ||
"$image" \ | ||
-c "${commands[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: "Update translations" | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 3 * * *" | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: {} | ||
|
||
defaults: | ||
run: | ||
shell: pwsh | ||
|
||
jobs: | ||
update-translations: | ||
permissions: | ||
contents: write # for git push | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
TX_TOKEN: ${{ secrets.TX_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
ref: ${{ github.ref }} | ||
|
||
- name: l10n-push | ||
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | ||
# we need to use a different docker image for those two, this appears to be a bit tricky with github actions out of the box | ||
run: bash .github/workflows/run-in-docker.sh owncloudci/transifex:latest "cd ownCloud/Resources/en.lproj && tx push -s --skip" | ||
|
||
- name: l10n-pull | ||
run: bash .github/workflows/run-in-docker.sh owncloudci/transifex:latest "cd ownCloud/Resources/ && tx pull --force --skip --all" | ||
|
||
- 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://swift.org/builds/swift-5.3-release/ubuntu2004/swift-5.3-RELEASE/swift-5.3-RELEASE-ubuntu20.04.tar.gz | ||
|
||
- name: Extract Swift | ||
run: tar xzf swift-5.3-RELEASE-ubuntu20.04.tar.gz | ||
|
||
- name: Move Swift to /usr/share | ||
run: sudo mv swift-5.3-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: Compile Swift file | ||
run: swiftc tools/normalizestrings/main.swift -o ocstringstool | ||
|
||
- name: Run compiled Swift program | ||
run: ./ocstringstool normalize ownCloud/Resources/ | ||
|
||
- name: update-repo-before-commit | ||
run: | | ||
git status | ||
git add ownCloud/Resources/*.strings | ||
git status | ||
git stash | ||
git pull --ff-only origin | ||
- name: commit and push | ||
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | ||
run: | | ||
install -d -m 0700 ~/.ssh | ||
Set-Content -Value "${{ secrets.DEPLOYMENT_SSH_KEY }}" -Path ~/.ssh/id_ed25519 | ||
chmod 0600 ~/.ssh/id_ed25519 | ||
if(git stash list) { | ||
git stash pop | ||
install -d -m 0700 ~/.ssh | ||
Set-Content -Value "${{ secrets.DEPLOYMENT_SSH_KEY }}" -Path ~/.ssh/id_ed25519 | ||
chmod 0600 ~/.ssh/id_ed25519 | ||
git config user.name "ownClouders" | ||
git config user.email "[email protected]" | ||
git add translations/ | ||
git commit -m "[tx] updated client translations from transifex [skip ci]" | ||
git push [email protected]:owncloud/ios-app.git | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// main.swift | ||
// ocstringstool | ||
// | ||
// Created by Felix Schwarz on 24.08.23. | ||
// Copyright © 2023 ownCloud GmbH. All rights reserved. | ||
// | ||
|
||
/* | ||
* Copyright (C) 2023, ownCloud GmbH. | ||
* | ||
* This code is covered by the GNU Public License Version 3. | ||
* | ||
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/ | ||
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>. | ||
* | ||
*/ | ||
|
||
import Foundation | ||
|
||
// MARK: - Types | ||
enum Command: String { | ||
case normalize | ||
} | ||
|
||
// MARK: - Parsing | ||
if CommandLine.argc < 3 { | ||
print("ocstringstool normalize [base folder 1] …") | ||
exit(0) | ||
} | ||
|
||
let arguments = CommandLine.arguments | ||
let command = Command(rawValue: arguments[1]) | ||
var argIdx = 2 | ||
|
||
switch command { | ||
case .normalize: | ||
while argIdx < CommandLine.argc { | ||
let rootPath = arguments[argIdx] | ||
commandNormalize(rootPath: rootPath) | ||
argIdx += 1 | ||
} | ||
|
||
default: | ||
print("Unknown command \(command?.rawValue ?? "")") | ||
exit(-1) | ||
} | ||
|
||
// MARK: - Commands | ||
func commandNormalize(rootPath locRootPath: String) { | ||
let locRootURL = NSURL(fileURLWithPath: locRootPath) | ||
var convertedFilesCount = 0 | ||
|
||
print("[normalize] scanning \(locRootURL.path ?? locRootPath)") | ||
|
||
if let enumerator = FileManager.default.enumerator(at: locRootURL as URL, includingPropertiesForKeys: [ .isDirectoryKey, .nameKey ]) { | ||
for case let fileURL as URL in enumerator { | ||
guard let resourceValues = try? fileURL.resourceValues(forKeys: [.isDirectoryKey, .nameKey]), | ||
let isDirectory = resourceValues.isDirectory, | ||
let fileName = resourceValues.name | ||
else { | ||
continue | ||
} | ||
|
||
var encoding: String.Encoding = .utf8 | ||
|
||
if !isDirectory, 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 | ||
} | ||
} | ||
} | ||
} | ||
|
||
print("[normalize] converted \(convertedFilesCount) files in \(locRootURL.path ?? locRootPath)") | ||
} |
This file was deleted.
Oops, something went wrong.