mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Update localizations for FileDialog. (#2935)
* Update localizations for FileDialog. - Add "btnOk", "btnCancel" to default file dialog style. - Add localization strings for context menus of FileDialog. - Change extension text of directory to `<Strings.Directory>`. Change FileSystemInfoStats.IsDir to property. - Update unit test for FileDialog. * Undo the change to HideColumn. * Fix unit test.
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Terminal.Gui {
|
||||
if (Parent.AllowedTypes.Any () && Parent.OpenMode == OpenMode.File) {
|
||||
|
||||
children = children.Where (
|
||||
c => c.IsDir () ||
|
||||
c => c.IsDir ||
|
||||
(c.FileSystemInfo is IFileInfo f && Parent.IsCompatibleWithAllowedExtensions (f)))
|
||||
.ToList ();
|
||||
}
|
||||
@@ -77,7 +77,7 @@ namespace Terminal.Gui {
|
||||
|
||||
protected bool MatchesApiFilter (FileSystemInfoStats arg)
|
||||
{
|
||||
return arg.IsDir () ||
|
||||
return arg.IsDir ||
|
||||
(arg.FileSystemInfo is IFileInfo f && Parent.CurrentFilter.IsAllowed (f.FullName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,12 +91,12 @@ namespace Terminal.Gui {
|
||||
/// Gets or sets the text on the 'Ok' button. Typically you may want to change this to
|
||||
/// "Open" or "Save" etc.
|
||||
/// </summary>
|
||||
public string OkButtonText { get; set; } = "Ok";
|
||||
public string OkButtonText { get; set; } = Strings.btnOk;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text on the 'Cancel' button.
|
||||
/// </summary>
|
||||
public string CancelButtonText { get; set; } = "Cancel";
|
||||
public string CancelButtonText { get; set; } = Strings.btnCancel;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to flip the order of the Ok and Cancel buttons. Defaults
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
using Terminal.Gui.Resources;
|
||||
|
||||
namespace Terminal.Gui {
|
||||
|
||||
@@ -26,7 +27,7 @@ namespace Terminal.Gui {
|
||||
|
||||
private const long ByteConversion = 1024;
|
||||
|
||||
private static readonly string [] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
||||
private static readonly string [] SizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
||||
private static readonly List<string> ImageExtensions = new List<string> { ".JPG", ".JPEG", ".JPE", ".BMP", ".GIF", ".PNG" };
|
||||
private static readonly List<string> ExecutableExtensions = new List<string> { ".EXE", ".BAT" };
|
||||
|
||||
@@ -46,7 +47,8 @@ namespace Terminal.Gui {
|
||||
this.Type = fi.Extension;
|
||||
} else {
|
||||
this.HumanReadableLength = string.Empty;
|
||||
this.Type = "dir";
|
||||
this.Type = $"<{Strings.fdDirectory}>";
|
||||
this.IsDir = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +68,7 @@ namespace Terminal.Gui {
|
||||
public bool IsParent { get; internal set; }
|
||||
public string Name => this.IsParent ? ".." : this.FileSystemInfo.Name;
|
||||
|
||||
public bool IsDir ()
|
||||
{
|
||||
return this.Type == "dir";
|
||||
}
|
||||
public bool IsDir { get; }
|
||||
|
||||
public bool IsImage ()
|
||||
{
|
||||
@@ -96,7 +95,7 @@ namespace Terminal.Gui {
|
||||
}
|
||||
|
||||
if (value == 0) {
|
||||
return "0.0 bytes";
|
||||
return "0.0 B";
|
||||
}
|
||||
|
||||
int mag = (int)Math.Log (value, ByteConversion);
|
||||
|
||||
54
Terminal.Gui/Resources/Strings.Designer.cs
generated
54
Terminal.Gui/Resources/Strings.Designer.cs
generated
@@ -195,6 +195,60 @@ namespace Terminal.Gui.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Delete.
|
||||
/// </summary>
|
||||
internal static string fdCtxDelete {
|
||||
get {
|
||||
return ResourceManager.GetString("fdCtxDelete", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Hide {0}.
|
||||
/// </summary>
|
||||
internal static string fdCtxHide {
|
||||
get {
|
||||
return ResourceManager.GetString("fdCtxHide", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _New.
|
||||
/// </summary>
|
||||
internal static string fdCtxNew {
|
||||
get {
|
||||
return ResourceManager.GetString("fdCtxNew", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Rename.
|
||||
/// </summary>
|
||||
internal static string fdCtxRename {
|
||||
get {
|
||||
return ResourceManager.GetString("fdCtxRename", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Sort {0} ASC.
|
||||
/// </summary>
|
||||
internal static string fdCtxSortAsc {
|
||||
get {
|
||||
return ResourceManager.GetString("fdCtxSortAsc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Sort {0} DESC.
|
||||
/// </summary>
|
||||
internal static string fdCtxSortDesc {
|
||||
get {
|
||||
return ResourceManager.GetString("fdCtxSortDesc", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Are you sure you want to delete '{0}'? This operation is permanent.
|
||||
/// </summary>
|
||||
|
||||
@@ -255,4 +255,22 @@
|
||||
<data name="btnSaveAs" xml:space="preserve">
|
||||
<value>名前を付けて保存 (_S)</value>
|
||||
</data>
|
||||
<data name="fdCtxDelete" xml:space="preserve">
|
||||
<value>削除 (_D)</value>
|
||||
</data>
|
||||
<data name="fdCtxHide" xml:space="preserve">
|
||||
<value>{0}を隠す (_H)</value>
|
||||
</data>
|
||||
<data name="fdCtxNew" xml:space="preserve">
|
||||
<value>新規 (_N)</value>
|
||||
</data>
|
||||
<data name="fdCtxRename" xml:space="preserve">
|
||||
<value>名前変更 (_R)</value>
|
||||
</data>
|
||||
<data name="fdCtxSortAsc" xml:space="preserve">
|
||||
<value>{0}で昇順ソート (_S)</value>
|
||||
</data>
|
||||
<data name="fdCtxSortDesc" xml:space="preserve">
|
||||
<value>{0}で降順ソート (_S)</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -259,4 +259,22 @@
|
||||
<data name="btnCancel" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="fdCtxDelete" xml:space="preserve">
|
||||
<value>_Delete</value>
|
||||
</data>
|
||||
<data name="fdCtxHide" xml:space="preserve">
|
||||
<value>_Hide {0}</value>
|
||||
</data>
|
||||
<data name="fdCtxNew" xml:space="preserve">
|
||||
<value>_New</value>
|
||||
</data>
|
||||
<data name="fdCtxRename" xml:space="preserve">
|
||||
<value>_Rename</value>
|
||||
</data>
|
||||
<data name="fdCtxSortAsc" xml:space="preserve">
|
||||
<value>_Sort {0} ASC</value>
|
||||
</data>
|
||||
<data name="fdCtxSortDesc" xml:space="preserve">
|
||||
<value>_Sort {0} DESC</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -255,4 +255,22 @@
|
||||
<data name="btnCancel" xml:space="preserve">
|
||||
<value>取消 (_C)</value>
|
||||
</data>
|
||||
<data name="fdCtxDelete" xml:space="preserve">
|
||||
<value>删除 (_D)</value>
|
||||
</data>
|
||||
<data name="fdCtxHide" xml:space="preserve">
|
||||
<value>隐藏{0} (_H)</value>
|
||||
</data>
|
||||
<data name="fdCtxNew" xml:space="preserve">
|
||||
<value>新建 (_N)</value>
|
||||
</data>
|
||||
<data name="fdCtxRename" xml:space="preserve">
|
||||
<value>重命名 (_R)</value>
|
||||
</data>
|
||||
<data name="fdCtxSortAsc" xml:space="preserve">
|
||||
<value>{0}顺序排序 (_S)</value>
|
||||
</data>
|
||||
<data name="fdCtxSortDesc" xml:space="preserve">
|
||||
<value>{0}逆序排序 (_S)</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1291,7 +1291,7 @@ namespace Terminal.Gui {
|
||||
// This portion is never reordered (aways .. at top then folders)
|
||||
var forcedOrder = stats
|
||||
.OrderByDescending (f => f.IsParent)
|
||||
.ThenBy (f => f.IsDir () ? -1 : 100);
|
||||
.ThenBy (f => f.IsDir ? -1 : 100);
|
||||
|
||||
// This portion is flexible based on the column clicked (e.g. alphabetical)
|
||||
var ordered =
|
||||
@@ -1325,10 +1325,10 @@ namespace Terminal.Gui {
|
||||
// work out new sort order
|
||||
if (this.currentSortColumn == clickedCol && this.currentSortIsAsc) {
|
||||
isAsc = false;
|
||||
return $"{tableView.Table.ColumnNames [clickedCol]} DESC";
|
||||
return string.Format (Strings.fdCtxSortDesc, tableView.Table.ColumnNames [clickedCol]);
|
||||
} else {
|
||||
isAsc = true;
|
||||
return $"{tableView.Table.ColumnNames [clickedCol]} ASC";
|
||||
return string.Format (Strings.fdCtxSortAsc, tableView.Table.ColumnNames [clickedCol]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1341,8 +1341,8 @@ namespace Terminal.Gui {
|
||||
e.MouseEvent.Y + 1,
|
||||
new MenuBarItem (new MenuItem []
|
||||
{
|
||||
new MenuItem($"Hide {StripArrows(tableView.Table.ColumnNames[clickedCol])}", string.Empty, () => this.HideColumn(clickedCol)),
|
||||
new MenuItem($"Sort {StripArrows(sort)}",string.Empty, ()=> this.SortColumn(clickedCol,isAsc)),
|
||||
new MenuItem(string.Format (Strings.fdCtxHide, StripArrows (tableView.Table.ColumnNames[clickedCol])), string.Empty, () => this.HideColumn (clickedCol)),
|
||||
new MenuItem(StripArrows (sort), string.Empty, () => this.SortColumn (clickedCol, isAsc)),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -1365,9 +1365,9 @@ namespace Terminal.Gui {
|
||||
e.MouseEvent.Y + 1,
|
||||
new MenuBarItem (new MenuItem []
|
||||
{
|
||||
new MenuItem($"New", string.Empty, () => New()),
|
||||
new MenuItem($"Rename",string.Empty, ()=> Rename()),
|
||||
new MenuItem($"Delete",string.Empty, ()=> Delete()),
|
||||
new MenuItem(Strings.fdCtxNew, string.Empty, New),
|
||||
new MenuItem(Strings.fdCtxRename, string.Empty, Rename),
|
||||
new MenuItem(Strings.fdCtxDelete,string.Empty, Delete),
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -385,21 +385,21 @@ namespace Terminal.Gui.FileServicesTests {
|
||||
|
||||
string expected =
|
||||
@$"
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│/demo/ │
|
||||
│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
|
||||
│┌────────────┬──────────┬──────────────────────────────┬─────────┐│
|
||||
││Filename (▲)│Size │Modified │Type ││
|
||||
│├────────────┼──────────┼──────────────────────────────┼─────────┤│
|
||||
││.. │ │ │dir ││
|
||||
││/subfolder │ │2002-01-01T22:42:10 │dir ││
|
||||
││image.gif │4.00 bytes│2002-01-01T22:42:10 │.gif ││
|
||||
││jQuery.js │7.00 bytes│2001-01-01T11:44:42 │.js ││
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} Ok {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
|
||||
└──────────────────────────────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│/demo/ │
|
||||
│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
|
||||
│┌────────────┬──────────┬──────────────────────────────┬────────────────┐│
|
||||
││Filename (▲)│Size │Modified │Type ││
|
||||
│├────────────┼──────────┼──────────────────────────────┼────────────────┤│
|
||||
││.. │ │ │<Directory> ││
|
||||
││/subfolder │ │2002-01-01T22:42:10 │<Directory> ││
|
||||
││image.gif │4.00 B │2002-01-01T22:42:10 │.gif ││
|
||||
││jQuery.js │7.00 B │2001-01-01T11:44:42 │.js ││
|
||||
│ │
|
||||
│ │
|
||||
│ │
|
||||
│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} OK {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
";
|
||||
TestHelpers.AssertDriverContentsAre (expected, output, true);
|
||||
}
|
||||
@@ -421,21 +421,21 @@ namespace Terminal.Gui.FileServicesTests {
|
||||
|
||||
string expected =
|
||||
@$"
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│c:\demo\ │
|
||||
│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
|
||||
│┌────────────┬──────────┬──────────────────────────────┬─────────┐│
|
||||
││Filename (▲)│Size │Modified │Type ││
|
||||
│├────────────┼──────────┼──────────────────────────────┼─────────┤│
|
||||
││.. │ │ │dir ││
|
||||
││\subfolder │ │2002-01-01T22:42:10 │dir ││
|
||||
││image.gif │4.00 bytes│2002-01-01T22:42:10 │.gif ││
|
||||
││jQuery.js │7.00 bytes│2001-01-01T11:44:42 │.js ││
|
||||
││mybinary.exe│7.00 bytes│2001-01-01T11:44:42 │.exe ││
|
||||
│ │
|
||||
│ │
|
||||
│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} Ok {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
|
||||
└──────────────────────────────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│c:\demo\ │
|
||||
│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
|
||||
│┌────────────┬──────────┬──────────────────────────────┬────────────────┐│
|
||||
││Filename (▲)│Size │Modified │Type ││
|
||||
│├────────────┼──────────┼──────────────────────────────┼────────────────┤│
|
||||
││.. │ │ │<Directory> ││
|
||||
││\subfolder │ │2002-01-01T22:42:10 │<Directory> ││
|
||||
││image.gif │4.00 B │2002-01-01T22:42:10 │.gif ││
|
||||
││jQuery.js │7.00 B │2001-01-01T11:44:42 │.js ││
|
||||
││mybinary.exe│7.00 B │2001-01-01T11:44:42 │.exe ││
|
||||
│ │
|
||||
│ │
|
||||
│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} OK {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
|
||||
└─────────────────────────────────────────────────────────────────────────┘
|
||||
";
|
||||
TestHelpers.AssertDriverContentsAre (expected, output, true);
|
||||
}
|
||||
@@ -559,7 +559,8 @@ namespace Terminal.Gui.FileServicesTests {
|
||||
fileSystem.AddFile (@"c:\demo\subfolder\image2.gif", new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 }) { LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10) });
|
||||
|
||||
var fd = new FileDialog (fileSystem) {
|
||||
Height = 15
|
||||
Height = 15,
|
||||
Width = 75
|
||||
};
|
||||
fd.Path = @"c:\demo\";
|
||||
Begin (fd);
|
||||
@@ -583,7 +584,8 @@ namespace Terminal.Gui.FileServicesTests {
|
||||
fileSystem.AddFile (@"/demo/subfolder/image2.gif", new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 }) { LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10) });
|
||||
|
||||
var fd = new FileDialog (fileSystem) {
|
||||
Height = 15
|
||||
Height = 15,
|
||||
Width = 75
|
||||
};
|
||||
fd.Path = @"/demo/";
|
||||
Begin (fd);
|
||||
|
||||
Reference in New Issue
Block a user