mirror of
https://github.com/ppy/osu
synced 2025-03-05 10:58:34 +00:00
Add localisation for WikiHeader
Co-authored-by: huoyaoyuan <huoyaoyuan@hotmail.com>
This commit is contained in:
parent
4b4c341fb8
commit
ba9b51c12d
29
osu.Game/Localisation/WikiStrings.cs
Normal file
29
osu.Game/Localisation/WikiStrings.cs
Normal 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 WikiStrings
|
||||
{
|
||||
private const string prefix = @"osu.Game.Resources.Localisation.Wiki";
|
||||
|
||||
/// <summary>
|
||||
/// "index"
|
||||
/// </summary>
|
||||
public static LocalisableString IndexPageString => new TranslatableString(getKey(@"index_page"), @"index");
|
||||
|
||||
/// <summary>
|
||||
/// "wiki"
|
||||
/// </summary>
|
||||
public static LocalisableString HeaderTitle => new TranslatableString(getKey(@"header_title"), @"wiki");
|
||||
|
||||
/// <summary>
|
||||
/// "knowledge base"
|
||||
/// </summary>
|
||||
public static LocalisableString HeaderDescription => new TranslatableString(getKey(@"header_description"), @"knowledge base");
|
||||
|
||||
private static string getKey(string key) => $"{prefix}:{key}";
|
||||
}
|
||||
}
|
@ -5,14 +5,18 @@ using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Overlays.Wiki
|
||||
{
|
||||
public class WikiHeader : BreadcrumbControlOverlayHeader
|
||||
{
|
||||
private const string index_page_string = "index";
|
||||
private const string index_path = "Main_Page";
|
||||
public static LocalisableString IndexPageString => WikiStrings.IndexPageString;
|
||||
public static LocalisableString HeaderTitle => WikiStrings.HeaderTitle;
|
||||
public static LocalisableString HeaderDescription => WikiStrings.HeaderDescription;
|
||||
|
||||
public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
|
||||
|
||||
@ -21,8 +25,8 @@ namespace osu.Game.Overlays.Wiki
|
||||
|
||||
public WikiHeader()
|
||||
{
|
||||
TabControl.AddItem(index_page_string);
|
||||
Current.Value = index_page_string;
|
||||
TabControl.AddItem(IndexPageString);
|
||||
Current.Value = IndexPageString;
|
||||
|
||||
WikiPageData.BindValueChanged(onWikiPageChange);
|
||||
Current.BindValueChanged(onCurrentChange);
|
||||
@ -34,13 +38,13 @@ namespace osu.Game.Overlays.Wiki
|
||||
return;
|
||||
|
||||
TabControl.Clear();
|
||||
Current.Value = null;
|
||||
Current.Value = string.Empty;
|
||||
|
||||
TabControl.AddItem(index_page_string);
|
||||
TabControl.AddItem(IndexPageString);
|
||||
|
||||
if (e.NewValue.Path == index_path)
|
||||
{
|
||||
Current.Value = index_page_string;
|
||||
Current.Value = IndexPageString;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -51,12 +55,12 @@ namespace osu.Game.Overlays.Wiki
|
||||
Current.Value = e.NewValue.Title;
|
||||
}
|
||||
|
||||
private void onCurrentChange(ValueChangedEvent<string> e)
|
||||
private void onCurrentChange(ValueChangedEvent<LocalisableString> e)
|
||||
{
|
||||
if (e.NewValue == TabControl.Items.LastOrDefault())
|
||||
return;
|
||||
|
||||
if (e.NewValue == index_page_string)
|
||||
if (e.NewValue == IndexPageString)
|
||||
{
|
||||
ShowIndexPage?.Invoke();
|
||||
return;
|
||||
@ -73,8 +77,8 @@ namespace osu.Game.Overlays.Wiki
|
||||
{
|
||||
public WikiHeaderTitle()
|
||||
{
|
||||
Title = "wiki";
|
||||
Description = "knowledge base";
|
||||
Title = HeaderTitle;
|
||||
Description = HeaderDescription;
|
||||
IconTexture = "Icons/Hexacons/wiki";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user