Use LocalisableStrings where possible to leverage localisable text flow

This commit is contained in:
Bartłomiej Dach
2021-10-30 18:50:13 +02:00
parent ad98ab0a26
commit 11de924704
8 changed files with 23 additions and 15 deletions

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
@ -19,7 +20,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary> /// </summary>
protected virtual bool PlaySoundsOnUserChange => true; protected virtual bool PlaySoundsOnUserChange => true;
public string LabelText public LocalisableString LabelText
{ {
set set
{ {

View File

@ -8,6 +8,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK; using osuTK;
@ -156,18 +157,18 @@ namespace osu.Game.Graphics.UserInterfaceV2
descriptionText.Colour = osuColour.Yellow; descriptionText.Colour = osuColour.Yellow;
} }
public string Label public LocalisableString Label
{ {
set => labelText.Text = value; set => labelText.Text = value;
} }
public string Description public LocalisableString Description
{ {
set set
{ {
descriptionText.Text = value; descriptionText.Text = value;
if (!string.IsNullOrEmpty(value)) if (value == default)
descriptionText.Show(); descriptionText.Show();
else else
descriptionText.Hide(); descriptionText.Hide();

View File

@ -3,6 +3,7 @@
using System; using System;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -12,7 +13,7 @@ namespace osu.Game.Online.Placeholders
{ {
public Action Action; public Action Action;
public ClickablePlaceholder(string actionMessage, IconUsage icon) public ClickablePlaceholder(LocalisableString actionMessage, IconUsage icon)
{ {
OsuTextFlowContainer textFlow; OsuTextFlowContainer textFlow;

View File

@ -3,14 +3,15 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
namespace osu.Game.Online.Placeholders namespace osu.Game.Online.Placeholders
{ {
public class MessagePlaceholder : Placeholder public class MessagePlaceholder : Placeholder
{ {
private readonly string message; private readonly LocalisableString message;
public MessagePlaceholder(string message) public MessagePlaceholder(LocalisableString message)
{ {
AddIcon(FontAwesome.Solid.ExclamationCircle, cp => AddIcon(FontAwesome.Solid.ExclamationCircle, cp =>
{ {

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osuTK; using osuTK;
@ -42,9 +43,9 @@ namespace osu.Game.Overlays.Dialog
set => icon.Icon = value; set => icon.Icon = value;
} }
private string headerText; private LocalisableString headerText;
public string HeaderText public LocalisableString HeaderText
{ {
get => headerText; get => headerText;
set set
@ -57,9 +58,9 @@ namespace osu.Game.Overlays.Dialog
} }
} }
private string bodyText; private LocalisableString bodyText;
public string BodyText public LocalisableString BodyText
{ {
get => bodyText; get => bodyText;
set set

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
@ -22,7 +23,7 @@ namespace osu.Game.Overlays.Notifications
{ {
private const float loading_spinner_size = 22; private const float loading_spinner_size = 22;
public string Text public LocalisableString Text
{ {
set => Schedule(() => textDrawable.Text = value); set => Schedule(() => textDrawable.Text = value);
} }

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osuTK; using osuTK;
@ -15,9 +16,9 @@ namespace osu.Game.Overlays.Notifications
{ {
public class SimpleNotification : Notification public class SimpleNotification : Notification
{ {
private string text = string.Empty; private LocalisableString text;
public string Text public LocalisableString Text
{ {
get => text; get => text;
set set

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
@ -16,7 +17,7 @@ namespace osu.Game.Screens.Edit.Timing
{ {
private readonly SettingsSlider<T> slider; private readonly SettingsSlider<T> slider;
public SliderWithTextBoxInput(string labelText) public SliderWithTextBoxInput(LocalisableString labelText)
{ {
LabelledTextBox textbox; LabelledTextBox textbox;