Fix localization issues and export strings for translation
Changelog-Fixed: Fix localization issues and export strings for translation Signed-off-by: Terry Yiu <git@tyiu.xyz> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// CustomZapViewTests.swift
|
||||
// damusTests
|
||||
//
|
||||
// Created by Terry Yiu on 4/29/23.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import damus
|
||||
|
||||
final class CustomZapViewTests: XCTestCase {
|
||||
|
||||
let enUsLocale = Locale(identifier: "en-US")
|
||||
|
||||
override func setUpWithError() throws {
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
func testSatsString() throws {
|
||||
XCTAssertEqual(satsString(0, locale: enUsLocale), "sats")
|
||||
XCTAssertEqual(satsString(1, locale: enUsLocale), "sat")
|
||||
XCTAssertEqual(satsString(2, locale: enUsLocale), "sats")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(satsString(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// EventDetailBarTests.swift
|
||||
// damusTests
|
||||
//
|
||||
// Created by Terry Yiu on 2/24/23.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import damus
|
||||
|
||||
final class EventDetailBarTests: XCTestCase {
|
||||
|
||||
let enUsLocale = Locale(identifier: "en-US")
|
||||
|
||||
override func setUpWithError() throws {
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
func testRepostsCountString() throws {
|
||||
XCTAssertEqual(repostsCountString(0, locale: enUsLocale), "Reposts")
|
||||
XCTAssertEqual(repostsCountString(1, locale: enUsLocale), "Repost")
|
||||
XCTAssertEqual(repostsCountString(2, locale: enUsLocale), "Reposts")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(repostsCountString(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testReactionsCountString() throws {
|
||||
XCTAssertEqual(reactionsCountString(0, locale: enUsLocale), "Reactions")
|
||||
XCTAssertEqual(reactionsCountString(1, locale: enUsLocale), "Reaction")
|
||||
XCTAssertEqual(reactionsCountString(2, locale: enUsLocale), "Reactions")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(reactionsCountString(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testZapssCountString() throws {
|
||||
XCTAssertEqual(zapsCountString(0, locale: enUsLocale), "Zaps")
|
||||
XCTAssertEqual(zapsCountString(1, locale: enUsLocale), "Zap")
|
||||
XCTAssertEqual(zapsCountString(2, locale: enUsLocale), "Zaps")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(zapsCountString(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
41
damusTests/LocalizationUtilTests.swift
Normal file
41
damusTests/LocalizationUtilTests.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// LocalizationUtilTests.swift
|
||||
// damusTests
|
||||
//
|
||||
// Created by Terry Yiu on 7/13/23.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import damus
|
||||
|
||||
final class LocalizationUtilTests: XCTestCase {
|
||||
|
||||
func testPluralizedString() throws {
|
||||
let enUsLocale = Locale(identifier: "en-US")
|
||||
|
||||
// Test cases of the localization string key, and the expected en-US strings for a count of 0, 1, and 2.
|
||||
let keys = [
|
||||
["followers_count", "Followers", "Follower", "Followers"],
|
||||
["following_count", "Following", "Following", "Following"],
|
||||
["imports_count", "Imports", "Import", "Imports"],
|
||||
["reactions_count", "Reactions", "Reaction", "Reactions"],
|
||||
["relays_count", "Relays", "Relay", "Relays"],
|
||||
["reposts_count", "Reposts", "Repost", "Reposts"],
|
||||
["sats", "sats", "sat", "sats"],
|
||||
["zaps_count", "Zaps", "Zap", "Zaps"],
|
||||
["word_count", "0 Words", "1 Word", "2 Words"]
|
||||
]
|
||||
|
||||
for key in keys {
|
||||
XCTAssertEqual(pluralizedString(key: key[0], count: 0, locale: enUsLocale), key[1])
|
||||
XCTAssertEqual(pluralizedString(key: key[0], count: 1, locale: enUsLocale), key[2])
|
||||
XCTAssertEqual(pluralizedString(key: key[0], count: 2, locale: enUsLocale), key[3])
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(pluralizedString(key: key[0], count: count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -105,18 +105,6 @@ final class NostrScriptTests: XCTestCase {
|
||||
self.wait(for: [resume_expected], timeout: 10.0)
|
||||
}
|
||||
|
||||
func test_imports_string() throws {
|
||||
let enUsLocale = Locale(identifier: "en-US")
|
||||
XCTAssertEqual(imports_string(0, locale: enUsLocale), "Imports")
|
||||
XCTAssertEqual(imports_string(1, locale: enUsLocale), "Import")
|
||||
XCTAssertEqual(imports_string(2, locale: enUsLocale), "Imports")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(imports_string(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testPerformanceExample() throws {
|
||||
// This is an example of a performance test case.
|
||||
self.measure {
|
||||
|
||||
@@ -20,39 +20,6 @@ final class ProfileViewTests: XCTestCase {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
func testFollowersCountString() throws {
|
||||
XCTAssertEqual(followersCountString(0, locale: enUsLocale), "Followers")
|
||||
XCTAssertEqual(followersCountString(1, locale: enUsLocale), "Follower")
|
||||
XCTAssertEqual(followersCountString(2, locale: enUsLocale), "Followers")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(followersCountString(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testFollowingCountString() throws {
|
||||
XCTAssertEqual(followingCountString(0, locale: enUsLocale), "Following")
|
||||
XCTAssertEqual(followingCountString(1, locale: enUsLocale), "Following")
|
||||
XCTAssertEqual(followingCountString(2, locale: enUsLocale), "Following")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(followingCountString(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testRelaysCountString() throws {
|
||||
XCTAssertEqual(relaysCountString(0, locale: enUsLocale), "Relays")
|
||||
XCTAssertEqual(relaysCountString(1, locale: enUsLocale), "Relay")
|
||||
XCTAssertEqual(relaysCountString(2, locale: enUsLocale), "Relays")
|
||||
Bundle.main.localizations.map { Locale(identifier: $0) }.forEach {
|
||||
for count in 1...10 {
|
||||
XCTAssertNoThrow(relaysCountString(count, locale: $0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testFollowedByString() throws {
|
||||
let profiles = test_damus_state().profiles
|
||||
|
||||
|
||||
Reference in New Issue
Block a user