chore: update the i18n suggests

This commit is contained in:
sunxiaojian 2021-03-02 10:25:49 +08:00
parent 148a996129
commit f6d9b12722
6 changed files with 66 additions and 29 deletions

View File

@ -10,18 +10,20 @@
"reason": "reason"
},
"itemDetail": {
"emailInvalid": "It's not a valid e-mail address",
"usernameInvalid": "username only contains alphanumeric characters and underscores"
"email_invalid": "This is not a valid e-mail address",
"username_invalid": "Username must only contain alphanumeric characters and underscores",
"password_too_shrot": "password is too short (must be at least 8 characters)",
"username_too_long": "username is too long (can't be longer than 30 characters)"
},
"ERR_BLOCKED": "contains a disallowed e-mail provider",
"ERR_UNREACHABLE": "does not seem to exist",
"ERR_TAKEN": "is already in use",
"ERR_RESERVED": "is a reserved keyword or username",
"ERR_RESERVED": "is a reserved keyword",
"ERR_ACCEPTED": "must be accepted",
"ERR_BLANK": "is required",
"ERR_INVALID": "is invalid",
"ERR_TOO_LONG": "is too long ( can't be longer than 30 characters)",
"ERR_TOO_SHORT": "is too short (must be at least 8 characters)",
"ERR_TOO_LONG": "is too long",
"ERR_TOO_SHORT": "is too short",
"ERR_INCLUSION": "is not a supported value"
},
"alerts": {

View File

@ -55,7 +55,7 @@
2D61335825C188A000CAE157 /* APIService+Persist+Timeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D61335725C188A000CAE157 /* APIService+Persist+Timeline.swift */; };
2D61335E25C1894B00CAE157 /* APIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D61335D25C1894B00CAE157 /* APIService.swift */; };
2D61336925C18A4F00CAE157 /* AlamofireNetworkActivityIndicator in Frameworks */ = {isa = PBXBuildFile; productRef = 2D61336825C18A4F00CAE157 /* AlamofireNetworkActivityIndicator */; };
2D650FAB25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReson.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D650FAA25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReson.swift */; };
2D650FAB25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReason.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D650FAA25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReason.swift */; };
2D69CFF425CA9E2200C3A1B2 /* LoadMoreConfigurableTableViewContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D69CFF325CA9E2200C3A1B2 /* LoadMoreConfigurableTableViewContainer.swift */; };
2D69D00A25CAA00300C3A1B2 /* APIService+CoreData+Toot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D69D00925CAA00300C3A1B2 /* APIService+CoreData+Toot.swift */; };
2D76316525C14BD100929FB9 /* PublicTimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D76316425C14BD100929FB9 /* PublicTimelineViewController.swift */; };
@ -71,6 +71,7 @@
2D927F0825C7E9A8004F19B8 /* Tag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F0725C7E9A8004F19B8 /* Tag.swift */; };
2D927F0E25C7E9C9004F19B8 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F0D25C7E9C9004F19B8 /* History.swift */; };
2D927F1425C7EDD9004F19B8 /* Emoji.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D927F1325C7EDD9004F19B8 /* Emoji.swift */; };
2D939AB525EDD8A90076FA61 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D939AB425EDD8A90076FA61 /* String.swift */; };
2DA7D04425CA52B200804E11 /* TimelineLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D04325CA52B200804E11 /* TimelineLoaderTableViewCell.swift */; };
2DA7D04A25CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D04925CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift */; };
2DA7D05725CA693F00804E11 /* Application.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DA7D05625CA693F00804E11 /* Application.swift */; };
@ -261,7 +262,7 @@
2D5A3D6125CFD9CB002347D6 /* HomeTimelineViewController+DebugAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "HomeTimelineViewController+DebugAction.swift"; sourceTree = "<group>"; };
2D61335725C188A000CAE157 /* APIService+Persist+Timeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+Persist+Timeline.swift"; sourceTree = "<group>"; };
2D61335D25C1894B00CAE157 /* APIService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIService.swift; sourceTree = "<group>"; };
2D650FAA25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReson.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Mastodon+Entidy+ErrorDetailReson.swift"; sourceTree = "<group>"; };
2D650FAA25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReason.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Mastodon+Entidy+ErrorDetailReason.swift"; sourceTree = "<group>"; };
2D69CFF325CA9E2200C3A1B2 /* LoadMoreConfigurableTableViewContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadMoreConfigurableTableViewContainer.swift; sourceTree = "<group>"; };
2D69D00925CAA00300C3A1B2 /* APIService+CoreData+Toot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "APIService+CoreData+Toot.swift"; sourceTree = "<group>"; };
2D76316425C14BD100929FB9 /* PublicTimelineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublicTimelineViewController.swift; sourceTree = "<group>"; };
@ -277,6 +278,7 @@
2D927F0725C7E9A8004F19B8 /* Tag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tag.swift; sourceTree = "<group>"; };
2D927F0D25C7E9C9004F19B8 /* History.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = History.swift; sourceTree = "<group>"; };
2D927F1325C7EDD9004F19B8 /* Emoji.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Emoji.swift; sourceTree = "<group>"; };
2D939AB425EDD8A90076FA61 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
2DA7D04325CA52B200804E11 /* TimelineLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineLoaderTableViewCell.swift; sourceTree = "<group>"; };
2DA7D04925CA52CB00804E11 /* TimelineBottomLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineBottomLoaderTableViewCell.swift; sourceTree = "<group>"; };
2DA7D05025CA545E00804E11 /* LoadMoreConfigurableTableViewContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadMoreConfigurableTableViewContainer.swift; sourceTree = "<group>"; };
@ -1009,7 +1011,8 @@
DB45FAD625CA6C76005A8AC7 /* UIBarButtonItem.swift */,
2D32EAB925CB9B0500C9ED86 /* UIView.swift */,
0FAA101B25E10E760017CCDE /* UIFont.swift */,
2D650FAA25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReson.swift */,
2D650FAA25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReason.swift */,
2D939AB425EDD8A90076FA61 /* String.swift */,
);
path = Extension;
sourceTree = "<group>";
@ -1460,6 +1463,7 @@
DB45FAE325CA7181005A8AC7 /* MastodonUser.swift in Sources */,
DB0AC6FC25CD02E600D75117 /* APIService+Instance.swift in Sources */,
2D69D00A25CAA00300C3A1B2 /* APIService+CoreData+Toot.swift in Sources */,
2D939AB525EDD8A90076FA61 /* String.swift in Sources */,
0FAA101C25E10E760017CCDE /* UIFont.swift in Sources */,
2D38F1D525CD465300561493 /* HomeTimelineViewController.swift in Sources */,
DB98338825C945ED00AD9700 /* Assets.swift in Sources */,
@ -1505,7 +1509,7 @@
2D38F20825CD491300561493 /* DisposeBagCollectable.swift in Sources */,
DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */,
2D76319F25C1521200929FB9 /* StatusSection.swift in Sources */,
2D650FAB25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReson.swift in Sources */,
2D650FAB25ECDC9300851B58 /* Mastodon+Entidy+ErrorDetailReason.swift in Sources */,
DB118A8C25E4BFB500FAB162 /* HighlightDimmableButton.swift in Sources */,
DB084B5725CBC56C00F898ED /* Toot.swift in Sources */,
DB0140A825C40C1500F9F3CF /* MastodonPinBasedAuthenticationViewModelNavigationDelegateShim.swift in Sources */,

