1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 01:02:54 +08:00

Add localisation for NewsHeader

Co-authored-by: huoyaoyuan <huoyaoyuan@hotmail.com>
This commit is contained in:
kj415j45 2021-07-17 19:28:27 +08:00
parent ba9b51c12d
commit 51742da89a
2 changed files with 39 additions and 6 deletions

View File

@ -0,0 +1,29 @@
// 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 NewsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.News";
/// <summary>
/// "frontpage"
/// </summary>
public static LocalisableString FrontPageString => new TranslatableString(getKey(@"front_page"), @"frontpage");
/// <summary>
/// "news"
/// </summary>
public static LocalisableString HeaderTitle => new TranslatableString(getKey(@"header_title"), @"news");
/// <summary>
/// "join the real-time discussion"
/// </summary>
public static LocalisableString HeaderDescription => new TranslatableString(getKey(@"header_description"), @"get up-to-date on community happenings");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -4,12 +4,16 @@
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Localisation;
namespace osu.Game.Overlays.News
{
public class NewsHeader : BreadcrumbControlOverlayHeader
{
private const string front_page_string = "frontpage";
public static LocalisableString FrontPageString => NewsStrings.FrontPageString;
public static LocalisableString HeaderTitle => NewsStrings.HeaderTitle;
public static LocalisableString HeaderDescription => NewsStrings.HeaderDescription;
public Action ShowFrontPage;
@ -17,7 +21,7 @@ namespace osu.Game.Overlays.News
public NewsHeader()
{
TabControl.AddItem(front_page_string);
TabControl.AddItem(FrontPageString);
article.BindValueChanged(onArticleChanged, true);
}
@ -28,7 +32,7 @@ namespace osu.Game.Overlays.News
Current.BindValueChanged(e =>
{
if (e.NewValue == front_page_string)
if (e.NewValue == FrontPageString)
ShowFrontPage?.Invoke();
});
}
@ -49,7 +53,7 @@ namespace osu.Game.Overlays.News
}
else
{
Current.Value = front_page_string;
Current.Value = FrontPageString;
}
}
@ -61,8 +65,8 @@ namespace osu.Game.Overlays.News
{
public NewsHeaderTitle()
{
Title = "news";
Description = "get up-to-date on community happenings";
Title = HeaderTitle;
Description = HeaderDescription;
IconTexture = "Icons/Hexacons/news";
}
}