型と項目の名前の翻訳をYMM4の名前空間のものに限る

このコミットが含まれているのは:
routersys committed 2026-11-01 09:19:57 +09:00
1 親 221996c1a3
コミット 41cd8a976a
7ファイル変更
+57 -28

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -81,7 +81,7 @@ YMM4の取り消しとやり直しの履歴は1本の列で、取り消したあ
現在の位置は太字と青い丸、現在の位置までの経路は黒い丸、ほかは白抜きの丸で示します。やり直せるノードは少し薄く、ほかのブランチはさらに薄く表示します。右端には、ツールがノードを作った時刻を表示します。
ノードの名前は、変更の対象の名前と項目名を「/」でつなぎます。対象の名前はアイテムやエフェクトの名前で、ないときは型の名前です。項目名はYMM4の画面に出る名前で、取れないときはプロパティの名前です。1つのノードに複数の変更があるときは、先頭の変更のあとに「(ほかN件)」を付けます。リストの追加と削除は、追加だけなら「項目をn件追加」、削除だけなら「項目をm件削除」、両方なら「項目をn件追加、m件削除」と書きます。
ノードの名前は、変更の対象の名前と項目名を「/」でつなぎます。対象の名前はアイテムやエフェクトの名前で、ないときは型の名前です。項目名はYMM4の画面に出る名前で、取れないときはプロパティの名前です。型の名前と項目名は、名前空間がYukkuriMovieMakerのものだけを、画面の言語に訳します。ほかのプラグインの型と項目は、名前のまま表示します。1つのノードに複数の変更があるときは、先頭の変更のあとに「(ほかN件)」を付けます。リストの追加と削除は、追加だけなら「項目をn件追加」、削除だけなら「項目をm件削除」、両方なら「項目をn件追加、m件削除」と書きます。
履歴が変わるたびに、現在の位置のノードを選びます。この動作はメニューの「現在の位置に追従する」で切り替えられます。「現在の位置を表示」ボタンは、現在の位置を隠している折りたたまれたブランチを開いて、そのノードを選びます。「すべてのブランチを展開」と「すべてのブランチを折りたたむ」ボタンは、ブランチを一度に開閉します。
-11
ファイルの表示
@@ -100,17 +100,6 @@ public sealed class Labelled : UndoRedoable
}
}
public sealed class CharacterSettings : UndoRedoable
{
int letterSpacing;
public int LetterSpacing
{
get => letterSpacing;
set => Set(ref letterSpacing, value);
}
}
public enum Shade
{
[Display(Name = "Visible shade")]
+14
ファイルの表示
@@ -0,0 +1,14 @@
namespace Foreign
{
public sealed class Animation
{
public double Length { get; set; }
}
}
namespace YukkuriMovieMakerExtras
{
public sealed class Animation
{
}
}
+7 -6
ファイルの表示
@@ -1,5 +1,6 @@
using YukkuriMovieMaker.Commons;
using YukkuriMovieMaker.Controls;
using YukkuriMovieMaker.Project;
using YukkuriMovieMaker.UndoRedo;
namespace UndoTree.Tests;
@@ -168,14 +169,14 @@ public sealed class UndoRedoCommandViewTests
public void ATargetAndAMemberWithoutLabelsAreNamedInTheLanguageOfTheTexts()
{
var (manager, _) = Histories.NewDocument();
var settings = new CharacterSettings();
manager.Subscribe(settings);
Histories.Edit(manager, () => settings.LetterSpacing = 1);
var video = new VideoInfo();
manager.Subscribe(video);
Histories.Edit(manager, () => video.Width = 1280);
var info = UndoRedoCommandView.Read(Only(manager)).Describe();
Assert.Equal("Character settings", info.TargetLabel);
Assert.Equal("Letter spacing", info.Member);
Assert.Equal("Video information", info.TargetLabel);
Assert.Equal("Width", info.Member);
}
[Fact]
@@ -265,7 +266,7 @@ public sealed class UndoRedoCommandViewTests
public void AnObjectWithoutItsOwnTextIsShownByItsLabelOrItsTypeName()
{
Assert.Equal("blur", UndoRedoCommandView.TextOf(new Part("blur")));
Assert.Equal("Character settings", UndoRedoCommandView.TextOf(new CharacterSettings()));
Assert.Equal("Video information", UndoRedoCommandView.TextOf(new VideoInfo()));
Assert.Equal("42", UndoRedoCommandView.TextOf(42));
}
+25 -5
ファイルの表示
@@ -30,14 +30,14 @@ public sealed class UndoTreeNamesTests
var cultureInfo = CultureInfo.GetCultureInfo(culture);
Assert.Equal(type, UndoTreeNames.OfType(typeof(Animation), cultureInfo));
Assert.Equal(member, UndoTreeNames.OfMember(nameof(Animation.Length), cultureInfo));
Assert.Equal(member, UndoTreeNames.OfMember(typeof(Animation), nameof(Animation.Length), cultureInfo));
}
[Fact]
public void TheLanguageOfTheTextsIsUsedByDefault()
{
Assert.Equal("Effects above", UndoTreeNames.OfMember("AboveEffects"));
Assert.Equal("上のエフェクト", UndoTreeNames.OfMember("AboveEffects", CultureInfo.GetCultureInfo("ja-JP")));
Assert.Equal("Effects above", UndoTreeNames.OfMember(typeof(Animation), "AboveEffects"));
Assert.Equal("上のエフェクト", UndoTreeNames.OfMember(typeof(Animation), "AboveEffects", CultureInfo.GetCultureInfo("ja-JP")));
}
[Fact]
@@ -45,7 +45,27 @@ public sealed class UndoTreeNamesTests
{
Assert.Equal(nameof(Document), UndoTreeNames.OfType(typeof(Document)));
Assert.Equal("List`1", UndoTreeNames.OfType(typeof(List<int>)));
Assert.Equal("Unlisted", UndoTreeNames.OfMember("Unlisted"));
Assert.Equal("Unlisted", UndoTreeNames.OfMember(typeof(Animation), "Unlisted"));
}
[Fact]
public void ATypeOutsideTheHostNamespaceIsNotTranslatedEvenWithTheSameName()
{
var japanese = CultureInfo.GetCultureInfo("ja-JP");
Assert.Equal("アニメーション", UndoTreeNames.OfType(typeof(Animation), japanese));
Assert.Equal("Animation", UndoTreeNames.OfType(typeof(Foreign.Animation), japanese));
Assert.Equal("長さ", UndoTreeNames.OfMember(typeof(Animation), "Length", japanese));
Assert.Equal("Length", UndoTreeNames.OfMember(typeof(Foreign.Animation), "Length", japanese));
Assert.Equal("Length", UndoTreeNames.OfMember(null, "Length", japanese));
}
[Fact]
public void ANamespaceThatOnlyStartsWithTheHostNameIsNotTheHost()
{
var japanese = CultureInfo.GetCultureInfo("ja-JP");
Assert.Equal("Animation", UndoTreeNames.OfType(typeof(YukkuriMovieMakerExtras.Animation), japanese));
}
[Theory]
@@ -54,7 +74,7 @@ public sealed class UndoTreeNamesTests
{
var cultureInfo = CultureInfo.GetCultureInfo(culture);
Assert.All(["X", "Y", "Z", "BPM", "FPS", "Hz"], member => Assert.Equal(member, UndoTreeNames.OfMember(member, cultureInfo)));
Assert.All(["X", "Y", "Z", "BPM", "FPS", "Hz"], member => Assert.Equal(member, UndoTreeNames.OfMember(typeof(Animation), member, cultureInfo)));
}
[Fact]
+5 -3
ファイルの表示
@@ -144,10 +144,12 @@ internal sealed class UndoRedoCommandView
static string MemberLabel(object? target, string member)
{
Type? owner = null;
try
{
var name = target?.GetType().GetProperty(member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?
.GetCustomAttribute<DisplayAttribute>()?.GetName();
var property = target?.GetType().GetProperty(member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
owner = property?.DeclaringType;
var name = property?.GetCustomAttribute<DisplayAttribute>()?.GetName();
if (!string.IsNullOrEmpty(name))
return name;
}
@@ -155,7 +157,7 @@ internal sealed class UndoRedoCommandView
{
}
return UndoTreeNames.OfMember(member);
return UndoTreeNames.OfMember(owner, member);
}
internal static string ListChangeOf(int added, int removed) => (added, removed) switch
+5 -2
ファイルの表示
@@ -13,12 +13,13 @@ internal static class UndoTreeNames
{
const string TypePrefix = "Type_";
const string MemberPrefix = "Member_";
const string HostNamespace = "YukkuriMovieMaker";
static readonly ConcurrentDictionary<Type, IPlugin?> Plugins = new();
public static string OfType(Type type, CultureInfo? culture = null) => Find(TypePrefix + type.Name, culture) ?? type.Name;
public static string OfType(Type type, CultureInfo? culture = null) => (IsHost(type) ? Find(TypePrefix + type.Name, culture) : null) ?? type.Name;
public static string OfMember(string member, CultureInfo? culture = null) => Find(MemberPrefix + member, culture) ?? member;
public static string OfMember(Type? owner, string member, CultureInfo? culture = null) => (owner is not null && IsHost(owner) ? Find(MemberPrefix + member, culture) : null) ?? member;
public static string OfPlugin(Type type)
=> Plugins.GetOrAdd(type, CreatePlugin)?.Name is { Length: > 0 } name ? name : OfType(type);
@@ -32,6 +33,8 @@ internal static class UndoTreeNames
return string.Join(", ", value.ToString().Split(", ").Select(field => DisplayName(type, field)));
}
static bool IsHost(Type type) => type.Namespace is { } name && (name == HostNamespace || name.StartsWith(HostNamespace + ".", StringComparison.Ordinal));
static string? Find(string key, CultureInfo? culture)
=> Texts.ResourceManager.GetString(key, culture ?? Texts.Culture) is { Length: > 0 } text ? text : null;