1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 15:22:55 +08:00

Add localisation support to overlay header title/description

This commit is contained in:
Dean Herbert 2021-04-21 14:37:11 +09:00
parent 5c8f562472
commit 31c8586dac
12 changed files with 126 additions and 18 deletions

View File

@ -0,0 +1,24 @@
// 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 ChatStrings
{
private const string prefix = "osu.Game.Localisation.Chat";
/// <summary>
/// "chat"
/// </summary>
public static LocalisableString HeaderTitle => new TranslatableString(getKey("header_title"), "chat");
/// <summary>
/// "join the real-time discussion"
/// </summary>
public static LocalisableString HeaderDescription => new TranslatableString(getKey("header_description"), "join the real-time discussion");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -0,0 +1,24 @@
// 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 NotificationsStrings
{
private const string prefix = "osu.Game.Localisation.Notifications";
/// <summary>
/// "notifications"
/// </summary>
public static LocalisableString HeaderTitle => new TranslatableString(getKey("header_title"), "notifications");
/// <summary>
/// "waiting for 'ya"
/// </summary>
public static LocalisableString HeaderDescription => new TranslatableString(getKey("header_description"), "waiting for 'ya");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -0,0 +1,24 @@
// 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 NowPlayingStrings
{
private const string prefix = "osu.Game.Localisation.NowPlaying";
/// <summary>
/// "now playing"
/// </summary>
public static LocalisableString HeaderTitle => new TranslatableString(getKey("header_title"), "now playing");
/// <summary>
/// "manage the currently playing track"
/// </summary>
public static LocalisableString HeaderDescription => new TranslatableString(getKey("header_description"), "manage the currently playing track");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -0,0 +1,24 @@
// 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 SettingsStrings
{
private const string prefix = "osu.Game.Localisation.Settings";
/// <summary>
/// "settings"
/// </summary>
public static LocalisableString HeaderTitle => new TranslatableString(getKey("header_title"), "settings");
/// <summary>
/// "change the way osu! behaves"
/// </summary>
public static LocalisableString HeaderDescription => new TranslatableString(getKey("header_description"), "change the way osu! behaves");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -24,6 +24,8 @@ using osu.Game.Overlays.Chat.Tabs;
using osuTK.Input; using osuTK.Input;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Online; using osu.Game.Online;
namespace osu.Game.Overlays namespace osu.Game.Overlays
@ -31,8 +33,8 @@ namespace osu.Game.Overlays
public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent public class ChatOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent
{ {
public string IconTexture => "Icons/Hexacons/messaging"; public string IconTexture => "Icons/Hexacons/messaging";
public string Title => "chat"; public LocalisableString Title => ChatStrings.HeaderTitle;
public string Description => "join the real-time discussion"; public LocalisableString Description => ChatStrings.HeaderDescription;
private const float textbox_height = 60; private const float textbox_height = 60;
private const float channel_selection_min_height = 0.3f; private const float channel_selection_min_height = 0.3f;

View File

@ -8,6 +8,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
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.Online.API; using osu.Game.Online.API;
using osuTK.Graphics; using osuTK.Graphics;
@ -18,8 +19,8 @@ namespace osu.Game.Overlays
where T : OverlayHeader where T : OverlayHeader
{ {
public virtual string IconTexture => Header.Title.IconTexture ?? string.Empty; public virtual string IconTexture => Header.Title.IconTexture ?? string.Empty;
public virtual string Title => Header.Title.Title ?? string.Empty; public virtual LocalisableString Title => Header.Title.Title;
public virtual string Description => Header.Title.Description ?? string.Empty; public virtual LocalisableString Description => Header.Title.Description;
public T Header { get; } public T Header { get; }

View File

@ -1,14 +1,16 @@
// 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 osu.Framework.Localisation;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public interface INamedOverlayComponent public interface INamedOverlayComponent
{ {
string IconTexture { get; } string IconTexture { get; }
string Title { get; } LocalisableString Title { get; }
string Description { get; } LocalisableString Description { get; }
} }
} }

View File

@ -11,16 +11,18 @@ using osu.Game.Graphics.Containers;
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Localisation;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Localisation;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class NotificationOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent public class NotificationOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent
{ {
public string IconTexture => "Icons/Hexacons/notification"; public string IconTexture => "Icons/Hexacons/notification";
public string Title => "notifications"; public LocalisableString Title => NotificationsStrings.HeaderTitle;
public string Description => "waiting for 'ya"; public LocalisableString Description => NotificationsStrings.HeaderDescription;
private const float width = 320; private const float width = 320;

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays.Music; using osu.Game.Overlays.Music;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -28,8 +29,8 @@ namespace osu.Game.Overlays
public class NowPlayingOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent public class NowPlayingOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent
{ {
public string IconTexture => "Icons/Hexacons/music"; public string IconTexture => "Icons/Hexacons/music";
public string Title => "now playing"; public LocalisableString Title => NowPlayingStrings.HeaderTitle;
public string Description => "manage the currently playing track"; public LocalisableString Description => NowPlayingStrings.HeaderDescription;
private const float player_height = 130; private const float player_height = 130;
private const float transition_length = 800; private const float transition_length = 800;

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osuTK; using osuTK;
@ -19,15 +20,15 @@ namespace osu.Game.Overlays
private readonly OsuSpriteText titleText; private readonly OsuSpriteText titleText;
private readonly Container icon; private readonly Container icon;
private string title; private LocalisableString title;
public string Title public LocalisableString Title
{ {
get => title; get => title;
protected set => titleText.Text = title = value; protected set => titleText.Text = title = value;
} }
public string Description { get; protected set; } public LocalisableString Description { get; protected set; }
private string iconTexture; private string iconTexture;

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -11,10 +12,10 @@ namespace osu.Game.Overlays.Settings
{ {
public class SettingsHeader : Container public class SettingsHeader : Container
{ {
private readonly string heading; private readonly LocalisableString heading;
private readonly string subheading; private readonly LocalisableString subheading;
public SettingsHeader(string heading, string subheading) public SettingsHeader(LocalisableString heading, LocalisableString subheading)
{ {
this.heading = heading; this.heading = heading;
this.subheading = subheading; this.subheading = subheading;

View File

@ -10,14 +10,16 @@ using osuTK.Graphics;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Localisation;
using osu.Game.Localisation;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class SettingsOverlay : SettingsPanel, INamedOverlayComponent public class SettingsOverlay : SettingsPanel, INamedOverlayComponent
{ {
public string IconTexture => "Icons/Hexacons/settings"; public string IconTexture => "Icons/Hexacons/settings";
public string Title => "settings"; public LocalisableString Title => SettingsStrings.HeaderTitle;
public string Description => "change the way osu! behaves"; public LocalisableString Description => SettingsStrings.HeaderDescription;
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[] protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
{ {