localise storage error popup dialog

This commit is contained in:
Loreos7 2024-02-02 15:32:55 +03:00
parent 7cdedfb6ca
commit 20504c55ef
2 changed files with 58 additions and 8 deletions

View File

@ -0,0 +1,49 @@
// 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 StorageErrorDialogStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.StorageErrorDialog";
/// <summary>
/// "osu! storage error"
/// </summary>
public static LocalisableString StorageError => new TranslatableString(getKey(@"storage_error"), @"osu! storage error");
/// <summary>
/// "The specified osu! data location (&quot;{0}&quot;) is not accessible. If it is on external storage, please reconnect the device and try again."
/// </summary>
public static LocalisableString LocationIsNotAccessible(string? loc) => new TranslatableString(getKey(@"location_is_not_accessible"), @"The specified osu! data location (""{0}"") is not accessible. If it is on external storage, please reconnect the device and try again.", loc);
/// <summary>
/// "The specified osu! data location (&quot;{0}&quot;) is empty. If you have moved the files, please close osu! and move them back."
/// </summary>
public static LocalisableString LocationIsEmpty(string? loc2) => new TranslatableString(getKey(@"location_is_empty"), @"The specified osu! data location (""{0}"") is empty. If you have moved the files, please close osu! and move them back.", loc2);
/// <summary>
/// "Try again"
/// </summary>
public static LocalisableString TryAgain => new TranslatableString(getKey(@"try_again"), @"Try again");
/// <summary>
/// "Use default location until restart"
/// </summary>
public static LocalisableString UseDefaultLocation => new TranslatableString(getKey(@"use_default_location"), @"Use default location until restart");
/// <summary>
/// "Reset to default location"
/// </summary>
public static LocalisableString ResetToDefaultLocation => new TranslatableString(getKey(@"reset_to_default_location"), @"Reset to default location");
/// <summary>
/// "Start fresh at specified location"
/// </summary>
public static LocalisableString StartFresh => new TranslatableString(getKey(@"start_fresh"), @"Start fresh at specified location");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.IO;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;
@ -17,7 +18,7 @@ namespace osu.Game.Screens.Menu
public StorageErrorDialog(OsuStorage storage, OsuStorageError error)
{
HeaderText = "osu! storage error";
HeaderText = StorageErrorDialogStrings.StorageError;
Icon = FontAwesome.Solid.ExclamationTriangle;
var buttons = new List<PopupDialogButton>();
@ -25,13 +26,13 @@ namespace osu.Game.Screens.Menu
switch (error)
{
case OsuStorageError.NotAccessible:
BodyText = $"The specified osu! data location (\"{storage.CustomStoragePath}\") is not accessible. If it is on external storage, please reconnect the device and try again.";
BodyText = StorageErrorDialogStrings.LocationIsNotAccessible(storage.CustomStoragePath);
buttons.AddRange(new PopupDialogButton[]
{
new PopupDialogCancelButton
{
Text = "Try again",
Text = StorageErrorDialogStrings.TryAgain,
Action = () =>
{
if (!storage.TryChangeToCustomStorage(out var nextError))
@ -40,29 +41,29 @@ namespace osu.Game.Screens.Menu
},
new PopupDialogCancelButton
{
Text = "Use default location until restart",
Text = StorageErrorDialogStrings.UseDefaultLocation,
},
new PopupDialogOkButton
{
Text = "Reset to default location",
Text = StorageErrorDialogStrings.ResetToDefaultLocation,
Action = storage.ResetCustomStoragePath
},
});
break;
case OsuStorageError.AccessibleButEmpty:
BodyText = $"The specified osu! data location (\"{storage.CustomStoragePath}\") is empty. If you have moved the files, please close osu! and move them back.";
BodyText = StorageErrorDialogStrings.LocationIsEmpty(storage.CustomStoragePath);
// Todo: Provide the option to search for the files similar to migration.
buttons.AddRange(new PopupDialogButton[]
{
new PopupDialogCancelButton
{
Text = "Start fresh at specified location"
Text = StorageErrorDialogStrings.StartFresh
},
new PopupDialogOkButton
{
Text = "Reset to default location",
Text = StorageErrorDialogStrings.ResetToDefaultLocation,
Action = storage.ResetCustomStoragePath
},
});