1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 17:33:02 +08:00

Localise login form

This commit is contained in:
ansel 2023-01-16 20:39:38 +03:00
parent 4224907f08
commit ff5a12fcb4
4 changed files with 69 additions and 15 deletions

View File

@ -0,0 +1,54 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class LoginPanelStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.LoginPanel";
/// <summary>
/// "Do not disturb"
/// </summary>
public static LocalisableString DoNotDisturb => new TranslatableString(getKey(@"do_not_disturb"), @"Do not disturb");
/// <summary>
/// "Appear offline"
/// </summary>
public static LocalisableString AppearOffline => new TranslatableString(getKey(@"appear_offline"), @"Appear offline");
/// <summary>
/// "Sign out"
/// </summary>
public static LocalisableString SignOut => new TranslatableString(getKey(@"sign_out"), @"Sign out");
/// <summary>
/// "Signed in"
/// </summary>
public static LocalisableString SignedIn => new TranslatableString(getKey(@"signed_in"), @"Signed in");
/// <summary>
/// "ACCOUNT"
/// </summary>
public static LocalisableString Account => new TranslatableString(getKey(@"account"), @"ACCOUNT");
/// <summary>
/// "Remember username"
/// </summary>
public static LocalisableString RememberUsername => new TranslatableString(getKey(@"remember_username"), @"Remember username");
/// <summary>
/// "Stay signed in"
/// </summary>
public static LocalisableString StaySignedIn => new TranslatableString(getKey(@"stay_signed_in"), @"Stay signed in");
/// <summary>
/// "Register"
/// </summary>
public static LocalisableString Register => new TranslatableString(getKey(@"register"), @"Register");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -16,6 +16,7 @@ using osu.Game.Online.API;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osuTK; using osuTK;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Login namespace osu.Game.Overlays.Login
{ {
@ -47,7 +48,7 @@ namespace osu.Game.Overlays.Login
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
ErrorTextFlowContainer errorText; ErrorTextFlowContainer errorText;
LinkFlowContainer forgottenPaswordLink; LinkFlowContainer forgottenPasswordLink;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -71,15 +72,15 @@ namespace osu.Game.Overlays.Login
}, },
new SettingsCheckbox new SettingsCheckbox
{ {
LabelText = "Remember username", LabelText = LoginPanelStrings.RememberUsername,
Current = config.GetBindable<bool>(OsuSetting.SaveUsername), Current = config.GetBindable<bool>(OsuSetting.SaveUsername),
}, },
new SettingsCheckbox new SettingsCheckbox
{ {
LabelText = "Stay signed in", LabelText = LoginPanelStrings.StaySignedIn,
Current = config.GetBindable<bool>(OsuSetting.SavePassword), Current = config.GetBindable<bool>(OsuSetting.SavePassword),
}, },
forgottenPaswordLink = new LinkFlowContainer forgottenPasswordLink = new LinkFlowContainer
{ {
Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS }, Padding = new MarginPadding { Left = SettingsPanel.CONTENT_MARGINS },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -105,7 +106,7 @@ namespace osu.Game.Overlays.Login
}, },
new SettingsButton new SettingsButton
{ {
Text = "Register", Text = LoginPanelStrings.Register,
Action = () => Action = () =>
{ {
RequestHide?.Invoke(); RequestHide?.Invoke();
@ -114,7 +115,7 @@ namespace osu.Game.Overlays.Login
} }
}; };
forgottenPaswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.WebsiteRootUrl}/home/password-reset"); forgottenPasswordLink.AddLink(LayoutStrings.PopupLoginLoginForgot, $"{api.WebsiteRootUrl}/home/password-reset");
password.OnCommit += (_, _) => performLogin(); password.OnCommit += (_, _) => performLogin();

View File

@ -6,6 +6,7 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
@ -81,7 +82,7 @@ namespace osu.Game.Overlays.Login
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = "ACCOUNT", Text = LoginPanelStrings.Account,
Margin = new MarginPadding { Bottom = 5 }, Margin = new MarginPadding { Bottom = 5 },
Font = OsuFont.GetFont(weight: FontWeight.Bold), Font = OsuFont.GetFont(weight: FontWeight.Bold),
}, },
@ -115,7 +116,7 @@ namespace osu.Game.Overlays.Login
}, },
}; };
linkFlow.AddLink("cancel", api.Logout, string.Empty); linkFlow.AddLink(Resources.Localisation.Web.CommonStrings.ButtonsCancel.ToLower(), api.Logout, string.Empty);
break; break;
case APIState.Online: case APIState.Online:
@ -140,7 +141,7 @@ namespace osu.Game.Overlays.Login
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Text = "Signed in", Text = LoginPanelStrings.SignedIn,
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold), Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold),
Margin = new MarginPadding { Top = 5, Bottom = 5 }, Margin = new MarginPadding { Top = 5, Bottom = 5 },
}, },

View File

@ -1,11 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.ComponentModel;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Login namespace osu.Game.Overlays.Login
{ {
@ -14,13 +12,13 @@ namespace osu.Game.Overlays.Login
[LocalisableDescription(typeof(UsersStrings), nameof(UsersStrings.StatusOnline))] [LocalisableDescription(typeof(UsersStrings), nameof(UsersStrings.StatusOnline))]
Online, Online,
[Description(@"Do not disturb")] [LocalisableDescription(typeof(LoginPanelStrings), nameof(LoginPanelStrings.DoNotDisturb))]
DoNotDisturb, DoNotDisturb,
[Description(@"Appear offline")] [LocalisableDescription(typeof(LoginPanelStrings), nameof(LoginPanelStrings.AppearOffline))]
AppearOffline, AppearOffline,
[Description(@"Sign out")] [LocalisableDescription(typeof(LoginPanelStrings), nameof(LoginPanelStrings.SignOut))]
SignOut, SignOut,
} }
} }