Skip to content

Commit

Permalink
Merge pull request #29414 from smoogipoo/fix-daily-challenge-2
Browse files Browse the repository at this point in the history
Add localisation for daily challenge day/week units
  • Loading branch information
peppy authored Aug 14, 2024
2 parents 6840f4b + f882ad4 commit 58d9a4a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
24 changes: 24 additions & 0 deletions osu.Game/Localisation/DailyChallengeStatsDisplayStrings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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 DailyChallengeStatsDisplayStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.DailyChallengeStatsDisplay";

/// <summary>
/// "{0}d"
/// </summary>
public static LocalisableString UnitDay(LocalisableString count) => new TranslatableString(getKey(@"unit_day"), @"{0}d", count);

/// <summary>
/// "{0}w"
/// </summary>
public static LocalisableString UnitWeek(LocalisableString count) => new TranslatableString(getKey(@"unit_week"), @"{0}w", count);

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Scoring;
using osu.Game.Localisation;

namespace osu.Game.Overlays.Profile.Header.Components
{
Expand Down Expand Up @@ -106,7 +106,7 @@ private void updateDisplay()

APIUserDailyChallengeStatistics stats = User.Value.User.DailyChallengeStatistics;

dailyPlayCount.Text = UsersStrings.ShowDailyChallengeUnitDay(stats.PlayCount.ToLocalisableString("N0"));
dailyPlayCount.Text = DailyChallengeStatsDisplayStrings.UnitDay(stats.PlayCount.ToLocalisableString("N0"));
dailyPlayCount.Colour = colours.ForRankingTier(tierForPlayCount(stats.PlayCount));

TooltipContent = new DailyChallengeTooltipData(colourProvider, stats);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Scoring;
using osuTK;
using Box = osu.Framework.Graphics.Shapes.Box;
using Color4 = osuTK.Graphics.Color4;
using osuTK.Graphics;

namespace osu.Game.Overlays.Profile.Header.Components
{
Expand Down Expand Up @@ -112,16 +113,16 @@ public void SetContent(DailyChallengeTooltipData content)
background.Colour = colourProvider.Background4;
topBackground.Colour = colourProvider.Background5;

currentDaily.Value = UsersStrings.ShowDailyChallengeUnitDay(content.Statistics.DailyStreakCurrent.ToLocalisableString(@"N0"));
currentDaily.Value = DailyChallengeStatsDisplayStrings.UnitDay(content.Statistics.DailyStreakCurrent.ToLocalisableString(@"N0"));
currentDaily.ValueColour = colours.ForRankingTier(TierForDaily(statistics.DailyStreakCurrent));

currentWeekly.Value = UsersStrings.ShowDailyChallengeUnitWeek(statistics.WeeklyStreakCurrent.ToLocalisableString(@"N0"));
currentWeekly.Value = DailyChallengeStatsDisplayStrings.UnitWeek(statistics.WeeklyStreakCurrent.ToLocalisableString(@"N0"));
currentWeekly.ValueColour = colours.ForRankingTier(TierForWeekly(statistics.WeeklyStreakCurrent));

bestDaily.Value = UsersStrings.ShowDailyChallengeUnitDay(statistics.DailyStreakBest.ToLocalisableString(@"N0"));
bestDaily.Value = DailyChallengeStatsDisplayStrings.UnitDay(statistics.DailyStreakBest.ToLocalisableString(@"N0"));
bestDaily.ValueColour = colours.ForRankingTier(TierForDaily(statistics.DailyStreakBest));

bestWeekly.Value = UsersStrings.ShowDailyChallengeUnitWeek(statistics.WeeklyStreakBest.ToLocalisableString(@"N0"));
bestWeekly.Value = DailyChallengeStatsDisplayStrings.UnitWeek(statistics.WeeklyStreakBest.ToLocalisableString(@"N0"));
bestWeekly.ValueColour = colours.ForRankingTier(TierForWeekly(statistics.WeeklyStreakBest));

topTen.Value = statistics.Top10PercentPlacements.ToLocalisableString(@"N0");
Expand Down

0 comments on commit 58d9a4a

Please sign in to comment.