Merge pull request #13914 from kj415j45/localisation-header

Add localisation for overlay headers
This commit is contained in:
Dean Herbert
2021-08-03 17:59:30 +09:00
committed by GitHub
14 changed files with 137 additions and 71 deletions

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.730.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.728.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2021.728.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">

View File

@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Online
[Test] [Test]
public void TestControl() public void TestControl()
{ {
AddAssert("Front page selected", () => header.Current.Value == "frontpage"); AddAssert("Front page selected", () => header.Current.Value == NewsHeader.FrontPageString);
AddAssert("1 tab total", () => header.TabCount == 1); AddAssert("1 tab total", () => header.TabCount == 1);
AddStep("Set article 1", () => header.SetArticle("1")); AddStep("Set article 1", () => header.SetArticle("1"));
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("2 tabs total", () => header.TabCount == 2); AddAssert("2 tabs total", () => header.TabCount == 2);
AddStep("Set front page", () => header.SetFrontPage()); AddStep("Set front page", () => header.SetFrontPage());
AddAssert("Front page selected", () => header.Current.Value == "frontpage"); AddAssert("Front page selected", () => header.Current.Value == NewsHeader.FrontPageString);
AddAssert("1 tab total", () => header.TabCount == 1); AddAssert("1 tab total", () => header.TabCount == 1);
} }

View File

