Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion AssetEditor/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Windows;
using System.Windows.Threading;
using AssetEditor.Services;
Expand Down Expand Up @@ -56,9 +58,18 @@ protected override void OnStartup(StartupEventArgs e)
settingsService.AllowSettingsUpdate = true;
settingsService.Load();

// Auto-detect system language for first-time users
if (settingsService.CurrentSettings.IsFirstTimeStartingApplication)
{
var detectedLang = DetectSystemLanguage();
if (File.Exists($"Language_{detectedLang}.json"))
settingsService.CurrentSettings.SelectedLangauge = detectedLang;
settingsService.Save();
}

var localizationManager = _serviceProvider.GetRequiredService<LocalizationManager>();
localizationManager.GetPossibleLanguages();
localizationManager.LoadLanguage("en");
localizationManager.LoadLanguage(settingsService.CurrentSettings.SelectedLangauge);

// Show the settings window if its the first time the tool is ran
if (settingsService.CurrentSettings.IsFirstTimeStartingApplication)
Expand Down Expand Up @@ -93,6 +104,18 @@ private static void HandleFirstTimeSettings(IUiCommandFactory uiCommandFactory,
settingsService.Save();
}

private static string DetectSystemLanguage()
{
var twoLetter = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
return twoLetter switch
{
"zh" => "cn",
"en" => "en",
"fr" => "fr",
_ => "en"
};
}

private void LoadCAPackFiles(ApplicationSettingsService settingsService)
{
var gamePath = settingsService.GetGamePathForCurrentGame();
Expand Down
21 changes: 12 additions & 9 deletions AssetEditor/Language_Cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
"MenuBar.File.NewAnimPackWh3": "新建 AnimPack (战锤 III)",
"MenuBar.File.NewAnimPack3K": "新建 AnimPack (三国)",
"MenuBar.File.SaveActivePack": "保存当前 Pack",
"MenuBar.File.OpenPack": "打开 Pack",
"MenuBar.File.OpenProjectFolder": "打开项目",
"MenuBar.File.ImportPackAsProject": "将 Pack 导入为项目",
"MenuBar.File.ImportReferencePack": "导入参考项目",
"MenuBar.File.OpenRecentPacks": "打开最近的 Pack",
"MenuBar.File.OpenGamePacks": "打开游戏 Pack",
"MenuBar.File.GameAttila": "阿提拉",
Expand All @@ -124,7 +126,7 @@
"MenuBar.Tools": "工具",
"MenuBar.Reports": "报告",
"MenuBar.Reports.Rmv2": "Rmv2",
"MenuBar.Reports.RmvToText": "Rmv to Text",
"MenuBar.Reports.Bmd": "Bmd 地图报告",
"MenuBar.Reports.MetaData": "元数据",
"MenuBar.Reports.FileList": "文件列表",
"MenuBar.Reports.MetaJsons": "元 Json",
Expand Down Expand Up @@ -568,6 +570,7 @@
"FbxAnimationPanel.Browse": "浏览...",

"Dialog.Filter.Browse": "浏览",
"Dialog.Filter.Hide": "隐藏",

"KitbashTool.SaveDialog.Title": "保存",
"KitbashTool.SaveDialog.Path": "路径:",
Expand Down Expand Up @@ -883,11 +886,11 @@
"FbxSettingsDialog.Import": "导入",
"FbxSettingsDialog.Cancel": "取消",

"PackFileCache.InvalidReason.Title": "Cache Rebuild Required",
"PackFileCache.InvalidReason.NotFound": "No cache found for {0}. Building cache for the first time - this may take a moment.",
"PackFileCache.InvalidReason.DataChanged": "Game files for {0} have changed since the cache was built. Rebuilding cache.",
"PackFileCache.InvalidReason.Corrupted": "Cache for {0} is corrupted and will be rebuilt.",
"PackFileCache.BuildingCache": "Building pack file cache for {0}. This may take some time, please wait...",
"PackFileCache.BuildingCache.Title": "Building Cache",
"PackFileCache.Description": "The cache allows faster startup times and reduces memory usage by storing pre-processed game file data on disk."
"PackFileCache.InvalidReason.Title": "需要重建缓存",
"PackFileCache.InvalidReason.NotFound": "未找到 {0} 的缓存。首次构建缓存 - 这可能需要一些时间。",
"PackFileCache.InvalidReason.DataChanged": "{0} 的游戏文件自缓存构建后已更改。正在重建缓存。",
"PackFileCache.InvalidReason.Corrupted": "{0} 的缓存已损坏,将被重建。",
"PackFileCache.BuildingCache": "正在为 {0} 构建 Pack 文件缓存。这可能需要一些时间,请稍候...",
"PackFileCache.BuildingCache.Title": "正在构建缓存",
"PackFileCache.Description": "缓存通过将预处理的游戏文件数据存储在磁盘上来加快启动速度并减少内存使用。"
}
3 changes: 2 additions & 1 deletion AssetEditor/Language_En.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"MenuBar.Tools": "Tools",
"MenuBar.Reports": "Reports",
"MenuBar.Reports.Rmv2": "Rmv2",
"MenuBar.Reports.RmvToText": "Rmv to Text",
"MenuBar.Reports.Bmd": "Bmd Report",
"MenuBar.Reports.MetaData": "Meta Data",
"MenuBar.Reports.FileList": "File List",
"MenuBar.Reports.MetaJsons": "Meta Jsons",
Expand Down Expand Up @@ -570,6 +570,7 @@
"FbxAnimationPanel.Browse": "Browse...",

"Dialog.Filter.Browse": "Browse",
"Dialog.Filter.Hide": "Hide",

"KitbashTool.SaveDialog.Title": "Save",
"KitbashTool.SaveDialog.Path": "Path:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
// The .NET Foundation 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;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Extensions.DependencyInjection;
using Shared.Core.Services;
using Shared.Ui.Common;
using static CommonControls.FilterDialog.FilterUserControl;

namespace CommonControls.FilterDialog
Expand All @@ -22,13 +26,14 @@ public CollapsableFilterControl()
BrowseButton.Click += (a, b) => ToggleSearchFiled();
ClearButton.Click += (a, b) => ClearSelection();
FilterBox.Visibility = Visibility.Collapsed;
BrowseButton.Content = GetLocalizedString("Dialog.Filter.Browse");
}

void HandleItemDoubleClicked()
{
HandleOnItemSelected();
FilterBox.Visibility = Visibility.Collapsed;
BrowseButton.Content = "Browse";
BrowseButton.Content = GetLocalizedString("Dialog.Filter.Browse");
}

void HandleOnItemSelected()
Expand Down Expand Up @@ -64,14 +69,24 @@ void ToggleSearchFiled()
if (FilterBox.Visibility == Visibility.Visible)
{
FilterBox.Visibility = Visibility.Collapsed;
BrowseButton.Content = "Browse";
BrowseButton.Content = GetLocalizedString("Dialog.Filter.Browse");
}
else
{
BrowseButton.Content = "Hide";
BrowseButton.Content = GetLocalizedString("Dialog.Filter.Hide");
FilterBox.Visibility = Visibility.Visible;
}
}

private static string GetLocalizedString(string key)
{
if (Application.Current is IAssetEditorMain appMain)
{
var localizationManager = appMain.ServiceProvider.GetRequiredService<LocalizationManager>();
return localizationManager.Get(key);
}
return key;
}
#region properties

public FrameworkElement InnerContent
Expand Down
Loading