Fix i18n issue

This commit is contained in:
Yu Leng (from Dev Box)
2025-04-24 11:02:23 +08:00
parent 9f8a238e84
commit 923e33a067
7 changed files with 130 additions and 28 deletions

View File

@@ -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(),
});
}

View File

@@ -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<EnvironmentsCache> _instance = new Lazy<EnvironmentsCache>(() => new EnvironmentsCache());
public static EnvironmentsCache Instance => _instance.Value;

View File

@@ -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;

View File

@@ -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"

View File

@@ -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"
}

View File

@@ -141,6 +141,87 @@ namespace Microsoft.CmdPal.Ext.Bookmarks.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Command Prompt.
/// </summary>
public static string bookmarks_form_bookmark_type_CMD {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_CMD", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File.
/// </summary>
public static string bookmarks_form_bookmark_type_File {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_File", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Folder.
/// </summary>
public static string bookmarks_form_bookmark_type_Folder {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_Folder", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to PowerShell.
/// </summary>
public static string bookmarks_form_bookmark_type_PowerShell {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_PowerShell", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to PWSH.
/// </summary>
public static string bookmarks_form_bookmark_type_PWSH {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_PWSH", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Python.
/// </summary>
public static string bookmarks_form_bookmark_type_Python {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_Python", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Python3.
/// </summary>
public static string bookmarks_form_bookmark_type_Python3 {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_Python3", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Web.
/// </summary>
public static string bookmarks_form_bookmark_type_web {
get {
return ResourceManager.GetString("bookmarks_form_bookmark_type_web", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Bookmark type is required..
/// </summary>
public static string bookmarks_form_bookmarkType_required {
get {
return ResourceManager.GetString("bookmarks_form_bookmarkType_required", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Name.
/// </summary>

View File

@@ -164,4 +164,31 @@
<data name="bookmarks_form_bookmark_type" xml:space="preserve">
<value>Bookmark Type</value>
</data>
<data name="bookmarks_form_bookmarkType_required" xml:space="preserve">
<value>Bookmark type is required.</value>
</data>
<data name="bookmarks_form_bookmark_type_web" xml:space="preserve">
<value>Web</value>
</data>
<data name="bookmarks_form_bookmark_type_File" xml:space="preserve">
<value>File</value>
</data>
<data name="bookmarks_form_bookmark_type_Folder" xml:space="preserve">
<value>Folder</value>
</data>
<data name="bookmarks_form_bookmark_type_PWSH" xml:space="preserve">
<value>PWSH</value>
</data>
<data name="bookmarks_form_bookmark_type_PowerShell" xml:space="preserve">
<value>PowerShell</value>
</data>
<data name="bookmarks_form_bookmark_type_Python" xml:space="preserve">
<value>Python</value>
</data>
<data name="bookmarks_form_bookmark_type_Python3" xml:space="preserve">
<value>Python3</value>
</data>
<data name="bookmarks_form_bookmark_type_CMD" xml:space="preserve">
<value>Command Prompt</value>
</data>
</root>