Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ swift build -Xswiftc -strict-concurrency=complete -Xswiftc -warnings-as-errors
- Do not commit local build output, `.dmg` files, `.worktrees/`, `.build/`, API keys, tokens, or personal configuration.
- Update documentation when changing install, setup, provider, or release behavior.
- Use English for documentation and project-facing prose.
- Interface text lives in `Sources/InkletApp/Localization/`, one file per language. Add each new key to every language file; `scripts/check-localization.sh` fails when a table is missing a key.

## Distribution And Release Changes

Expand Down
3,151 changes: 1 addition & 3,150 deletions Sources/InkletApp/InkletLocalization.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+de.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+en.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+es.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+fr.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+it.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+ja.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+ko.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+pt.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+zhHans.swift

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions Sources/InkletApp/Localization/L10n+zhHant.swift

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions Tests/InkletCoreTests/LegacyMigrationLocalizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ final class LegacyMigrationLocalizationTests: XCTestCase {
}

private func parsedLanguageTables() throws -> [String: [LocalizationEntry]] {
let packageRoot = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
let localizationURL = packageRoot.appendingPathComponent("Sources/InkletApp/InkletLocalization.swift")
let source = try String(contentsOf: localizationURL, encoding: .utf8)
let source = try LocalizationSourceFixture.source()
return try Dictionary(uniqueKeysWithValues: languageTables.map { language in
(language.symbol, try migrationEntries(in: language.symbol, source: source))
})
Expand All @@ -277,7 +275,7 @@ final class LegacyMigrationLocalizationTests: XCTestCase {
}

private func migrationEntries(in table: String, source: String) throws -> [LocalizationEntry] {
let startMarker = "private static let \(table): [String: String] = ["
let startMarker = " static let \(table): [String: String] = ["
let startRange = try XCTUnwrap(source.range(of: startMarker), "Missing \(table) localization table")
let remainder = source[startRange.upperBound...]
let endRange = try XCTUnwrap(remainder.range(of: "\n ]"), "Unterminated \(table) localization table")
Expand Down
15 changes: 15 additions & 0 deletions Tests/InkletCoreTests/LocalizationSourceFixture.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

/// Source text of the localization layer: `InkletLocalization.swift` followed by
/// every language table under `Localization/`, in `L10n.translationTables` order.
enum LocalizationSourceFixture {
static let tableIDs = ["en", "zhHans", "zhHant", "ja", "ko", "es", "fr", "de", "pt", "it"]

static func source() throws -> String {
let appSources = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
.appendingPathComponent("Sources/InkletApp")
let files = [appSources.appendingPathComponent("InkletLocalization.swift")]
+ tableIDs.map { appSources.appendingPathComponent("Localization/L10n+\($0).swift") }
return try files.map { try String(contentsOf: $0, encoding: .utf8) }.joined(separator: "\n")
}
}
4 changes: 1 addition & 3 deletions Tests/InkletCoreTests/SettingsViewSourceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ final class SettingsViewSourceTests: XCTestCase {
}

func testTemperatureLocalizationKeysAreRemoved() throws {
let packageRoot = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
let sourceURL = packageRoot.appendingPathComponent("Sources/InkletApp/InkletLocalization.swift")
let source = try String(contentsOf: sourceURL, encoding: .utf8)
let source = try LocalizationSourceFixture.source()

XCTAssertFalse(source.contains("settings.row.temperature"))
XCTAssertFalse(source.contains("settings.help.temperature"))
Expand Down
8 changes: 3 additions & 5 deletions Tests/InkletCoreTests/UpdateCheckLocalizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,19 @@ final class UpdateCheckLocalizationTests: XCTestCase {
}

private func localizationSource() throws -> String {
let path = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
.appendingPathComponent("Sources/InkletApp/InkletLocalization.swift")
return try String(contentsOf: path, encoding: .utf8)
try LocalizationSourceFixture.source()
}

private func localizationTableIDs(in source: String) throws -> [String] {
let regex = try NSRegularExpression(pattern: #"^[ \t]*private[ \t]+static[ \t]+let[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*\[String:[ \t]*String\][ \t]*=[ \t]*\["#, options: .anchorsMatchLines)
let regex = try NSRegularExpression(pattern: #"^[ \t]*static[ \t]+let[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*\[String:[ \t]*String\][ \t]*=[ \t]*\["#, options: .anchorsMatchLines)
let range = NSRange(source.startIndex..<source.endIndex, in: source)
return regex.matches(in: source, range: range).compactMap {
Range($0.range(at: 1), in: source).map { String(source[$0]) }
}
}

private func localizationTableSource(_ tableID: String, in source: String) throws -> String {
let declaration = " private static let \(tableID): [String: String] = ["
let declaration = " static let \(tableID): [String: String] = ["
let start = try XCTUnwrap(source.range(of: declaration)).upperBound
let end = try XCTUnwrap(source.range(of: "\n ]", range: start..<source.endIndex)).lowerBound
return String(source[start..<end])
Expand Down
8 changes: 2 additions & 6 deletions Tests/InkletCoreTests/VoiceSettingsLocalizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import XCTest

final class VoiceSettingsLocalizationTests: XCTestCase {
func testHoldOnlyDictationKeepsCurrentShortcutAndLegacyHistoryLocalization() throws {
let packageRoot = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
let localizationURL = packageRoot.appendingPathComponent("Sources/InkletApp/InkletLocalization.swift")
let source = try String(contentsOf: localizationURL, encoding: .utf8)
let source = try LocalizationSourceFixture.source()

XCTAssertEqual(countDictionaryEntries("settings.quickStart.voice.pressAndHold", in: source), 10)
XCTAssertEqual(countDictionaryEntries("settings.history.source.voice", in: source), 10)
Expand All @@ -15,9 +13,7 @@ final class VoiceSettingsLocalizationTests: XCTestCase {
}

func testForceSelectionModeCopyExistsInAllLanguageTables() throws {
let packageRoot = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
let localizationURL = packageRoot.appendingPathComponent("Sources/InkletApp/InkletLocalization.swift")
let source = try String(contentsOf: localizationURL, encoding: .utf8)
let source = try LocalizationSourceFixture.source()

XCTAssertTrue(source.contains(#""settings.row.forceSelectionMode": "Force Selection""#))
XCTAssertTrue(source.contains(
Expand Down
6 changes: 3 additions & 3 deletions Tests/InkletCoreTests/WritingDictationLocalizationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ final class WritingDictationLocalizationTests: XCTestCase {
}

private func localizationSource() throws -> String {
try sourceFile("Sources/InkletApp/InkletLocalization.swift")
try LocalizationSourceFixture.source()
}

private func sourceFile(_ relativePath: String) throws -> String {
Expand All @@ -243,7 +243,7 @@ final class WritingDictationLocalizationTests: XCTestCase {

private func localizationTableIDs(in source: String) throws -> [String] {
let regex = try NSRegularExpression(
pattern: #"^[ \t]*private[ \t]+static[ \t]+let[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*\[String:[ \t]*String\][ \t]*=[ \t]*\["#,
pattern: #"^[ \t]*static[ \t]+let[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*\[String:[ \t]*String\][ \t]*=[ \t]*\["#,
options: .anchorsMatchLines
)
let sourceRange = NSRange(source.startIndex..<source.endIndex, in: source)
Expand All @@ -254,7 +254,7 @@ final class WritingDictationLocalizationTests: XCTestCase {
}

private func localizationTableSource(_ tableID: String, in source: String) throws -> String {
let declaration = " private static let \(tableID): [String: String] = ["
let declaration = " static let \(tableID): [String: String] = ["
let declarationRange = try XCTUnwrap(
source.range(of: declaration),
"Missing localization table declaration for \(tableID)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,12 @@ final class WritingModeLauncherLocalizationTests: XCTestCase {
}

private func localizationSource() throws -> String {
let packageRoot = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
let localizationURL = packageRoot.appendingPathComponent("Sources/InkletApp/InkletLocalization.swift")
return try String(contentsOf: localizationURL, encoding: .utf8)
try LocalizationSourceFixture.source()
}

private func localizationTableIDs(in source: String) throws -> [String] {
let regex = try NSRegularExpression(
pattern: #"^[ \t]*private[ \t]+static[ \t]+let[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*\[String:[ \t]*String\][ \t]*=[ \t]*\["#,
pattern: #"^[ \t]*static[ \t]+let[ \t]+([A-Za-z_][A-Za-z0-9_]*):[ \t]*\[String:[ \t]*String\][ \t]*=[ \t]*\["#,
options: .anchorsMatchLines
)
let sourceRange = NSRange(source.startIndex..<source.endIndex, in: source)
Expand All @@ -234,7 +232,7 @@ final class WritingModeLauncherLocalizationTests: XCTestCase {
}

private func localizationTableSource(_ tableID: String, in source: String) throws -> String {
let declaration = " private static let \(tableID): [String: String] = ["
let declaration = " static let \(tableID): [String: String] = ["
let declarationRange = try XCTUnwrap(
source.range(of: declaration),
"Missing localization table declaration for \(tableID)"
Expand Down
Loading