Localize Microsoft/Mojang authentication error messages (#331)

* Move Microsoft/Mojang error message to lang file.

* Add mstfLogin to language file
This commit is contained in:
Kamesuta 2024-02-23 01:23:23 +09:00 committed by GitHub
parent 95eebc18a7
commit fc4823a01f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 159 additions and 2 deletions

View File

@ -12,12 +12,122 @@
const ConfigManager = require('./configmanager') const ConfigManager = require('./configmanager')
const { LoggerUtil } = require('helios-core') const { LoggerUtil } = require('helios-core')
const { RestResponseStatus } = require('helios-core/common') const { RestResponseStatus } = require('helios-core/common')
const { MojangRestAPI, mojangErrorDisplayable, MojangErrorCode } = require('helios-core/mojang') const { MojangRestAPI, MojangErrorCode } = require('helios-core/mojang')
const { MicrosoftAuth, microsoftErrorDisplayable, MicrosoftErrorCode } = require('helios-core/microsoft') const { MicrosoftAuth, MicrosoftErrorCode } = require('helios-core/microsoft')
const { AZURE_CLIENT_ID } = require('./ipcconstants') const { AZURE_CLIENT_ID } = require('./ipcconstants')
const Lang = require('./langloader')
const log = LoggerUtil.getLogger('AuthManager') const log = LoggerUtil.getLogger('AuthManager')
// Error messages
function microsoftErrorDisplayable(errorCode) {
switch (errorCode) {
case MicrosoftErrorCode.NO_PROFILE:
return {
title: Lang.queryJS('auth.microsoft.error.noProfileTitle'),
desc: Lang.queryJS('auth.microsoft.error.noProfileDesc')
}
case MicrosoftErrorCode.NO_XBOX_ACCOUNT:
return {
title: Lang.queryJS('auth.microsoft.error.noXboxAccountTitle'),
desc: Lang.queryJS('auth.microsoft.error.noXboxAccountDesc')
}
case MicrosoftErrorCode.XBL_BANNED:
return {
title: Lang.queryJS('auth.microsoft.error.xblBannedTitle'),
desc: Lang.queryJS('auth.microsoft.error.xblBannedDesc')
}
case MicrosoftErrorCode.UNDER_18:
return {
title: Lang.queryJS('auth.microsoft.error.under18Title'),
desc: Lang.queryJS('auth.microsoft.error.under18Desc')
}
case MicrosoftErrorCode.UNKNOWN:
return {
title: Lang.queryJS('auth.microsoft.error.unknownTitle'),
desc: Lang.queryJS('auth.microsoft.error.unknownDesc')
}
}
}
function mojangErrorDisplayable(errorCode) {
switch(errorCode) {
case MojangErrorCode.ERROR_METHOD_NOT_ALLOWED:
return {
title: Lang.queryJS('auth.mojang.error.methodNotAllowedTitle'),
desc: Lang.queryJS('auth.mojang.error.methodNotAllowedDesc')
}
case MojangErrorCode.ERROR_NOT_FOUND:
return {
title: Lang.queryJS('auth.mojang.error.notFoundTitle'),
desc: Lang.queryJS('auth.mojang.error.notFoundDesc')
}
case MojangErrorCode.ERROR_USER_MIGRATED:
return {
title: Lang.queryJS('auth.mojang.error.accountMigratedTitle'),
desc: Lang.queryJS('auth.mojang.error.accountMigratedDesc')
}
case MojangErrorCode.ERROR_INVALID_CREDENTIALS:
return {
title: Lang.queryJS('auth.mojang.error.invalidCredentialsTitle'),
desc: Lang.queryJS('auth.mojang.error.invalidCredentialsDesc')
}
case MojangErrorCode.ERROR_RATELIMIT:
return {
title: Lang.queryJS('auth.mojang.error.tooManyAttemptsTitle'),
desc: Lang.queryJS('auth.mojang.error.tooManyAttemptsDesc')
}
case MojangErrorCode.ERROR_INVALID_TOKEN:
return {
title: Lang.queryJS('auth.mojang.error.invalidTokenTitle'),
desc: Lang.queryJS('auth.mojang.error.invalidTokenDesc')
}
case MojangErrorCode.ERROR_ACCESS_TOKEN_HAS_PROFILE:
return {
title: Lang.queryJS('auth.mojang.error.tokenHasProfileTitle'),
desc: Lang.queryJS('auth.mojang.error.tokenHasProfileDesc')
}
case MojangErrorCode.ERROR_CREDENTIALS_MISSING:
return {
title: Lang.queryJS('auth.mojang.error.credentialsMissingTitle'),
desc: Lang.queryJS('auth.mojang.error.credentialsMissingDesc')
}
case MojangErrorCode.ERROR_INVALID_SALT_VERSION:
return {
title: Lang.queryJS('auth.mojang.error.invalidSaltVersionTitle'),
desc: Lang.queryJS('auth.mojang.error.invalidSaltVersionDesc')
}
case MojangErrorCode.ERROR_UNSUPPORTED_MEDIA_TYPE:
return {
title: Lang.queryJS('auth.mojang.error.unsupportedMediaTypeTitle'),
desc: Lang.queryJS('auth.mojang.error.unsupportedMediaTypeDesc')
}
case MojangErrorCode.ERROR_GONE:
return {
title: Lang.queryJS('auth.mojang.error.accountGoneTitle'),
desc: Lang.queryJS('auth.mojang.error.accountGoneDesc')
}
case MojangErrorCode.ERROR_UNREACHABLE:
return {
title: Lang.queryJS('auth.mojang.error.unreachableTitle'),
desc: Lang.queryJS('auth.mojang.error.unreachableDesc')
}
case MojangErrorCode.ERROR_NOT_PAID:
return {
title: Lang.queryJS('auth.mojang.error.gameNotPurchasedTitle'),
desc: Lang.queryJS('auth.mojang.error.gameNotPurchasedDesc')
}
case MojangErrorCode.UNKNOWN:
return {
title: Lang.queryJS('auth.mojang.error.unknownErrorTitle'),
desc: Lang.queryJS('auth.mojang.error.unknownErrorDesc')
}
default:
throw new Error(`Unknown error code: ${errorCode}`)
}
}
// Functions // Functions
/** /**

View File

@ -279,6 +279,11 @@ latestVersionTitle = "You Are Running the Latest Version"
checkForUpdatesButton = "Check for Updates" checkForUpdatesButton = "Check for Updates"
checkingForUpdatesButton = "Checking for Updates.." checkingForUpdatesButton = "Checking for Updates.."
[js.settings.msftLogin]
errorTitle = "Microsoft Login Failed"
errorMessage = "We were unable to authenticate your Microsoft account. Please try again."
okButton = "OK"
[js.uibinder.startup] [js.uibinder.startup]
fatalErrorTitle = "Fatal Error: Unable to Load Distribution Index" fatalErrorTitle = "Fatal Error: Unable to Load Distribution Index"
fatalErrorMessage = "A connection could not be established to our servers to download the distribution index. No local copies were available to load. <br><br>The distribution index is an essential file which provides the latest server information. The launcher is unable to start without it. Ensure you are connected to the internet and relaunch the application." fatalErrorMessage = "A connection could not be established to our servers to download the distribution index. No local copies were available to load. <br><br>The distribution index is an essential file which provides the latest server information. The launcher is unable to start without it. Ensure you are connected to the internet and relaunch the application."
@ -295,3 +300,45 @@ selectAnotherAccountButton = "Select Another Account"
checkingForUpdateButton = "Checking for Updates..." checkingForUpdateButton = "Checking for Updates..."
installNowButton = "Install Now" installNowButton = "Install Now"
checkForUpdatesButton = "Check for Updates" checkForUpdatesButton = "Check for Updates"
[js.auth.microsoft.error]
noProfileTitle = "Error During Login:<br>Profile Not Set Up"
noProfileDesc = "Your Microsoft account does not yet have a Minecraft profile set up. If you have recently purchased the game or redeemed it through Xbox Game Pass, you have to set up your profile on <a href=\"https://minecraft.net/\">Minecraft.net</a>.<br><br>If you have not yet purchased the game, you can also do that on <a href=\"https://minecraft.net/\">Minecraft.net</a>."
noXboxAccountTitle = "Error During Login:<br>No Xbox Account"
noXboxAccountDesc = "Your Microsoft account has no Xbox account associated with it."
xblBannedTitle = "Error During Login:<br>Xbox Live Unavailable"
xblBannedDesc = "Your Microsoft account is from a country where Xbox Live is not available or banned."
under18Title = "Error During Login:<br>Parental Approval Required"
under18Desc = "Accounts for users under the age of 18 must be added to a Family by an adult."
unknownTitle = "Unknown Error During Login"
unknownDesc = "An unknown error has occurred. Please see the console for details."
[js.auth.mojang.error]
methodNotAllowedTitle = "Internal Error:<br>Method Not Allowed"
methodNotAllowedDesc = "Method not allowed. Please report this error."
notFoundTitle = "Internal Error:<br>Not Found"
notFoundDesc = "The authentication endpoint was not found. Please report this issue."
accountMigratedTitle = "Error During Login:<br>Account Migrated"
accountMigratedDesc = "You've attempted to login with a migrated account. Try again using the account email as the username."
invalidCredentialsTitle = "Error During Login:<br>Invalid Credentials"
invalidCredentialsDesc = "The email or password you've entered is incorrect. Please try again."
tooManyAttemptsTitle = "Error During Login:<br>Too Many Attempts"
tooManyAttemptsDesc = "There have been too many login attempts with this account recently. Please try again later."
invalidTokenTitle = "Error During Login:<br>Invalid Token"
invalidTokenDesc = "The provided access token is invalid."
tokenHasProfileTitle = "Error During Login:<br>Token Has Profile"
tokenHasProfileDesc = "Access token already has a profile assigned. Selecting profiles is not implemented yet."
credentialsMissingTitle = "Error During Login:<br>Credentials Missing"
credentialsMissingDesc = "Username/password was not submitted or password is less than 3 characters."
invalidSaltVersionTitle = "Error During Login:<br>Invalid Salt Version"
invalidSaltVersionDesc = "Invalid salt version."
unsupportedMediaTypeTitle = "Internal Error:<br>Unsupported Media Type"
unsupportedMediaTypeDesc = "Unsupported media type. Please report this error."
accountGoneTitle = "Error During Login:<br>Account Migrated"
accountGoneDesc = "Account has been migrated to a Microsoft account. Please log in with Microsoft."
unreachableTitle = "Error During Login:<br>Unreachable"
unreachableDesc = "Unable to reach the authentication servers. Ensure that they are online and you are connected to the internet."
gameNotPurchasedTitle = "Error During Login:<br>Game Not Purchased"
gameNotPurchasedDesc = "The account you are trying to login with has not purchased a copy of Minecraft. You may purchase a copy on <a href=\"https://minecraft.net/\">Minecraft.net</a>"
unknownErrorTitle = "Unknown Error During Login"
unknownErrorDesc = "An unknown error has occurred. Please see the console for details."