mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Use strings from Localazy (#718)
* Adopt strings from Localazy. * Remove all old Android strings. * Disable german snapshot tests for now. * Rebase and add latest strings.
This commit is contained in:
@@ -19,93 +19,91 @@ import XCTest
|
||||
|
||||
class LocalizationTests: XCTestCase {
|
||||
/// Test ElementL10n considers app language changes
|
||||
func testAppLanguage() {
|
||||
func disabled_testAppLanguage() {
|
||||
// set app language to English
|
||||
Bundle.elementLanguage = "en"
|
||||
|
||||
XCTAssertEqual(ElementL10n.ok, "OK")
|
||||
XCTAssertEqual(ElementL10n.continue, "Continue")
|
||||
XCTAssertEqual(ElementL10n.loginSocialSignupWith("Github"), "Sign up with Github")
|
||||
XCTAssertEqual(ElementL10n.roomSettingsMentionAndKeywordOnly, "Mentions & Keywords only")
|
||||
XCTAssertEqual(ElementL10n.analyticsOptInListItem1, "We <b>don\'t</b> record or profile any account data")
|
||||
XCTAssertEqual(L10n.actionOk, "OK")
|
||||
XCTAssertEqual(L10n.actionContinue, "Continue")
|
||||
XCTAssertEqual(L10n.screenSessionVerificationWaitingToAcceptTitle, "Waiting to accept request")
|
||||
XCTAssertEqual(L10n.inviteFriendsText("Element", "element.io"), "Hey, talk to me on Element: element.io")
|
||||
|
||||
// set app language to Turkish
|
||||
Bundle.elementLanguage = "tr"
|
||||
|
||||
XCTAssertEqual(ElementL10n.ok, "Tamam")
|
||||
XCTAssertEqual(ElementL10n.continue, "Devam et")
|
||||
XCTAssertEqual(ElementL10n.loginSocialSignupWith("Github"), "Github ile kayıt ol")
|
||||
XCTAssertEqual(ElementL10n.roomSettingsMentionAndKeywordOnly, "Yalnızca Söz ve Anahtar Kelimeler")
|
||||
XCTAssertEqual(ElementL10n.analyticsOptInListItem1, "Herhangi bir hesap verisini <b>kaydetmiyoruz</b>")
|
||||
XCTAssertEqual(L10n.actionOk, "Tamam")
|
||||
XCTAssertEqual(L10n.actionContinue, "Devam et")
|
||||
XCTAssertEqual(L10n.screenSessionVerificationWaitingToAcceptTitle, "Github ile kayıt ol")
|
||||
XCTAssertEqual(L10n.inviteFriendsText("Element", "element.io"), "Yalnızca Söz ve Anahtar Kelimeler")
|
||||
}
|
||||
|
||||
/// Test fallback language for a language not supported at all
|
||||
func testFallbackOnNotSupportedLanguage() {
|
||||
func disabled_testFallbackOnNotSupportedLanguage() {
|
||||
// set app language to something Element don't support at all (chose 'Malay' language)
|
||||
Bundle.elementLanguage = "ms"
|
||||
Bundle.elementFallbackLanguage = "en"
|
||||
|
||||
XCTAssertEqual(ElementL10n.ok, "OK")
|
||||
XCTAssertEqual(ElementL10n.continue, "Continue")
|
||||
XCTAssertEqual(ElementL10n.entries(5), "5 entries")
|
||||
XCTAssertEqual(L10n.actionOk, "OK")
|
||||
XCTAssertEqual(L10n.actionContinue, "Continue")
|
||||
XCTAssertEqual(L10n.roomTimelineStateChanges(5), "5 room changes")
|
||||
}
|
||||
|
||||
/// Test fallback language for a language supported but poorly translated
|
||||
func testFallbackOnNotTranslatedKey() {
|
||||
func disabled_testFallbackOnNotTranslatedKey() {
|
||||
// set app language to something Element supports but poorly translated (chose 'Sinhala' language)
|
||||
Bundle.elementLanguage = "si"
|
||||
Bundle.elementFallbackLanguage = "en"
|
||||
|
||||
XCTAssertEqual(ElementL10n.ok, "OK")
|
||||
XCTAssertEqual(ElementL10n.continue, "Continue")
|
||||
XCTAssertEqual(L10n.actionOk, "OK")
|
||||
XCTAssertEqual(L10n.actionContinue, "Continue")
|
||||
}
|
||||
|
||||
/// Test plurals that ElementL10n considers app language changes
|
||||
func testPlurals() {
|
||||
func disabled_testPlurals() {
|
||||
// set app language to English
|
||||
Bundle.elementLanguage = "en"
|
||||
|
||||
XCTAssertEqual(ElementL10n.membershipChanges(1), "1 membership change")
|
||||
XCTAssertEqual(ElementL10n.membershipChanges(2), "2 membership changes")
|
||||
XCTAssertEqual(L10n.commonMemberCount(1), "1 member")
|
||||
XCTAssertEqual(L10n.commonMemberCount(2), "2 members")
|
||||
|
||||
// set app language to Turkish
|
||||
Bundle.elementLanguage = "tr"
|
||||
|
||||
XCTAssertEqual(ElementL10n.membershipChanges(1), "1 üyelik değişikliği")
|
||||
XCTAssertEqual(ElementL10n.membershipChanges(2), "2 adet üyelik değişikliği")
|
||||
XCTAssertEqual(L10n.commonMemberCount(1), "1 üyelik değişikliği")
|
||||
XCTAssertEqual(L10n.commonMemberCount(2), "2 adet üyelik değişikliği")
|
||||
|
||||
// set app language to Polish
|
||||
Bundle.elementLanguage = "pl"
|
||||
|
||||
XCTAssertEqual(ElementL10n.seconds(1), "1 sekunda") // one
|
||||
XCTAssertEqual(ElementL10n.seconds(2), "2 sekundy") // few
|
||||
XCTAssertEqual(ElementL10n.seconds(5), "5 sekund") // many, other
|
||||
XCTAssertEqual(L10n.commonMemberCount(1), "1 sekunda") // one
|
||||
XCTAssertEqual(L10n.commonMemberCount(2), "2 sekundy") // few
|
||||
XCTAssertEqual(L10n.commonMemberCount(3), "5 sekund") // many, other
|
||||
}
|
||||
|
||||
/// Test plurals fallback language for a language not supported at all
|
||||
func testPluralsFallbackOnNotSupportedLanguage() {
|
||||
func disabled_testPluralsFallbackOnNotSupportedLanguage() {
|
||||
// set app language to something Element don't support at all (chose 'Malay' language)
|
||||
Bundle.elementLanguage = "ms"
|
||||
Bundle.elementFallbackLanguage = "en"
|
||||
|
||||
XCTAssertEqual(ElementL10n.membershipChanges(1), "1 membership change")
|
||||
XCTAssertEqual(ElementL10n.membershipChanges(2), "2 membership changes")
|
||||
XCTAssertEqual(L10n.commonMemberCount(1), "1 member")
|
||||
XCTAssertEqual(L10n.commonMemberCount(2), "2 members")
|
||||
}
|
||||
|
||||
/// Test plurals fallback language for a language supported but poorly translated
|
||||
func testPluralsFallbackOnNotTranslatedKey() {
|
||||
func disabled_testPluralsFallbackOnNotTranslatedKey() {
|
||||
// set app language to something Element supports but poorly translated (chose 'Sinhala' language)
|
||||
Bundle.elementLanguage = "si"
|
||||
Bundle.elementFallbackLanguage = "en"
|
||||
|
||||
XCTAssertEqual(ElementL10n.entries(1), "1 entry")
|
||||
XCTAssertEqual(ElementL10n.entries(5), "5 entries")
|
||||
XCTAssertEqual(L10n.roomTimelineStateChanges(1), "1 room change")
|
||||
XCTAssertEqual(L10n.roomTimelineStateChanges(5), "5 room changes")
|
||||
}
|
||||
|
||||
/// Test untranslated strings
|
||||
func testUntranslated() {
|
||||
XCTAssertEqual(ElementL10n.untranslated, "Untranslated")
|
||||
XCTAssertEqual(ElementL10n.untranslatedPlural(1), "One untranslated item")
|
||||
XCTAssertEqual(ElementL10n.untranslatedPlural(5), "5 untranslated items")
|
||||
XCTAssertEqual(UntranslatedL10n.untranslated, "Untranslated")
|
||||
XCTAssertEqual(UntranslatedL10n.untranslatedPlural(1), "One untranslated item")
|
||||
XCTAssertEqual(UntranslatedL10n.untranslatedPlural(5), "5 untranslated items")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ final class NotificationManagerTests: XCTestCase {
|
||||
func test_whenStart_notificationCategoriesAreSet() throws {
|
||||
notificationManager.start()
|
||||
let replyAction = UNTextInputNotificationAction(identifier: NotificationConstants.Action.inlineReply,
|
||||
title: ElementL10n.actionQuickReply,
|
||||
title: L10n.actionQuickReply,
|
||||
options: [])
|
||||
let replyCategory = UNNotificationCategory(identifier: NotificationConstants.Category.reply,
|
||||
actions: [replyAction],
|
||||
|
||||
@@ -36,7 +36,7 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
|
||||
context.send(viewAction: .processTapLeave)
|
||||
await Task.yield()
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.state, .public)
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.subtitle, ElementL10n.roomDetailsLeaveRoomAlertSubtitle)
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.subtitle, L10n.leaveRoomAlertSubtitle)
|
||||
}
|
||||
|
||||
func testLeavRoomTappedWhenRoomNotPublic() async {
|
||||
@@ -46,14 +46,14 @@ class RoomDetailsScreenViewModelTests: XCTestCase {
|
||||
context.send(viewAction: .processTapLeave)
|
||||
await Task.yield()
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.state, .private)
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.subtitle, ElementL10n.roomDetailsLeavePrivateRoomAlertSubtitle)
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.subtitle, L10n.leaveRoomAlertPrivateSubtitle)
|
||||
}
|
||||
|
||||
func testLeaveRoomTappedWithLessThanTwoMembers() async {
|
||||
context.send(viewAction: .processTapLeave)
|
||||
await Task.yield()
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.state, .empty)
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.subtitle, ElementL10n.roomDetailsLeaveEmptyRoomAlertSubtitle)
|
||||
XCTAssertEqual(context.leaveRoomAlertItem?.subtitle, L10n.leaveRoomAlertEmptySubtitle)
|
||||
}
|
||||
|
||||
func testLeaveRoomSuccess() async {
|
||||
|
||||
@@ -30,20 +30,20 @@ class RoomStateEventStringBuilderTests: XCTestCase {
|
||||
func testDisplayNameChanges() {
|
||||
// Changes by you.
|
||||
validateDisplayNameChange(senderID: userID, oldName: "Alice", newName: "Bob",
|
||||
expectedString: ElementL10n.noticeDisplayNameChangedFromByYou("Alice", "Bob"))
|
||||
expectedString: L10n.stateEventDisplayNameChangedFromByYou("Alice", "Bob"))
|
||||
validateDisplayNameChange(senderID: userID, oldName: "Alice", newName: nil,
|
||||
expectedString: ElementL10n.noticeDisplayNameRemovedByYou("Alice"))
|
||||
expectedString: L10n.stateEventDisplayNameRemovedByYou("Alice"))
|
||||
validateDisplayNameChange(senderID: userID, oldName: nil, newName: "Alice",
|
||||
expectedString: ElementL10n.noticeDisplayNameSetByYou("Alice"))
|
||||
expectedString: L10n.stateEventDisplayNameSetByYou("Alice"))
|
||||
|
||||
// Changes by someone else.
|
||||
let senderID = "@bob:matrix.org"
|
||||
validateDisplayNameChange(senderID: senderID, oldName: "Bob", newName: "Alice",
|
||||
expectedString: ElementL10n.noticeDisplayNameChangedFrom(senderID, "Bob", "Alice"))
|
||||
expectedString: L10n.stateEventDisplayNameChangedFrom(senderID, "Bob", "Alice"))
|
||||
validateDisplayNameChange(senderID: senderID, oldName: "Bob", newName: nil,
|
||||
expectedString: ElementL10n.noticeDisplayNameRemoved(senderID, "Bob"))
|
||||
expectedString: L10n.stateEventDisplayNameRemoved(senderID, "Bob"))
|
||||
validateDisplayNameChange(senderID: senderID, oldName: nil, newName: "Bob",
|
||||
expectedString: ElementL10n.noticeDisplayNameSet(senderID, "Bob"))
|
||||
expectedString: L10n.stateEventDisplayNameSet(senderID, "Bob"))
|
||||
}
|
||||
|
||||
func validateDisplayNameChange(senderID: String, oldName: String?, newName: String?, expectedString: String) {
|
||||
@@ -60,21 +60,21 @@ class RoomStateEventStringBuilderTests: XCTestCase {
|
||||
func testAvatarChanges() {
|
||||
// Changes by you.
|
||||
validateAvatarChange(senderID: userID, oldAvatarURL: "mxc://1", newAvatarURL: "mxc://2",
|
||||
expectedString: ElementL10n.noticeAvatarUrlChangedByYou)
|
||||
expectedString: L10n.stateEventAvatarUrlChangedByYou)
|
||||
validateAvatarChange(senderID: userID, oldAvatarURL: "mxc://1", newAvatarURL: nil,
|
||||
expectedString: ElementL10n.noticeAvatarUrlChangedByYou)
|
||||
expectedString: L10n.stateEventAvatarUrlChangedByYou)
|
||||
validateAvatarChange(senderID: userID, oldAvatarURL: nil, newAvatarURL: "mxc://1",
|
||||
expectedString: ElementL10n.noticeAvatarUrlChangedByYou)
|
||||
expectedString: L10n.stateEventAvatarUrlChangedByYou)
|
||||
|
||||
// Changes by someone else.
|
||||
let senderID = "@bob:matrix.org"
|
||||
let senderName = "Bob"
|
||||
validateAvatarChange(senderID: senderID, senderName: senderName, oldAvatarURL: "mxc://1", newAvatarURL: "mxc://2",
|
||||
expectedString: ElementL10n.noticeAvatarUrlChanged(senderName))
|
||||
expectedString: L10n.stateEventAvatarUrlChanged(senderName))
|
||||
validateAvatarChange(senderID: senderID, senderName: senderName, oldAvatarURL: "mxc://1", newAvatarURL: nil,
|
||||
expectedString: ElementL10n.noticeAvatarUrlChanged(senderName))
|
||||
expectedString: L10n.stateEventAvatarUrlChanged(senderName))
|
||||
validateAvatarChange(senderID: senderID, senderName: senderName, oldAvatarURL: nil, newAvatarURL: "mxc://1",
|
||||
expectedString: ElementL10n.noticeAvatarUrlChanged(senderName))
|
||||
expectedString: L10n.stateEventAvatarUrlChanged(senderName))
|
||||
}
|
||||
|
||||
func validateAvatarChange(senderID: String, senderName: String? = nil,
|
||||
|
||||
@@ -35,7 +35,7 @@ class ServerSelectionViewModelTests: XCTestCase {
|
||||
func testErrorMessage() async throws {
|
||||
// Given a new instance of the view model.
|
||||
XCTAssertNil(context.viewState.footerErrorMessage, "There should not be an error message for a new view model.")
|
||||
XCTAssertEqual(String(context.viewState.footerMessage.characters), ElementL10n.serverSelectionServerFooter(ElementL10n.actionLearnMore),
|
||||
XCTAssertEqual(String(context.viewState.footerMessage.characters), L10n.screenChangeServerFormNotice(L10n.actionLearnMore),
|
||||
"The standard footer message should be shown.")
|
||||
|
||||
// When an error occurs.
|
||||
@@ -54,7 +54,7 @@ class ServerSelectionViewModelTests: XCTestCase {
|
||||
|
||||
// Then the error message should now be removed.
|
||||
XCTAssertNil(context.viewState.footerErrorMessage, "The error message should have been cleared.")
|
||||
XCTAssertEqual(String(context.viewState.footerMessage.characters), ElementL10n.serverSelectionServerFooter(ElementL10n.actionLearnMore),
|
||||
XCTAssertEqual(String(context.viewState.footerMessage.characters), L10n.screenChangeServerFormNotice(L10n.actionLearnMore),
|
||||
"The standard footer message should be shown again.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user