-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add LocalizationTests with automatic UTF-16 to UTF-8 conversion
- Loading branch information
1 parent
c41b0cc
commit 0a47517
Showing
8 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
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,27 @@ | ||
name: Localizable.strings to UTF8 | ||
# This workflow is triggered on pushes to the repository. | ||
on: | ||
push: | ||
branches: | ||
- fix/* | ||
- feature/* | ||
- milestone/* | ||
|
||
jobs: | ||
build: | ||
runs-on: macos-latest | ||
name: Localizable.strings to UTF8 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- name: Xcode version | ||
run: /usr/bin/xcodebuild -version | ||
- name: Run Localizations To UTF8 | ||
run: ./localizations_to_utf8.sh | ||
working-directory: ./tools/LocalizationsToUTF8/ | ||
- name: Commit files | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: converted Localizable.strings to UTF8 | ||
file_pattern: '*.strings' |
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
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict/> | ||
<dict> | ||
<key>server-locator.use</key> | ||
<string>web-finger</string> | ||
</dict> | ||
</plist> |
Binary file not shown.
Binary file not shown.
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,46 @@ | ||
// | ||
// LocalizationTests.swift | ||
// ownCloudTests | ||
// | ||
// Created by Felix Schwarz on 23.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 XCTest | ||
|
||
final class LocalizationTests: XCTestCase { | ||
func testConvertLocalizableUTF16() throws { | ||
if let locRootPath = ProcessInfo.processInfo.environment["OC_LOCALIZATION_ROOT"] { | ||
let locRootURL = NSURL(fileURLWithPath: 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 { | ||
if let utf8Data = strings.data(using: .utf8, allowLossyConversion: false) { | ||
try? utf8Data.write(to: fileURL) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,8 @@ | ||
#!/bin/bash | ||
|
||
# Run test to convert the app's Localizable.strings to UTF-8 where needed | ||
xcodebuild test \ | ||
-project ../../ownCloud.xcodeproj \ | ||
-scheme ownCloud \ | ||
-destination 'platform=iOS Simulator,name=iPhone 14,OS=latest' \ | ||
-only-testing ownCloudTests/LocalizationTests/testConvertLocalizableUTF16 |