@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Online
[Test] [Test]
public void TestWikiHeader() public void TestWikiHeader()
{ {
AddAssert("Current is index", () => checkCurrent("index")); AddAssert("Current is index", () => checkCurrent(WikiHeader.IndexPageString));
AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage
{ {
@ -54,8 +54,8 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("Current is welcome", () => checkCurrent("Welcome")); AddAssert("Current is welcome", () => checkCurrent("Welcome"));
AddAssert("Check breadcrumb", checkBreadcrumb); AddAssert("Check breadcrumb", checkBreadcrumb);
AddStep("Change current to index", () => header.Current.Value = "index"); AddStep("Change current to index", () => header.Current.Value = WikiHeader.IndexPageString);
AddAssert("Current is index", () => checkCurrent("index")); AddAssert("Current is index", () => checkCurrent(WikiHeader.IndexPageString));
AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage
{ {
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("Check breadcrumb", checkBreadcrumb); AddAssert("Check breadcrumb", checkBreadcrumb);
} }
private bool checkCurrent(string expectedCurrent) => header.Current.Value == expectedCurrent; private bool checkCurrent(LocalisableString expectedCurrent) => header.Current.Value == expectedCurrent;
private bool checkBreadcrumb() private bool checkBreadcrumb()
{ {

View File

@ -0,0 +1,44 @@
// 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 NamedOverlayComponentStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.NamedOverlayComponent";
/// <summary>
/// "browse for new beatmaps"
/// </summary>
public static LocalisableString BeatmapListingDescription => new TranslatableString(getKey(@"beatmap_listing_description"), @"browse for new beatmaps");
/// <summary>
/// "track recent dev updates in the osu! ecosystem"
/// </summary>
public static LocalisableString ChangelogDescription => new TranslatableString(getKey(@"changelog_description"), @"track recent dev updates in the osu! ecosystem");
/// <summary>
/// "view your friends and other information"
/// </summary>
public static LocalisableString DashboardDescription => new TranslatableString(getKey(@"dashboard_description"), @"view your friends and other information");
/// <summary>
/// "find out who's the best right now"
/// </summary>
public static LocalisableString RankingsDescription => new TranslatableString(getKey(@"rankings_description"), @"find out who's the best right now");
/// <summary>
/// "get up-to-date on community happenings"
/// </summary>
public static LocalisableString NewsDescription => new TranslatableString(getKey(@"news_description"), @"get up-to-date on community happenings");
/// <summary>
/// "knowledge base"
/// </summary>
public static LocalisableString WikiDescription => new TranslatableString(getKey(@"wiki_description"), @"knowledge base");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -1,6 +1,9 @@
// 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.Game.Localisation;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.BeatmapListing namespace osu.Game.Overlays.BeatmapListing
{ {
public class BeatmapListingHeader : OverlayHeader public class BeatmapListingHeader : OverlayHeader
@ -11,8 +14,8 @@ namespace osu.Game.Overlays.BeatmapListing
{ {
public BeatmapListingTitle() public BeatmapListingTitle()
{ {
Title = "beatmap listing"; Title = PageTitleStrings.MainBeatmapsetsControllerIndex;
Description = "browse for new beatmaps"; Description = NamedOverlayComponentStrings.BeatmapListingDescription;
IconTexture = "Icons/Hexacons/beatmap"; IconTexture = "Icons/Hexacons/beatmap";
} }
} }

View File

@ -7,6 +7,7 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -54,7 +55,7 @@ namespace osu.Game.Overlays.BeatmapSet
{ {
public BeatmapHeaderTitle() public BeatmapHeaderTitle()
{ {
Title = "beatmap info"; Title = PageTitleStrings.MainBeatmapsetsControllerShow;
IconTexture = "Icons/Hexacons/beatmap"; IconTexture = "Icons/Hexacons/beatmap";
} }
} }

View File

@ -9,7 +9,10 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Changelog namespace osu.Game.Overlays.Changelog
{ {
@ -21,16 +24,16 @@ namespace osu.Game.Overlays.Changelog
public ChangelogUpdateStreamControl Streams; public ChangelogUpdateStreamControl Streams;
private const string listing_string = "listing"; public static LocalisableString ListingString => LayoutStrings.HeaderChangelogIndex;
private Box streamsBackground; private Box streamsBackground;
public ChangelogHeader() public ChangelogHeader()
{ {
TabControl.AddItem(listing_string); TabControl.AddItem(ListingString);
Current.ValueChanged += e => Current.ValueChanged += e =>
{ {
if (e.NewValue == listing_string) if (e.NewValue == ListingString)
ListingSelected?.Invoke(); ListingSelected?.Invoke();
}; };
@ -63,7 +66,7 @@ namespace osu.Game.Overlays.Changelog
} }
else else
{ {
Current.Value = listing_string; Current.Value = ListingString;
Streams.Current.Value = null; Streams.Current.Value = null;
} }
} }
@ -114,8 +117,8 @@ namespace osu.Game.Overlays.Changelog
{ {
public ChangelogHeaderTitle() public ChangelogHeaderTitle()
{ {
Title = "changelog"; Title = PageTitleStrings.MainChangelogControllerDefault;
Description = "track recent dev updates in the osu! ecosystem"; Description = NamedOverlayComponentStrings.ChangelogDescription;
IconTexture = "Icons/Hexacons/devtools"; IconTexture = "Icons/Hexacons/devtools";
} }
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Dashboard namespace osu.Game.Overlays.Dashboard
@ -16,8 +17,8 @@ namespace osu.Game.Overlays.Dashboard
{ {
public DashboardTitle() public DashboardTitle()
{ {
Title = HomeStrings.UserTitle; Title = PageTitleStrings.MainHomeControllerIndex;
Description = "view your friends and other information"; Description = NamedOverlayComponentStrings.DashboardDescription;
IconTexture = "Icons/Hexacons/social"; IconTexture = "Icons/Hexacons/social";
} }
} }

View File

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

View File

@ -3,11 +3,10 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Localisation;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Users; using osu.Game.Users;
using osu.Game.Resources.Localisation.Web;
using osu.Framework.Localisation;
using System;
namespace osu.Game.Overlays.Rankings namespace osu.Game.Overlays.Rankings
{ {
@ -33,42 +32,9 @@ namespace osu.Game.Overlays.Rankings
public RankingsTitle() public RankingsTitle()
{ {
Title = PageTitleStrings.MainRankingControllerDefault; Title = PageTitleStrings.MainRankingControllerDefault;
Description = "find out who's the best right now"; Description = NamedOverlayComponentStrings.RankingsDescription;
IconTexture = "Icons/Hexacons/rankings"; IconTexture = "Icons/Hexacons/rankings";
} }
} }
} }
[LocalisableEnum(typeof(RankingsScopeEnumLocalisationMapper))]
public enum RankingsScope
{
Performance,
Spotlights,
Score,
Country
}
public class RankingsScopeEnumLocalisationMapper : EnumLocalisationMapper<RankingsScope>
{
public override LocalisableString Map(RankingsScope value)
{
switch (value)
{
case RankingsScope.Performance:
return RankingsStrings.TypePerformance;
case RankingsScope.Spotlights:
return RankingsStrings.TypeCharts;
case RankingsScope.Score:
return RankingsStrings.TypeScore;
case RankingsScope.Country:
return RankingsStrings.TypeCountry;
default:
throw new ArgumentOutOfRangeException(nameof(value), value, null);
}
}
}
} }

View File

@ -0,0 +1,42 @@
// 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 System;
using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Rankings
{
[LocalisableEnum(typeof(RankingsScopeEnumLocalisationMapper))]
public enum RankingsScope
{
Performance,
Spotlights,
Score,
Country
}
public class RankingsScopeEnumLocalisationMapper : EnumLocalisationMapper<RankingsScope>
{
public override LocalisableString Map(RankingsScope value)
{
switch (value)
{
case RankingsScope.Performance:
return RankingsStrings.TypePerformance;
case RankingsScope.Spotlights:
return RankingsStrings.TypeCharts;
case RankingsScope.Score:
return RankingsStrings.TypeScore;
case RankingsScope.Country:
return RankingsStrings.TypeCountry;
default:
throw new ArgumentOutOfRangeException(nameof(value), value, null);
}
}
}
}

View File

@ -6,15 +6,18 @@ using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Wiki namespace osu.Game.Overlays.Wiki
{ {
public class WikiHeader : BreadcrumbControlOverlayHeader public class WikiHeader : BreadcrumbControlOverlayHeader
{ {
private const string index_page_string = "index";
private const string index_path = "Main_Page"; private const string index_path = "Main_Page";
public static LocalisableString IndexPageString => LayoutStrings.HeaderHelpIndex;
public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>(); public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
public Action ShowIndexPage; public Action ShowIndexPage;
@ -22,8 +25,8 @@ namespace osu.Game.Overlays.Wiki
public WikiHeader() public WikiHeader()
{ {
TabControl.AddItem(index_page_string); TabControl.AddItem(IndexPageString);
Current.Value = index_page_string; Current.Value = IndexPageString;
WikiPageData.BindValueChanged(onWikiPageChange); WikiPageData.BindValueChanged(onWikiPageChange);
Current.BindValueChanged(onCurrentChange); Current.BindValueChanged(onCurrentChange);
@ -37,11 +40,11 @@ namespace osu.Game.Overlays.Wiki
TabControl.Clear(); TabControl.Clear();
Current.Value = null; Current.Value = null;
TabControl.AddItem(index_page_string); TabControl.AddItem(IndexPageString);
if (e.NewValue.Path == index_path) if (e.NewValue.Path == index_path)
{ {
Current.Value = index_page_string; Current.Value = IndexPageString;
return; return;
} }
@ -57,7 +60,7 @@ namespace osu.Game.Overlays.Wiki
if (e.NewValue == TabControl.Items.LastOrDefault()) if (e.NewValue == TabControl.Items.LastOrDefault())
return; return;
if (e.NewValue == index_page_string) if (e.NewValue == IndexPageString)
{ {
ShowIndexPage?.Invoke(); ShowIndexPage?.Invoke();
return; return;
@ -74,8 +77,8 @@ namespace osu.Game.Overlays.Wiki
{ {
public WikiHeaderTitle() public WikiHeaderTitle()
{ {
Title = "wiki"; Title = PageTitleStrings.MainWikiControllerDefault;
Description = "knowledge base"; Description = NamedOverlayComponentStrings.WikiDescription;
IconTexture = "Icons/Hexacons/wiki"; IconTexture = "Icons/Hexacons/wiki";
} }
} }

View File

@ -37,7 +37,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.3.0" /> <PackageReference Include="Realm" Version="10.3.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.728.0" /> <PackageReference Include="ppy.osu.Framework" Version="2021.728.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.730.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
<PackageReference Include="Sentry" Version="3.8.3" /> <PackageReference Include="Sentry" Version="3.8.3" />
<PackageReference Include="SharpCompress" Version="0.28.3" /> <PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -71,7 +71,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.728.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2021.728.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.730.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" />
</ItemGroup> </ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) --> <!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup> <PropertyGroup>