diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/BookmarkTypeHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/BookmarkTypeHelper.cs index d1f9e372da..b7b50d1367 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/BookmarkTypeHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/BookmarkTypeHelper.cs @@ -2,13 +2,9 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.Json.Nodes; -using System.Threading.Tasks; using Microsoft.CmdPal.Ext.Bookmarks.Models; +using Microsoft.CmdPal.Ext.Bookmarks.Properties; namespace Microsoft.CmdPal.Ext.Bookmarks.Helpers; @@ -20,17 +16,17 @@ public static partial class BookmarkTypeHelper { new JsonObject { - ["title"] = "Web", + ["title"] = Resources.bookmarks_form_bookmark_type_web, ["value"] = BookmarkType.Web.ToString(), }, new JsonObject { - ["title"] = "File", + ["title"] = Resources.bookmarks_form_bookmark_type_File, ["value"] = BookmarkType.File.ToString(), }, new JsonObject { - ["title"] = "Folder", + ["title"] = Resources.bookmarks_form_bookmark_type_Folder, ["value"] = BookmarkType.Folder.ToString(), }, }; @@ -39,7 +35,7 @@ public static partial class BookmarkTypeHelper { bookmarkChoices.Add(new JsonObject { - ["title"] = "pwsh", + ["title"] = Resources.bookmarks_form_bookmark_type_PWSH, ["value"] = BookmarkType.PWSH.ToString(), }); } @@ -48,7 +44,7 @@ public static partial class BookmarkTypeHelper { bookmarkChoices.Add(new JsonObject { - ["title"] = "Windows PowerShell", + ["title"] = Resources.bookmarks_form_bookmark_type_PowerShell, ["value"] = BookmarkType.PowerShell.ToString(), }); } @@ -57,7 +53,7 @@ public static partial class BookmarkTypeHelper { bookmarkChoices.Add(new JsonObject { - ["title"] = "Command Prompt", + ["title"] = Resources.bookmarks_form_bookmark_type_CMD, ["value"] = BookmarkType.Cmd.ToString(), }); } @@ -66,7 +62,7 @@ public static partial class BookmarkTypeHelper { bookmarkChoices.Add(new JsonObject { - ["title"] = "Python", + ["title"] = Resources.bookmarks_form_bookmark_type_Python, ["value"] = BookmarkType.Python.ToString(), }); } @@ -75,7 +71,7 @@ public static partial class BookmarkTypeHelper { bookmarkChoices.Add(new JsonObject { - ["title"] = "Python3", + ["title"] = Resources.bookmarks_form_bookmark_type_Python3, ["value"] = BookmarkType.Ptyhon3.ToString(), }); } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/EnvironmentsCache.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/EnvironmentsCache.cs index c7aceb743b..1bd55075a1 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/EnvironmentsCache.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/EnvironmentsCache.cs @@ -6,15 +6,12 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.CmdPal.Ext.Bookmarks.Helpers; -// TODO: move to toolKit? +// TODO: move to common? public class EnvironmentsCache { - // singleton instance private static readonly Lazy _instance = new Lazy(() => new EnvironmentsCache()); public static EnvironmentsCache Instance => _instance.Value; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/IconHelper.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/IconHelper.cs index f0513c9df3..ec6be6aecd 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/IconHelper.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Helpers/IconHelper.cs @@ -5,7 +5,6 @@ using System; using Microsoft.CmdPal.Ext.Bookmarks.Models; using Microsoft.CommandPalette.Extensions.Toolkit; -using Microsoft.UI.Xaml; namespace Microsoft.CmdPal.Ext.Bookmarks.Helpers; diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs index 6c97f9915f..3ac4f0e304 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.IO; using System.Text.Json; using System.Text.Json.Nodes; using Microsoft.CmdPal.Ext.Bookmarks.Helpers; @@ -25,7 +24,7 @@ internal sealed partial class AddBookmarkForm : FormContent _bookmark = bookmark; var name = _bookmark?.Name ?? string.Empty; var url = _bookmark?.Bookmark ?? string.Empty; - var bookmarkType = _bookmark?.Type.ToString() ?? string.Empty; + var bookmarkType = _bookmark?.Type.ToString() ?? BookmarkType.Web.ToString(); var bookmarkTypeChoices = BookmarkTypeHelper.GetBookmarkChoices(); TemplateJson = $$""" @@ -36,35 +35,37 @@ internal sealed partial class AddBookmarkForm : FormContent "body": [ { "type": "Input.ChoiceSet", - "label": "{{Resources.bookmarks_form_bookmark_type}}", + "label": {{JsonSerializer.Serialize(Resources.bookmarks_form_bookmark_type)}}, "value": {{JsonSerializer.Serialize(bookmarkType)}}, "choices": {{bookmarkTypeChoices}}, "placeholder": "Placeholder text", - "id": "bookmarkType" + "id": "bookmarkType", + "isRequired": true, + "errorMessage": "{{JsonSerializer.Serialize(Resources.bookmarks_form_bookmarkType_required)}}" }, { "type": "Input.Text", "style": "text", "id": "name", - "label": "{{Resources.bookmarks_form_name_label}}", + "label": {{JsonSerializer.Serialize(Resources.bookmarks_form_name_label)}}, "value": {{JsonSerializer.Serialize(name)}}, "isRequired": true, - "errorMessage": "{{Resources.bookmarks_form_name_required}}" + "errorMessage": "{{JsonSerializer.Serialize(Resources.bookmarks_form_name_required)}}" }, { "type": "Input.Text", "style": "text", "id": "bookmark", "value": {{JsonSerializer.Serialize(url)}}, - "label": "{{Resources.bookmarks_form_bookmark_label}}", + "label": {{JsonSerializer.Serialize(Resources.bookmarks_form_bookmark_label)}}, "isRequired": true, - "errorMessage": "{{Resources.bookmarks_form_bookmark_required}}" + "errorMessage": "{{JsonSerializer.Serialize(Resources.bookmarks_form_bookmark_required)}}" } ], "actions": [ { "type": "Action.Submit", - "title": "{{Resources.bookmarks_form_save}}", + "title": {{JsonSerializer.Serialize(Resources.bookmarks_form_save)}}, "data": { "name": "name", "bookmark": "bookmark" diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/BookmarkPlaceholderForm.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/BookmarkPlaceholderForm.cs index 06fe0a99ce..49b7316f43 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/BookmarkPlaceholderForm.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/BookmarkPlaceholderForm.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; +using System.Text.Json; using System.Text.Json.Nodes; using System.Text.RegularExpressions; using Microsoft.CmdPal.Ext.Bookmarks.Command; @@ -63,7 +64,7 @@ internal sealed partial class BookmarkPlaceholderForm : FormContent "actions": [ { "type": "Action.Submit", - "title": "{{Resources.bookmarks_form_open}}", + "title": {{JsonSerializer.Serialize(Resources.bookmarks_form_open)}}, "data": { "placeholder": "placeholder" } diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs index d36246f731..29c4869885 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs @@ -141,6 +141,87 @@ namespace Microsoft.CmdPal.Ext.Bookmarks.Properties { } } + /// + /// Looks up a localized string similar to Command Prompt. + /// + public static string bookmarks_form_bookmark_type_CMD { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_CMD", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to File. + /// + public static string bookmarks_form_bookmark_type_File { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_File", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Folder. + /// + public static string bookmarks_form_bookmark_type_Folder { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_Folder", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PowerShell. + /// + public static string bookmarks_form_bookmark_type_PowerShell { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_PowerShell", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PWSH. + /// + public static string bookmarks_form_bookmark_type_PWSH { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_PWSH", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Python. + /// + public static string bookmarks_form_bookmark_type_Python { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_Python", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Python3. + /// + public static string bookmarks_form_bookmark_type_Python3 { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_Python3", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Web. + /// + public static string bookmarks_form_bookmark_type_web { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_type_web", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bookmark type is required.. + /// + public static string bookmarks_form_bookmarkType_required { + get { + return ResourceManager.GetString("bookmarks_form_bookmarkType_required", resourceCulture); + } + } + /// /// Looks up a localized string similar to Name. /// diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx index 59d9782412..9a2989c144 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx @@ -164,4 +164,31 @@ Bookmark Type + + Bookmark type is required. + + + Web + + + File + + + Folder + + + PWSH + + + PowerShell + + + Python + + + Python3 + + + Command Prompt + \ No newline at end of file