vector-im/element-ios/issues/4899 - Replaced (*almost*) all NSLocalizedString calls with newly generated ObjC methods.

This commit is contained in:
Stefan Ceriu
2021-09-28 08:40:01 +03:00
committed by Stefan Ceriu
parent 83db774313
commit 04bc95a85c
77 changed files with 1099 additions and 1108 deletions
@@ -356,8 +356,6 @@
[self.mxRoom state:^(MXRoomState *roomState) {
MXStrongifyAndReturnIfNil(self);
NSString *powerLevelTextFormat;
MXRoomPowerLevels *powerLevels = [roomState powerLevels];
NSInteger powerLevel = [powerLevels powerLevelOfUserWithUserID:self.mxRoomMember.userId];
@@ -365,26 +363,18 @@
switch (roomPowerLevel) {
case RoomPowerLevelAdmin:
powerLevelTextFormat = NSLocalizedStringFromTable(@"room_member_power_level_admin_in", @"Vector", nil);
self.roomMemberPowerLevelLabel.text = [VectorL10n roomMemberPowerLevelAdminIn:self.mxRoom.summary.displayname];
self.roomMemberPowerLevelContainerView.hidden = NO;
break;
case RoomPowerLevelModerator:
powerLevelTextFormat = NSLocalizedStringFromTable(@"room_member_power_level_moderator_in", @"Vector", nil);
self.roomMemberPowerLevelLabel.text = [VectorL10n roomMemberPowerLevelModeratorIn:self.mxRoom.summary.displayname];
self.roomMemberPowerLevelContainerView.hidden = NO;
break;
default:
powerLevelTextFormat = nil;
self.roomMemberPowerLevelLabel.text = nil;
self.roomMemberPowerLevelContainerView.hidden = YES;
break;
}
NSString *powerLevelText;
if (powerLevelTextFormat)
{
NSString *roomName = self.mxRoom.summary.displayname;
powerLevelText = [NSString stringWithFormat:powerLevelTextFormat, roomName];
}
self.roomMemberPowerLevelLabel.text = powerLevelText;
self.roomMemberPowerLevelContainerView.hidden = !powerLevelTextFormat;
}];
NSString* presenceText;
@@ -727,23 +717,23 @@
{
if (section == securityIndex)
{
return NSLocalizedStringFromTable(@"room_participants_action_section_security", @"Vector", nil);
return [VectorL10n roomParticipantsActionSectionSecurity];
}
else if (section == adminToolsIndex)
{
return NSLocalizedStringFromTable(@"room_participants_action_section_admin_tools", @"Vector", nil);
return [VectorL10n roomParticipantsActionSectionAdminTools];
}
else if (section == otherActionsIndex)
{
return NSLocalizedStringFromTable(@"room_participants_action_section_other", @"Vector", nil);
return [VectorL10n roomParticipantsActionSectionOther];
}
else if (section == directChatsIndex)
{
return NSLocalizedStringFromTable(@"room_participants_action_section_direct_chats", @"Vector", nil);
return [VectorL10n roomParticipantsActionSectionDirectChats];
}
else if (section == devicesIndex)
{
return NSLocalizedStringFromTable(@"room_participants_action_section_devices", @"Vector", nil);
return [VectorL10n roomParticipantsActionSectionDevices];
}
return nil;
@@ -756,60 +746,60 @@
switch (action)
{
case MXKRoomMemberDetailsActionInvite:
title = NSLocalizedStringFromTable(@"room_participants_action_invite", @"Vector", nil);
title = [VectorL10n roomParticipantsActionInvite];
break;
case MXKRoomMemberDetailsActionLeave:
title = NSLocalizedStringFromTable(@"room_participants_action_leave", @"Vector", nil);
title = [VectorL10n roomParticipantsActionLeave];
break;
case MXKRoomMemberDetailsActionKick:
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
title = NSLocalizedStringFromTable(@"space_participants_action_remove", @"Vector", nil);
title = [VectorL10n spaceParticipantsActionRemove];
}
else
{
title = NSLocalizedStringFromTable(@"room_participants_action_remove", @"Vector", nil);
title = [VectorL10n roomParticipantsActionRemove];
}
break;
case MXKRoomMemberDetailsActionBan:
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
title = NSLocalizedStringFromTable(@"space_participants_action_ban", @"Vector", nil);
title = [VectorL10n spaceParticipantsActionBan];
}
else
{
title = NSLocalizedStringFromTable(@"room_participants_action_ban", @"Vector", nil);
title = [VectorL10n roomParticipantsActionBan];
}
break;
case MXKRoomMemberDetailsActionUnban:
title = NSLocalizedStringFromTable(@"room_participants_action_unban", @"Vector", nil);
title = [VectorL10n roomParticipantsActionUnban];
break;
case MXKRoomMemberDetailsActionIgnore:
title = NSLocalizedStringFromTable(@"room_participants_action_ignore", @"Vector", nil);
title = [VectorL10n roomParticipantsActionIgnore];
break;
case MXKRoomMemberDetailsActionUnignore:
title = NSLocalizedStringFromTable(@"room_participants_action_unignore", @"Vector", nil);
title = [VectorL10n roomParticipantsActionUnignore];
break;
case MXKRoomMemberDetailsActionSetDefaultPowerLevel:
title = NSLocalizedStringFromTable(@"room_participants_action_set_default_power_level", @"Vector", nil);
title = [VectorL10n roomParticipantsActionSetDefaultPowerLevel];
break;
case MXKRoomMemberDetailsActionSetModerator:
title = NSLocalizedStringFromTable(@"room_participants_action_set_moderator", @"Vector", nil);
title = [VectorL10n roomParticipantsActionSetModerator];
break;
case MXKRoomMemberDetailsActionSetAdmin:
title = NSLocalizedStringFromTable(@"room_participants_action_set_admin", @"Vector", nil);
title = [VectorL10n roomParticipantsActionSetAdmin];
break;
case MXKRoomMemberDetailsActionStartChat:
title = NSLocalizedStringFromTable(@"room_participants_action_start_chat", @"Vector", nil);
title = [VectorL10n roomParticipantsActionStartNewChat];
break;
case MXKRoomMemberDetailsActionStartVoiceCall:
title = NSLocalizedStringFromTable(@"room_participants_action_start_voice_call", @"Vector", nil);
title = [VectorL10n roomParticipantsActionStartVoiceCall];
break;
case MXKRoomMemberDetailsActionStartVideoCall:
title = NSLocalizedStringFromTable(@"room_participants_action_start_video_call", @"Vector", nil);
title = [VectorL10n roomParticipantsActionStartVideoCall];
break;
case MXKRoomMemberDetailsActionMention:
title = NSLocalizedStringFromTable(@"room_participants_action_mention", @"Vector", nil);
title = [VectorL10n roomParticipantsActionMention];
break;
default:
break;
@@ -834,26 +824,26 @@
switch (self.encryptionTrustLevel) {
case UserEncryptionTrustLevelTrusted:
statusText = NSLocalizedStringFromTable(@"room_participants_action_security_status_verified", @"Vector", nil);
statusText = [VectorL10n roomParticipantsActionSecurityStatusVerified];
break;
case UserEncryptionTrustLevelNotVerified:
case UserEncryptionTrustLevelNoCrossSigning:
{
if (self.isRoomMemberCurrentUser)
{
statusText = NSLocalizedStringFromTable(@"room_participants_action_security_status_complete_security", @"Vector", nil);
statusText = [VectorL10n roomParticipantsActionSecurityStatusCompleteSecurity];
}
else
{
statusText = NSLocalizedStringFromTable(@"room_participants_action_security_status_verify", @"Vector", nil);
statusText = [VectorL10n roomParticipantsActionSecurityStatusVerify];
}
}
break;
case UserEncryptionTrustLevelWarning:
statusText = NSLocalizedStringFromTable(@"room_participants_action_security_status_warning", @"Vector", nil);
statusText = [VectorL10n roomParticipantsActionSecurityStatusWarning];
break;
default:
statusText = NSLocalizedStringFromTable(@"room_participants_action_security_status_loading", @"Vector", nil);
statusText = [VectorL10n roomParticipantsActionSecurityStatusLoading];
break;
}
@@ -884,16 +874,16 @@
case UserEncryptionTrustLevelTrusted:
{
NSString *info = (self.mxRoom.isDirect) ?
NSLocalizedStringFromTable(@"room_participants_security_information_room_encrypted_for_dm", @"Vector", nil) :
NSLocalizedStringFromTable(@"room_participants_security_information_room_encrypted", @"Vector", nil);
[VectorL10n roomParticipantsSecurityInformationRoomEncryptedForDm] :
[VectorL10n roomParticipantsSecurityInformationRoomEncrypted];
[encryptionInformation appendString:info];
}
break;
case UserEncryptionTrustLevelNone:
{
NSString *info = (self.mxRoom.isDirect) ?
NSLocalizedStringFromTable(@"room_participants_security_information_room_not_encrypted_for_dm", @"Vector", nil) :
NSLocalizedStringFromTable(@"room_participants_security_information_room_not_encrypted", @"Vector", nil);
[VectorL10n roomParticipantsSecurityInformationRoomNotEncryptedForDm] :
[VectorL10n roomParticipantsSecurityInformationRoomNotEncrypted];
[encryptionInformation appendString:info];
}
break;
@@ -984,7 +974,7 @@
roomCell.avatarImageView.image = [UIImage imageNamed:@"start_chat"];
roomCell.avatarImageView.defaultBackgroundColor = [UIColor clearColor];
roomCell.avatarImageView.userInteractionEnabled = NO;
roomCell.titleLabel.text = NSLocalizedStringFromTable(@"room_participants_action_start_new_chat", @"Vector", nil);
roomCell.titleLabel.text = [VectorL10n roomParticipantsActionStartNewChat];
}
cell = roomCell;
@@ -1132,7 +1122,7 @@
__weak typeof(self) weakSelf = self;
// Ban
currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_event_action_ban_prompt_reason", @"Vector", nil)
currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionBanPromptReason]
message:nil
preferredStyle:UIAlertControllerStyleAlert];
@@ -1142,7 +1132,7 @@
textField.keyboardType = UIKeyboardTypeDefault;
}];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -1196,7 +1186,7 @@
__weak typeof(self) weakSelf = self;
// Kick
currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_event_action_kick_prompt_reason", @"Vector", nil)
currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionKickPromptReason]
message:nil
preferredStyle:UIAlertControllerStyleAlert];
@@ -1206,7 +1196,7 @@
textField.keyboardType = UIKeyboardTypeDefault;
}];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -1218,7 +1208,7 @@
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"remove", @"Vector", nil)
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n remove]
style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
if (weakSelf)
@@ -1288,7 +1278,7 @@
__block MXKImageView * avatarFullScreenView = [[MXKImageView alloc] initWithFrame:CGRectZero];
avatarFullScreenView.stretchable = YES;
[avatarFullScreenView setRightButtonTitle:[NSBundle mxk_localizedStringForKey:@"ok"]
[avatarFullScreenView setRightButtonTitle:[MatrixKitL10n ok]
handler:^(MXKImageView* imageView, NSString* buttonTitle) {
MXStrongifyAndReturnIfNil(self);
@@ -112,19 +112,19 @@
[NSLayoutConstraint activateConstraints:@[_searchBarTopConstraint]];
self.navigationItem.title = NSLocalizedStringFromTable(@"room_participants_title", @"Vector", nil);
self.navigationItem.title = [VectorL10n roomParticipantsTitle];
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
_searchBarView.placeholder = NSLocalizedStringFromTable(@"search_default_placeholder", @"Vector", nil);
_searchBarView.placeholder = [VectorL10n searchDefaultPlaceholder];
}
else if (self.mxRoom.isDirect)
{
_searchBarView.placeholder = NSLocalizedStringFromTable(@"room_participants_filter_room_members_for_dm", @"Vector", nil);
_searchBarView.placeholder = [VectorL10n roomParticipantsFilterRoomMembersForDm];
}
else
{
_searchBarView.placeholder = NSLocalizedStringFromTable(@"room_participants_filter_room_members", @"Vector", nil);
_searchBarView.placeholder = [VectorL10n roomParticipantsFilterRoomMembers];
}
_searchBarView.returnKeyType = UIReturnKeyDone;
_searchBarView.autocapitalizationType = UITextAutocapitalizationTypeNone;
@@ -347,15 +347,15 @@
if (self.mxRoom.summary.roomType == MXRoomTypeSpace)
{
self.searchBarView.placeholder = NSLocalizedStringFromTable(@"search_default_placeholder", @"Vector", nil);
self.searchBarView.placeholder = [VectorL10n searchDefaultPlaceholder];
}
else if (self.mxRoom.isDirect)
{
self.searchBarView.placeholder = NSLocalizedStringFromTable(@"room_participants_filter_room_members_for_dm", @"Vector", nil);
self.searchBarView.placeholder = [VectorL10n roomParticipantsFilterRoomMembersForDm];
}
else
{
self.searchBarView.placeholder = NSLocalizedStringFromTable(@"room_participants_filter_room_members", @"Vector", nil);
self.searchBarView.placeholder = [VectorL10n roomParticipantsFilterRoomMembers];
}
// Update the current matrix session.
@@ -574,7 +574,7 @@
}
[contactsPickerViewController showSearch:YES];
contactsPickerViewController.searchBar.placeholder = NSLocalizedStringFromTable(@"room_participants_invite_another_user", @"Vector", nil);
contactsPickerViewController.searchBar.placeholder = [VectorL10n roomParticipantsInviteAnotherUser];
// Apply the search pattern if any
if (currentSearchText)
@@ -613,7 +613,7 @@
if (mxMember.membership == MXMembershipJoin || mxMember.membership == MXMembershipInvite)
{
// The user is in this room
NSString *displayName = NSLocalizedStringFromTable(@"you", @"Vector", nil);
NSString *displayName = [VectorL10n you];
self->userParticipant = [[Contact alloc] initMatrixContactWithDisplayName:displayName andMatrixID:userId];
self->userParticipant.mxMember = [roomState.members memberWithUserId:userId];
@@ -1038,10 +1038,10 @@
switch (roomPowerLevel) {
case RoomPowerLevelAdmin:
powerLevelText = NSLocalizedStringFromTable(@"room_member_power_level_short_admin", @"Vector", nil);
powerLevelText = [VectorL10n roomMemberPowerLevelShortAdmin];
break;
case RoomPowerLevelModerator:
powerLevelText = NSLocalizedStringFromTable(@"room_member_power_level_short_moderator", @"Vector", nil);
powerLevelText = [VectorL10n roomMemberPowerLevelShortModerator];
break;
default:
powerLevelText = nil;
@@ -1139,7 +1139,7 @@
headerLabel.font = [UIFont boldSystemFontOfSize:15.0];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.text = NSLocalizedStringFromTable(@"room_participants_invited_section", @"Vector", nil);
headerLabel.text = [VectorL10n roomParticipantsInvitedSection];
[sectionHeader addSubview:headerLabel];
}
@@ -1290,20 +1290,20 @@
NSString *title, *message;
if (self.mxRoom.isDirect)
{
title = NSLocalizedStringFromTable(@"room_participants_leave_prompt_title_for_dm", @"Vector", nil);
message = NSLocalizedStringFromTable(@"room_participants_leave_prompt_msg_for_dm", @"Vector", nil);
title = [VectorL10n roomParticipantsLeavePromptTitleForDm];
message = [VectorL10n roomParticipantsLeavePromptMsgForDm];
}
else
{
title = NSLocalizedStringFromTable(@"room_participants_leave_prompt_title", @"Vector", nil);
message = NSLocalizedStringFromTable(@"room_participants_leave_prompt_msg", @"Vector", nil);
title = [VectorL10n roomParticipantsLeavePromptTitle];
message = [VectorL10n roomParticipantsLeavePromptMsg];
}
currentAlert = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1312,7 +1312,7 @@
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"leave", @"Vector", nil)
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n leave]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -1383,12 +1383,12 @@
NSString *memberUserId = contact.mxMember.userId;
// Kick ?
NSString *promptMsg = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_participants_remove_prompt_msg", @"Vector", nil), (contact ? contact.displayName : memberUserId)];
currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_participants_remove_prompt_title", @"Vector", nil)
NSString *promptMsg = [VectorL10n roomParticipantsRemovePromptMsg:(contact ? contact.displayName : memberUserId)];
currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomParticipantsRemovePromptTitle]
message:promptMsg
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1397,7 +1397,7 @@
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"remove", @"Vector", nil)
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n remove]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -1434,10 +1434,10 @@
{
// This is a third-party invite
currentAlert = [UIAlertController alertControllerWithTitle:nil
message:NSLocalizedStringFromTable(@"room_participants_remove_third_party_invite_prompt_msg", @"Vector", nil)
message:[VectorL10n roomParticipantsRemoveThirdPartyInvitePromptMsg]
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1446,7 +1446,7 @@
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"remove", @"Vector", nil)
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n remove]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -1504,12 +1504,12 @@
}
// Invite ?
NSString *promptMsg = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_participants_invite_prompt_msg", @"Vector", nil), contact.displayName];
currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_participants_invite_prompt_title", @"Vector", nil)
NSString *promptMsg = [VectorL10n roomParticipantsInvitePromptMsg:contact.displayName];
currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomParticipantsInvitePromptTitle]
message:promptMsg
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1521,7 +1521,7 @@
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"invite", @"Vector", nil)
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n invite]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -1595,7 +1595,7 @@
if ([error.domain isEqualToString:kMXRestClientErrorDomain]
&& error.code == MXRestClientErrorMissingIdentityServer)
{
NSString *message = [NSBundle mxk_localizedStringForKey:@"error_invite_3pid_with_no_identity_server"];
NSString *message = [VectorL10n errorInvite3pidWithNoIdentityServer];
[[AppDelegate theDelegate] showAlertWithTitle:message message:nil];
}
else