Localise friends online status stream control.

This commit is contained in:
Lucas A
2021-06-30 21:16:21 +02:00
parent 285c49be7e
commit f2287ba022
4 changed files with 38 additions and 8 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using Humanizer; using Humanizer;
using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osuTK.Graphics; using osuTK.Graphics;
@ -17,11 +18,11 @@ namespace osu.Game.Overlays.Changelog
Width *= 2; Width *= 2;
} }
protected override string MainText => Value.DisplayName; protected override LocalisableString MainText => Value.DisplayName;
protected override string AdditionalText => Value.LatestBuild.DisplayVersion; protected override LocalisableString AdditionalText => Value.LatestBuild.DisplayVersion;
protected override string InfoText => Value.LatestBuild.Users > 0 ? $"{"user".ToQuantity(Value.LatestBuild.Users, "N0")} online" : null; protected override LocalisableString InfoText => Value.LatestBuild.Users > 0 ? $"{"user".ToQuantity(Value.LatestBuild.Users, "N0")} online" : null;
protected override Color4 GetBarColour(OsuColour colours) => Value.Colour; protected override Color4 GetBarColour(OsuColour colours) => Value.Colour;
} }

View File

@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using osu.Framework.Extensions;
using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK.Graphics; using osuTK.Graphics;
@ -14,9 +16,9 @@ namespace osu.Game.Overlays.Dashboard.Friends
{ {
} }
protected override string MainText => Value.Status.ToString(); protected override LocalisableString MainText => Value.Status.GetLocalisableDescription();
protected override string AdditionalText => Value.Count.ToString(); protected override LocalisableString AdditionalText => Value.Count.ToString();
protected override Color4 GetBarColour(OsuColour colours) protected override Color4 GetBarColour(OsuColour colours)
{ {

View File

@ -1,12 +1,38 @@
// 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.
using System;
using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Dashboard.Friends namespace osu.Game.Overlays.Dashboard.Friends
{ {
[LocalisableEnum(typeof(OnlineStatusEnumLocalisationMapper))]
public enum OnlineStatus public enum OnlineStatus
{ {
All, All,
Online, Online,
Offline Offline
} }
public class OnlineStatusEnumLocalisationMapper : EnumLocalisationMapper<OnlineStatus>
{
public override LocalisableString Map(OnlineStatus value)
{
switch (value)
{
case OnlineStatus.All:
return SortStrings.All;
case OnlineStatus.Online:
return UsersStrings.StatusOnline;
case OnlineStatus.Offline:
return UsersStrings.StatusOffline;
default:
throw new ArgumentOutOfRangeException(nameof(value), value, null);
}
}
}
} }

View File

@ -12,6 +12,7 @@ using osu.Framework.Allocation;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Localisation;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@ -88,11 +89,11 @@ namespace osu.Game.Overlays
SelectedItem.BindValueChanged(_ => updateState(), true); SelectedItem.BindValueChanged(_ => updateState(), true);
} }
protected abstract string MainText { get; } protected abstract LocalisableString MainText { get; }
protected abstract string AdditionalText { get; } protected abstract LocalisableString AdditionalText { get; }
protected virtual string InfoText => string.Empty; protected virtual LocalisableString InfoText => string.Empty;
protected abstract Color4 GetBarColour(OsuColour colours); protected abstract Color4 GetBarColour(OsuColour colours);