From df74bccaaa7345e2b016516b799e85dc790a184c Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Tue, 17 Jan 2023 13:31:03 +0300 Subject: [PATCH] Replace 2 strings with one formattable --- osu.Game/Localisation/AccountCreationStrings.cs | 11 +++-------- osu.Game/Overlays/AccountCreation/ScreenEntry.cs | 10 +++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/osu.Game/Localisation/AccountCreationStrings.cs b/osu.Game/Localisation/AccountCreationStrings.cs index 0b27944a61..6acfaaa9ac 100644 --- a/osu.Game/Localisation/AccountCreationStrings.cs +++ b/osu.Game/Localisation/AccountCreationStrings.cs @@ -52,21 +52,16 @@ namespace osu.Game.Localisation public static LocalisableString MakeSureToGetIt => new TranslatableString(getKey(@"make_sure_to_get_it"), @" Make sure to get it right!"); /// - /// "At least " + /// "At least {0}. Choose something long but also something you will remember, like a line from your favourite song." /// - public static LocalisableString BeforeCharactersLong => new TranslatableString(getKey(@"before_characters_long"), @"At least "); + public static LocalisableString PasswordRequirements(string arg0) => new TranslatableString(getKey(@"password_requirements"), + @"At least {0}. Choose something long but also something you will remember, like a line from your favourite song.", arg0); /// /// "8 characters long" /// public static LocalisableString CharactersLong => new TranslatableString(getKey(@"characters_long"), @"8 characters long"); - /// - /// ". Choose something long but also something you will remember, like a line from your favourite song." - /// - public static LocalisableString AfterCharactersLong => - new TranslatableString(getKey(@"after_characters_long"), @". Choose something long but also something you will remember, like a line from your favourite song."); - private static string getKey(string key) => $@"{prefix}:{key}"; } } diff --git a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs index fc450c7a91..192b95b963 100644 --- a/osu.Game/Overlays/AccountCreation/ScreenEntry.cs +++ b/osu.Game/Overlays/AccountCreation/ScreenEntry.cs @@ -10,6 +10,7 @@ using osu.Framework.Allocation; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Localisation; using osu.Framework.Utils; using osu.Framework.Platform; using osu.Framework.Screens; @@ -52,7 +53,7 @@ namespace osu.Game.Overlays.AccountCreation private OsuGame game { get; set; } [BackgroundDependencyLoader] - private void load() + private void load(LocalisationManager localisationManager) { InternalChildren = new Drawable[] { @@ -138,9 +139,12 @@ namespace osu.Game.Overlays.AccountCreation emailAddressDescription.AddText(AccountCreationStrings.EmailUsage); emailAddressDescription.AddText(AccountCreationStrings.MakeSureToGetIt, cp => cp.Font = cp.Font.With(Typeface.Torus, weight: FontWeight.Bold)); - passwordDescription.AddText(AccountCreationStrings.BeforeCharactersLong); + string[] passwordReq = localisationManager.GetLocalisedBindableString(AccountCreationStrings.PasswordRequirements("{}")).Value.Split("{}"); + if (passwordReq.Length != 2) passwordReq = AccountCreationStrings.PasswordRequirements("{}").ToString().Split("{}"); + + passwordDescription.AddText(passwordReq[0]); characterCheckText = passwordDescription.AddText(AccountCreationStrings.CharactersLong); - passwordDescription.AddText(AccountCreationStrings.AfterCharactersLong); + passwordDescription.AddText(passwordReq[1]); passwordTextBox.Current.BindValueChanged(_ => updateCharacterCheckTextColour(), true); characterCheckText.DrawablePartsRecreated += _ => updateCharacterCheckTextColour();