View File

@ -1,5 +1,5 @@
//
// Mastodon+Entidy+ErrorDetailReason.swift
// Mastodon+Entity+ErrorDetailReason.swift
// Mastodon
//
// Created by sxiaojian on 2021/3/1.
@ -41,9 +41,12 @@ extension Mastodon.Entity.ErrorDetail {
if let username = self.username, !username.isEmpty {
let errors = username.map { errorDetailReason -> String in
if errorDetailReason.error == .ERR_INVALID {
return L10n.Common.Errors.Itemdetail.usernameinvalid
} else {
switch errorDetailReason.error {
case .ERR_INVALID:
return L10n.Common.Errors.Itemdetail.usernameInvalid
case .ERR_TOO_LONG:
return L10n.Common.Errors.Itemdetail.usernameTooLong
default:
return L10n.Common.Errors.Item.username + " " + errorDetailReason.localizedDescription()
}
}
@ -53,7 +56,7 @@ extension Mastodon.Entity.ErrorDetail {
if let email = self.email, !email.isEmpty {
let errors = email.map { errorDetailReason -> String in
if errorDetailReason.error == .ERR_INVALID {
return L10n.Common.Errors.Itemdetail.emailinvalid
return L10n.Common.Errors.Itemdetail.emailInvalid
} else {
return L10n.Common.Errors.Item.email + " " + errorDetailReason.localizedDescription()
}
@ -61,8 +64,12 @@ extension Mastodon.Entity.ErrorDetail {
messages.append(contentsOf: errors)
}
if let password = self.password,!password.isEmpty {
let errors = password.map {
L10n.Common.Errors.Item.password + " " + $0.localizedDescription()
let errors = password.map { errorDetailReason -> String in
if errorDetailReason.error == .ERR_TOO_SHORT {
return L10n.Common.Errors.Itemdetail.passwordTooShrot
} else {
return L10n.Common.Errors.Item.password + " " + errorDetailReason.localizedDescription()
}
}
messages.append(contentsOf: errors)
}
@ -87,6 +94,6 @@ extension Mastodon.Entity.ErrorDetail {
let message = messages
.compactMap { $0 }
.joined(separator: ", ")
return message
return message.capitalizingFirstLetter()
}
}

View File

@ -0,0 +1,18 @@
//
// String.swift
// Mastodon
//
// Created by sxiaojian on 2021/3/2.
//
import Foundation
extension String {
func capitalizingFirstLetter() -> String {
return prefix(1).capitalized + dropFirst()
}
mutating func capitalizeFirstLetter() {
self = self.capitalizingFirstLetter()
}
}

View File

@ -93,13 +93,13 @@ internal enum L10n {
internal static let errInclusion = L10n.tr("Localizable", "Common.Errors.ErrInclusion")
/// is invalid
internal static let errInvalid = L10n.tr("Localizable", "Common.Errors.ErrInvalid")
/// is a reserved keyword or username
/// is a reserved keyword
internal static let errReserved = L10n.tr("Localizable", "Common.Errors.ErrReserved")
/// is already in use
internal static let errTaken = L10n.tr("Localizable", "Common.Errors.ErrTaken")
/// is too long ( can't be longer than 30 characters)
/// is too long
internal static let errTooLong = L10n.tr("Localizable", "Common.Errors.ErrTooLong")
/// is too short (must be at least 8 characters)
/// is too short
internal static let errTooShort = L10n.tr("Localizable", "Common.Errors.ErrTooShort")
/// does not seem to exist
internal static let errUnreachable = L10n.tr("Localizable", "Common.Errors.ErrUnreachable")
@ -118,10 +118,14 @@ internal enum L10n {
internal static let username = L10n.tr("Localizable", "Common.Errors.Item.Username")
}
internal enum Itemdetail {
/// It's not a valid e-mail address
internal static let emailinvalid = L10n.tr("Localizable", "Common.Errors.Itemdetail.Emailinvalid")
/// username only contains alphanumeric characters and underscores
internal static let usernameinvalid = L10n.tr("Localizable", "Common.Errors.Itemdetail.Usernameinvalid")
/// This is not a valid e-mail address
internal static let emailInvalid = L10n.tr("Localizable", "Common.Errors.Itemdetail.EmailInvalid")
/// password is too short (must be at least 8 characters)
internal static let passwordTooShrot = L10n.tr("Localizable", "Common.Errors.Itemdetail.PasswordTooShrot")
/// Username must only contain alphanumeric characters and underscores
internal static let usernameInvalid = L10n.tr("Localizable", "Common.Errors.Itemdetail.UsernameInvalid")
/// username is too long ( can't be longer than 30 characters)
internal static let usernameTooLong = L10n.tr("Localizable", "Common.Errors.Itemdetail.UsernameTooLong")
}
}
}

View File

@ -28,10 +28,10 @@
"Common.Errors.ErrBlocked" = "contains a disallowed e-mail provider";
"Common.Errors.ErrInclusion" = "is not a supported value";
"Common.Errors.ErrInvalid" = "is invalid";
"Common.Errors.ErrReserved" = "is a reserved keyword or username";
"Common.Errors.ErrReserved" = "is a reserved keyword";
"Common.Errors.ErrTaken" = "is already in use";
"Common.Errors.ErrTooLong" = "is too long ( can't be longer than 30 characters)";
"Common.Errors.ErrTooShort" = "is too short (must be at least 8 characters)";
"Common.Errors.ErrTooLong" = "is too long";
"Common.Errors.ErrTooShort" = "is too short";
"Common.Errors.ErrUnreachable" = "does not seem to exist";
"Common.Errors.Item.Agreement" = "agreement";
"Common.Errors.Item.Email" = "email";
@ -39,8 +39,10 @@
"Common.Errors.Item.Password" = "password";
"Common.Errors.Item.Reason" = "reason";
"Common.Errors.Item.Username" = "username";
"Common.Errors.Itemdetail.Emailinvalid" = "It's not a valid e-mail address";
"Common.Errors.Itemdetail.Usernameinvalid" = "username only contains alphanumeric characters and underscores";
"Common.Errors.Itemdetail.EmailInvalid" = "This is not a valid e-mail address";
"Common.Errors.Itemdetail.PasswordTooShrot" = "password is too short (must be at least 8 characters)";
"Common.Errors.Itemdetail.UsernameInvalid" = "Username must only contain alphanumeric characters and underscores";
"Common.Errors.Itemdetail.UsernameTooLong" = "username is too long ( can't be longer than 30 characters)";
"Scene.ConfirmEmail.Button.DontReceiveEmail" = "I never got an email";
"Scene.ConfirmEmail.Button.OpenEmailApp" = "Open Email App";
"Scene.ConfirmEmail.DontReceiveEmail.Description" = "Check if your email address is correct as well as your junk folder if you havent.";