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" />
</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" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">

View File

@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
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);
AddStep("Set article 1", () => header.SetArticle("1"));
@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("2 tabs total", () => header.TabCount == 2);
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);
}

View File

@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
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
{
@ -54,8 +54,8 @@ namespace osu.Game.Tests.Visual.Online
AddAssert("Current is welcome", () => checkCurrent("Welcome"));
AddAssert("Check breadcrumb", checkBreadcrumb);
AddStep("Change current to index", () => header.Current.Value = "index");
AddAssert("Current is index", () => checkCurrent("index"));
AddStep("Change current to index", () => header.Current.Value = WikiHeader.IndexPageString);
AddAssert("Current is index", () => checkCurrent(WikiHeader.IndexPageString));
AddStep("Change wiki page data", () => wikiPageData.Value = new APIWikiPage
{
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Online
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()
{

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,11 +3,10 @@
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Localisation;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets;
using osu.Game.Users;
using osu.Game.Resources.Localisation.Web;
using osu.Framework.Localisation;
using System;
namespace osu.Game.Overlays.Rankings
{
@ -33,42 +32,9 @@ namespace osu.Game.Overlays.Rankings
public RankingsTitle()
{
Title = PageTitleStrings.MainRankingControllerDefault;
Description = "find out who's the best right now";
Description = NamedOverlayComponentStrings.RankingsDescription;
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.Graphics;
using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
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 => LayoutStrings.HeaderHelpIndex;
public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
public Action ShowIndexPage;
@ -22,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);
@ -37,11 +40,11 @@ namespace osu.Game.Overlays.Wiki
TabControl.Clear();
Current.Value = null;
TabControl.AddItem(index_page_string);
TabControl.AddItem(IndexPageString);
if (e.NewValue.Path == index_path)
{
Current.Value = index_page_string;
Current.Value = IndexPageString;
return;
}
@ -57,7 +60,7 @@ namespace osu.Game.Overlays.Wiki
if (e.NewValue == TabControl.Items.LastOrDefault())
return;
if (e.NewValue == index_page_string)
if (e.NewValue == IndexPageString)
{
ShowIndexPage?.Invoke();
return;
@ -74,8 +77,8 @@ namespace osu.Game.Overlays.Wiki
{
public WikiHeaderTitle()
{
Title = "wiki";
Description = "knowledge base";
Title = PageTitleStrings.MainWikiControllerDefault;
Description = NamedOverlayComponentStrings.WikiDescription;
IconTexture = "Icons/Hexacons/wiki";
}
}

View File

@ -37,7 +37,7 @@
</PackageReference>
<PackageReference Include="Realm" Version="10.3.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="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -71,7 +71,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<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>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup>