diff --git a/FoliCon/App.xaml.cs b/FoliCon/App.xaml.cs index c22a465..c5a0844 100644 --- a/FoliCon/App.xaml.cs +++ b/FoliCon/App.xaml.cs @@ -7,6 +7,7 @@ namespace FoliCon; /// /// Interaction logic for App.xaml /// +[Localizable(false)] public partial class App { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/FoliCon/Models/Constants/GlobalVariables.cs b/FoliCon/Models/Constants/GlobalVariables.cs index ddb51fa..02282b2 100644 --- a/FoliCon/Models/Constants/GlobalVariables.cs +++ b/FoliCon/Models/Constants/GlobalVariables.cs @@ -17,7 +17,7 @@ public static IconOverlay IconOverlayType() }; } - public static readonly string MediaInfoFile = "info.folicon"; + public const string MediaInfoFile = "info.folicon"; private static string IconOverlayTypeString => Services.Tracker.Store.GetData("PosterIconConfigViewModel")["p.IconOverlay"].ToString(); diff --git a/FoliCon/Models/Data/PosterIcon.cs b/FoliCon/Models/Data/PosterIcon.cs index 9d800dd..cc06d75 100644 --- a/FoliCon/Models/Data/PosterIcon.cs +++ b/FoliCon/Models/Data/PosterIcon.cs @@ -1,5 +1,6 @@ namespace FoliCon.Models.Data; +[Localizable(false)] public class PosterIcon: BindableBase { public ImageSource FolderJpg { get; set; } diff --git a/FoliCon/Models/Data/StatusBarData.cs b/FoliCon/Models/Data/StatusBarData.cs index a91f60f..143cd01 100644 --- a/FoliCon/Models/Data/StatusBarData.cs +++ b/FoliCon/Models/Data/StatusBarData.cs @@ -20,7 +20,7 @@ public class StatusBarData : BindableBase public void ResetData() { - AppStatus = LangProvider.GetLang("Idle"); + AppStatus = Lang.Idle; AppStatusAdditional = ""; ProcessedFolder = 0; TotalFolders = 0; diff --git a/FoliCon/Modules/Configuration/AppConfig.cs b/FoliCon/Modules/Configuration/AppConfig.cs index 3b3f3fb..b8f1bdd 100644 --- a/FoliCon/Modules/Configuration/AppConfig.cs +++ b/FoliCon/Modules/Configuration/AppConfig.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.Configuration; +[Localizable(false)] public class AppConfig : GlobalDataHelper { public string DevClientId { get; set; } diff --git a/FoliCon/Modules/Configuration/AssemblyInfo.cs b/FoliCon/Modules/Configuration/AssemblyInfo.cs index 8e0bafc..f5100b6 100644 --- a/FoliCon/Modules/Configuration/AssemblyInfo.cs +++ b/FoliCon/Modules/Configuration/AssemblyInfo.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.Configuration; +[Localizable(false)] internal static class AssemblyInfo { public static string GetVersion() diff --git a/FoliCon/Modules/Convertor/BoolToPermissionTextConvertor.cs b/FoliCon/Modules/Convertor/BoolToPermissionTextConvertor.cs index 80a32e3..4161aa4 100644 --- a/FoliCon/Modules/Convertor/BoolToPermissionTextConvertor.cs +++ b/FoliCon/Modules/Convertor/BoolToPermissionTextConvertor.cs @@ -1,12 +1,13 @@ namespace FoliCon.Modules.Convertor; +[Localizable(false)] public class BoolToPermissionTextConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is bool hasWritePermission) { - return hasWritePermission ? LangProvider.GetLang("WritePermissionAllowed") : LangProvider.GetLang("WritePermissionNotAllowed"); + return hasWritePermission ? Lang.WritePermissionAllowed : Lang.WritePermissionNotAllowed; } throw new InvalidOperationException("Must be a boolean value."); diff --git a/FoliCon/Modules/Convertor/ImageCacheConverter.cs b/FoliCon/Modules/Convertor/ImageCacheConverter.cs index 5c3b9c6..8ca7217 100644 --- a/FoliCon/Modules/Convertor/ImageCacheConverter.cs +++ b/FoliCon/Modules/Convertor/ImageCacheConverter.cs @@ -4,6 +4,7 @@ /// Converts an image path to a BitmapImage with caching to improve performance and thread safety. /// CREDIT: https://stackoverflow.com/a/37652158/8076598 /// +[Localizable(false)] public class ImageCacheConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/FoliCon/Modules/DeviantArt/DArt.cs b/FoliCon/Modules/DeviantArt/DArt.cs index 6ad9a4b..64506d8 100644 --- a/FoliCon/Modules/DeviantArt/DArt.cs +++ b/FoliCon/Modules/DeviantArt/DArt.cs @@ -2,29 +2,30 @@ namespace FoliCon.Modules.DeviantArt; +[Localizable(false)] public class DArt : BindableBase { private string _clientAccessToken; private string _clientSecret; - private string _clientId; + private readonly string _clientId; private readonly MemoryCache _cache = new(new MemoryCacheOptions()); private static readonly JsonSerializerSettings SerializerSettings = new() { NullValueHandling = NullValueHandling.Ignore }; - - public string ClientId + + private string ClientId { get => _clientId; - set => SetProperty(ref _clientId, value); + init => SetProperty(ref _clientId, value); } - public string ClientSecret + private string ClientSecret { get => _clientSecret; - set => SetProperty(ref _clientSecret, value); + init => SetProperty(ref _clientSecret, value); } - public string ClientAccessToken + private string ClientAccessToken { get => _clientAccessToken; set => SetProperty(ref _clientAccessToken, value); diff --git a/FoliCon/Modules/Extension/BindingPathExtensions.cs b/FoliCon/Modules/Extension/BindingPathExtensions.cs index 7cc3912..c9fa977 100644 --- a/FoliCon/Modules/Extension/BindingPathExtensions.cs +++ b/FoliCon/Modules/Extension/BindingPathExtensions.cs @@ -2,6 +2,7 @@ namespace FoliCon.Modules.Extension; +[Localizable(false)] public static class BindingPathExtensions { private static readonly ImageCacheConverter ImageCacheConverter = new (); diff --git a/FoliCon/Modules/Extension/DialogServiceExtensions.cs b/FoliCon/Modules/Extension/DialogServiceExtensions.cs index fa76cc3..94626a5 100644 --- a/FoliCon/Modules/Extension/DialogServiceExtensions.cs +++ b/FoliCon/Modules/Extension/DialogServiceExtensions.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.Extension; +[Localizable(false)] public static class DialogServiceExtensions { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/FoliCon/Modules/Extension/Extensions.cs b/FoliCon/Modules/Extension/Extensions.cs index 1b7af17..97b8d48 100644 --- a/FoliCon/Modules/Extension/Extensions.cs +++ b/FoliCon/Modules/Extension/Extensions.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.Extension; +[Localizable(false)] public static class Extensions { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/FoliCon/Modules/Extension/StreamExtension.cs b/FoliCon/Modules/Extension/StreamExtension.cs index 06857cf..616bc4e 100644 --- a/FoliCon/Modules/Extension/StreamExtension.cs +++ b/FoliCon/Modules/Extension/StreamExtension.cs @@ -5,6 +5,7 @@ namespace FoliCon.Modules.Extension; +[Localizable(false)] public static class StreamExtensions { private static readonly ReaderOptions ReaderOptions = new() { ArchiveEncoding = diff --git a/FoliCon/Modules/IGDB/IgdbDataTransformer.cs b/FoliCon/Modules/IGDB/IgdbDataTransformer.cs index 9e2268c..59cf4c5 100644 --- a/FoliCon/Modules/IGDB/IgdbDataTransformer.cs +++ b/FoliCon/Modules/IGDB/IgdbDataTransformer.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.IGDB; +[Localizable(false)] public class IgdbDataTransformer(ref List listDataTable, ref List imgDownloadList) { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/FoliCon/Modules/IGDB/IgdbService.cs b/FoliCon/Modules/IGDB/IgdbService.cs index 2eb6fc3..698c6f2 100644 --- a/FoliCon/Modules/IGDB/IgdbService.cs +++ b/FoliCon/Modules/IGDB/IgdbService.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.IGDB; +[Localizable(false)] public class IgdbService(ref IGDBClient serviceClient) { private const string ServiceClientIsNotInitialized = "Service Client is not initialized."; @@ -19,7 +20,7 @@ public async Task SearchGameAsync(string query) } var r = await _serviceClient.QueryAsync(IGDBClient.Endpoints.Games, - $"search \"{query}\"; fields artworks.image_id, name,first_release_date,total_rating,summary,cover.*;"); + $"""search "{query}"; fields artworks.image_id, name,first_release_date,total_rating,summary,cover.*;"""); return new ResultResponse { diff --git a/FoliCon/Modules/LangProvider.cs b/FoliCon/Modules/LangProvider.cs index 591de4d..ebd6986 100644 --- a/FoliCon/Modules/LangProvider.cs +++ b/FoliCon/Modules/LangProvider.cs @@ -2,6 +2,7 @@ namespace FoliCon.Properties.Langs; +[Localizable(false)] public class LangProvider : INotifyPropertyChanged { private static string _cultureInfoStr; diff --git a/FoliCon/Modules/Media/PngToIcoService.cs b/FoliCon/Modules/Media/PngToIcoService.cs index bf4c408..e12c9c7 100644 --- a/FoliCon/Modules/Media/PngToIcoService.cs +++ b/FoliCon/Modules/Media/PngToIcoService.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.Media; +[Localizable(false)] public static class PngToIcoService { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/FoliCon/Modules/TMDB/TMDBService.cs b/FoliCon/Modules/TMDB/TMDBService.cs index 1abab68..75d0a03 100644 --- a/FoliCon/Modules/TMDB/TMDBService.cs +++ b/FoliCon/Modules/TMDB/TMDBService.cs @@ -3,6 +3,7 @@ namespace FoliCon.Modules.TMDB; +[Localizable(false)] internal class TmdbService { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -114,8 +115,8 @@ public async Task SearchWithParamsAsync(ParsedTitle parsedTitle, { Logger.Debug("Searching for {ParsedTitle} in {SearchMode}", parsedTitle, searchMode); - var mediaType = ""; - object? searchResult = null; + string mediaType; + object? searchResult; switch (searchMode) { diff --git a/FoliCon/Modules/UI/CustomMessageBox.cs b/FoliCon/Modules/UI/CustomMessageBox.cs index 1af4e98..f03a866 100644 --- a/FoliCon/Modules/UI/CustomMessageBox.cs +++ b/FoliCon/Modules/UI/CustomMessageBox.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.UI; +[Localizable(false)] internal static class CustomMessageBox { public static MessageBoxInfo Ask(string messageBoxText, string caption) @@ -11,8 +12,8 @@ public static MessageBoxInfo Ask(string messageBoxText, string caption) Button = MessageBoxButton.YesNo, IconBrushKey = ResourceToken.AccentBrush, IconKey = ResourceToken.AskGeometry, - YesContent = LangProvider.GetLang("Confirm"), - NoContent = LangProvider.GetLang("Cancel") + YesContent = Lang.Confirm, + NoContent = Lang.Cancel }; } public static MessageBoxInfo Error(string messageBoxText, string caption) @@ -24,7 +25,7 @@ public static MessageBoxInfo Error(string messageBoxText, string caption) Button = MessageBoxButton.OK, IconBrushKey = ResourceToken.AccentBrush, IconKey = ResourceToken.ErrorGeometry, - ConfirmContent = LangProvider.GetLang("OK") + ConfirmContent = Lang.OK }; } public static MessageBoxInfo Warning(string messageBoxText, string caption) @@ -36,7 +37,7 @@ public static MessageBoxInfo Warning(string messageBoxText, string caption) Button = MessageBoxButton.OK, IconBrushKey = ResourceToken.AccentBrush, IconKey = ResourceToken.WarningGeometry, - ConfirmContent = LangProvider.GetLang("OK") + ConfirmContent = Lang.OK }; } public static MessageBoxInfo Info(string messageBoxText, string caption) @@ -48,7 +49,7 @@ public static MessageBoxInfo Info(string messageBoxText, string caption) Button = MessageBoxButton.OK, IconBrushKey = ResourceToken.AccentBrush, IconKey = ResourceToken.InfoGeometry, - ConfirmContent = LangProvider.GetLang("OK") + ConfirmContent = Lang.OK }; } } \ No newline at end of file diff --git a/FoliCon/Modules/UI/FolderDragDropHelper.cs b/FoliCon/Modules/UI/FolderDragDropHelper.cs index 9cd1e23..6c99f37 100644 --- a/FoliCon/Modules/UI/FolderDragDropHelper.cs +++ b/FoliCon/Modules/UI/FolderDragDropHelper.cs @@ -59,7 +59,7 @@ private static void Control_DragOver(object sender, DragEventArgs e) var dt = e.Data.GetData(DataFormats.FileDrop); var data = (dt as Array)?.GetValue(0)?.ToString(); - Logger.Trace("Control_DragOver: Data: {Data}", data ?? "null"); + Logger.Trace("Control_DragOver: Data: {Data}", data); e.Effects = Directory.Exists(data) ? DragDropEffects.Link : DragDropEffects.None; e.Handled = true; diff --git a/FoliCon/Modules/UI/HandyWindow.cs b/FoliCon/Modules/UI/HandyWindow.cs index de5d93b..fc68288 100644 --- a/FoliCon/Modules/UI/HandyWindow.cs +++ b/FoliCon/Modules/UI/HandyWindow.cs @@ -3,6 +3,7 @@ namespace FoliCon.Modules.UI; +[Localizable(false)] public class HandyWindow : Window, IDialogWindow { static HandyWindow() diff --git a/FoliCon/Modules/UI/ListViewClickSortBehavior.cs b/FoliCon/Modules/UI/ListViewClickSortBehavior.cs index 56e5b4d..421c1e7 100644 --- a/FoliCon/Modules/UI/ListViewClickSortBehavior.cs +++ b/FoliCon/Modules/UI/ListViewClickSortBehavior.cs @@ -62,7 +62,7 @@ private void OnClick(object sender, RoutedEventArgs e) ? Application.Current.Resources["HeaderTemplateArrowUp"] as DataTemplate : Application.Current.Resources["HeaderTemplateArrowDown"] as DataTemplate; - // Remove arrow from previously sorted header + // Remove arrow from the previously sorted header if (_lastHeaderClicked != null && _lastHeaderClicked != headerClicked) { _lastHeaderClicked.Column.HeaderTemplate = null; diff --git a/FoliCon/Modules/utils/CultureUtils.cs b/FoliCon/Modules/utils/CultureUtils.cs index 1b3a98f..8a2a51b 100644 --- a/FoliCon/Modules/utils/CultureUtils.cs +++ b/FoliCon/Modules/utils/CultureUtils.cs @@ -1,24 +1,25 @@ namespace FoliCon.Modules.utils; +[Localizable(false)] public static class CultureUtils { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); + private static readonly Dictionary LanguageCodes = new() + { + { Languages.English, "en-US" }, + { Languages.Spanish, "es-MX" }, + { Languages.Arabic, "ar-SA" }, + { Languages.Russian, "ru-RU" }, + { Languages.Hindi, "hi-IN" }, + { Languages.Portuguese, "pt-PT" } + }; + public static CultureInfo GetCultureInfoByLanguage(Languages language) { Logger.Debug("Getting CultureInfo by Language: {Language}", language); - - var languageCodes = new Dictionary - { - { Languages.English, "en-US" }, - { Languages.Spanish, "es-MX" }, - { Languages.Arabic, "ar-SA" }, - { Languages.Russian, "ru-RU" }, - { Languages.Hindi, "hi-IN" }, - { Languages.Portuguese, "pt-PT" } - }; - - var langCode = languageCodes.GetValueOrDefault(language, "en-US"); + + var langCode = LanguageCodes.GetValueOrDefault(language, "en-US"); ConfigHelper.Instance.SetLang(langCode.Split("-")[0]); return new CultureInfo(langCode); diff --git a/FoliCon/Modules/utils/DataUtils.cs b/FoliCon/Modules/utils/DataUtils.cs index cb4c1f6..6c3d65a 100644 --- a/FoliCon/Modules/utils/DataUtils.cs +++ b/FoliCon/Modules/utils/DataUtils.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.utils; +[Localizable(false)] public static class DataUtils { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -24,10 +25,10 @@ public static int GetResultCount(bool isPickedById, dynamic result, string searc /// Formatted Rating value. public static string FormatRating(double ratingInput) { - Logger.Debug("Start FormatRatingString() - Input received : {RatingInput}", ratingInput); + Logger.Trace("Start FormatRatingString() - Input received : {RatingInput}", ratingInput); var decimalPart = ratingInput % 1; var formattedRatingValue = decimalPart > 0 ? ratingInput.ToString("0.##") : ratingInput.ToString("0"); - Logger.Debug("End FormatRatingString() - Formatted Rating : {FormattedRatingValue}", formattedRatingValue); + Logger.Trace("End FormatRatingString() - Formatted Rating : {FormattedRatingValue}", formattedRatingValue); return formattedRatingValue; } diff --git a/FoliCon/Modules/utils/DialogUtils.cs b/FoliCon/Modules/utils/DialogUtils.cs index 02d2a08..860a312 100644 --- a/FoliCon/Modules/utils/DialogUtils.cs +++ b/FoliCon/Modules/utils/DialogUtils.cs @@ -16,10 +16,10 @@ public static void ShowGrowlInfo(string message) public static void ConfirmUpdate(ReleaseInfo ver) { - var message = LangProvider.GetLang("NewVersionFound") + var message = Lang.NewVersionFound .Format(ver.TagName, ver.Changelog.Replace("\\n", Environment.NewLine)); - var confirmMessage = LangProvider.GetLang("UpdateNow"); - var cancelMessage = LangProvider.GetLang("Ignore"); + var confirmMessage = Lang.UpdateNow; + var cancelMessage = Lang.Ignore; var info = new GrowlInfo { @@ -54,10 +54,7 @@ public static VistaFolderBrowserDialog NewFolderBrowserDialog(string description }; return folderBrowser; } - public static VistaOpenFileDialog NewOpenFileDialog(string description) - { - return NewOpenFileDialog(description, "All files (*.*)|*.*"); - } + public static VistaOpenFileDialog NewOpenFileDialog(string description, string filter) { Logger.Debug("Creating New Open File Dialog"); diff --git a/FoliCon/Modules/utils/FileUtils.cs b/FoliCon/Modules/utils/FileUtils.cs index 2773c08..c9b6918 100644 --- a/FoliCon/Modules/utils/FileUtils.cs +++ b/FoliCon/Modules/utils/FileUtils.cs @@ -229,14 +229,14 @@ public static void SaveMediaInfo(int id, string mediaType, string folderPath) mediaType, filePath).Log(); MessageBox.Show(CustomMessageBox.Error( e.Message.Contains("The process cannot access the file") - ? LangProvider.GetLang("FileIsInUse") - : LangProvider.GetLang("FailedToSaveMediaInfoAt").Format(filePath), LangProvider.GetLang("UnauthorizedAccess"))); + ? Lang.FileIsInUse + : Lang.FailedToSaveMediaInfoAt.Format(filePath), Lang.UnauthorizedAccess)); } catch (Exception e) { Logger.ForExceptionEvent(e, LogLevel.Error).Message("Error Occurred while Saving Media Info, ID: {Id}, Media Type: {MediaType}, Folder Path: {FolderPath}", id, mediaType, folderPath).Log(); - CustomMessageBox.Error(e.Message, LangProvider.GetLang("ExceptionOccurred")); + CustomMessageBox.Error(e.Message, Lang.ExceptionOccurred); } } @@ -337,7 +337,7 @@ public static async Task CheckForUpdate(bool onlyShowIfUpdateAvailable) if (!ApplicationHelper.IsConnectedToInternet()) { - DialogUtils.ShowGrowlError(LangProvider.GetLang("NetworkNotAvailable")); + DialogUtils.ShowGrowlError(Lang.NetworkNotAvailable); return; } @@ -349,7 +349,7 @@ public static async Task CheckForUpdate(bool onlyShowIfUpdateAvailable) if (!onlyShowIfUpdateAvailable) { - DialogUtils.ShowGrowlInfo(LangProvider.GetLang("ThisIsLatestVersion")); + DialogUtils.ShowGrowlInfo(Lang.ThisIsLatestVersion); } return; @@ -363,8 +363,8 @@ public static void HandleUnauthorizedAccessException(UnauthorizedAccessException { MessageBox.Show(CustomMessageBox.Error( ex.Message.Contains("The process cannot access the file") - ? LangProvider.GetLang("FileIsInUse") - : LangProvider.GetLang("FailedFileAccessAt").Format(path), LangProvider.GetLang("ExceptionOccurred"))); + ? Lang.FileIsInUse + : Lang.FailedFileAccessAt.Format(path), Lang.ExceptionOccurred)); } /// diff --git a/FoliCon/Modules/utils/ProcessUtils.cs b/FoliCon/Modules/utils/ProcessUtils.cs index ade59d1..ee77325 100644 --- a/FoliCon/Modules/utils/ProcessUtils.cs +++ b/FoliCon/Modules/utils/ProcessUtils.cs @@ -43,8 +43,8 @@ public static void CheckWebView2() { Logger.ForErrorEvent().Message("WebView2 Runtime is not installed.").Exception(exception).Log(); - var result = MessageBox.Show(CustomMessageBox.Ask(LangProvider.GetLang("WebView2DownloadConfirmation"), - LangProvider.GetLang("WebView2DownloadConfirmationHeader"))); + var result = MessageBox.Show(CustomMessageBox.Ask(Lang.WebView2DownloadConfirmation, + Lang.WebView2DownloadConfirmationHeader)); if (result != MessageBoxResult.Yes) { return; @@ -136,15 +136,15 @@ public static IDictionary GetCmdArgs() return arguments; } - public static bool? IfNotAdminRestartAsAdmin() + private static bool? IfNotAdminRestartAsAdmin() { if (ApplicationHelper.IsAdministrator()) { Logger.Info("Application is running as Administrator"); return null; } - if (MessageBox.Show(CustomMessageBox.Ask(LangProvider.GetLang("RestartAsAdmin"), - LangProvider.GetLang("Error"))) != MessageBoxResult.Yes) + if (MessageBox.Show(CustomMessageBox.Ask(Lang.RestartAsAdmin, + Lang.ExceptionOccurred)) != MessageBoxResult.Yes) { return false; } diff --git a/FoliCon/Modules/utils/StaTask.cs b/FoliCon/Modules/utils/StaTask.cs index c884f12..d94b8e4 100644 --- a/FoliCon/Modules/utils/StaTask.cs +++ b/FoliCon/Modules/utils/StaTask.cs @@ -1,6 +1,7 @@ namespace FoliCon.Modules.utils; //Taken from-https://stackoverflow.com/a/16722767/8076598 +[Localizable(false)] public static class StaTask { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/FoliCon/Modules/utils/TitleCleaner.cs b/FoliCon/Modules/utils/TitleCleaner.cs index 90c79e4..00d9b2c 100644 --- a/FoliCon/Modules/utils/TitleCleaner.cs +++ b/FoliCon/Modules/utils/TitleCleaner.cs @@ -1,5 +1,6 @@ namespace FoliCon.Modules.utils; +[Localizable(false)] internal static class TitleCleaner { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); diff --git a/FoliCon/ViewModels/AboutBoxViewModel.cs b/FoliCon/ViewModels/AboutBoxViewModel.cs index d78fcd0..0811803 100644 --- a/FoliCon/ViewModels/AboutBoxViewModel.cs +++ b/FoliCon/ViewModels/AboutBoxViewModel.cs @@ -1,16 +1,17 @@ namespace FoliCon.ViewModels; +[Localizable(false)] public class AboutBoxViewModel : BindableBase, IDialogAware { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private string _title = AssemblyInfo.GetVersionWithoutBuild(); private string _logo = "/Resources/icons/folicon Icon.png"; - private string _description = LangProvider.GetLang("FoliConDescription"); + private string _description = Lang.FoliConDescription; private string _website = "https://aprogrammers.wordpress.com"; - private string _additionalNotes = LangProvider.GetLang("DevelopedByDinesh"); - private string _license = LangProvider.GetLang("LicenseInfo"); + private string _additionalNotes = Lang.DevelopedByDinesh; + private string _license = Lang.LicenseInfo; private string _version = AssemblyInfo.GetVersion(); //These properties can also be initialized from Parameters for better re-usability. or From assembly diff --git a/FoliCon/ViewModels/ApiConfigurationViewModel.cs b/FoliCon/ViewModels/ApiConfigurationViewModel.cs index 99d4938..cbcdc11 100644 --- a/FoliCon/ViewModels/ApiConfigurationViewModel.cs +++ b/FoliCon/ViewModels/ApiConfigurationViewModel.cs @@ -2,7 +2,7 @@ public class ApiConfigurationViewModel : BindableBase, IDialogAware { - private string _title = "API Configuration"; + private string _title = Lang.APIKeysConfiguration; private string _dartClient; private string _dartClientId; private string _tmdbKey; diff --git a/FoliCon/ViewModels/CustomIconControlViewModel.cs b/FoliCon/ViewModels/CustomIconControlViewModel.cs index 14a4a43..4fcdf18 100644 --- a/FoliCon/ViewModels/CustomIconControlViewModel.cs +++ b/FoliCon/ViewModels/CustomIconControlViewModel.cs @@ -4,6 +4,7 @@ namespace FoliCon.ViewModels; +[Localizable(false)] public class CustomIconControlViewModel : BindableBase, IDialogAware, IFileDragDropTarget { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -17,12 +18,12 @@ public class CustomIconControlViewModel : BindableBase, IDialogAware, IFileDragD private bool _keepExactOnly; private bool _isBusy; private bool _stopSearch; - public string Title => LangProvider.GetLang("CustomIconSetter"); + public string Title => Lang.CustomIconSetter; private ObservableCollection _undoDirectories = []; private ObservableCollection _backupDirectories = []; private ObservableCollection _backupIcons = []; - private string _busyContent = LangProvider.GetLang("CreatingIcons"); + private string _busyContent = Lang.CreatingIcons; private int _index; private int _totalIcons; public bool KeepExactOnly @@ -54,7 +55,7 @@ public bool IsUndoEnable set => SetProperty(ref _isUndoEnable, value); } - public string SelectedDirectory + private string SelectedDirectory { get => _selectedDirectory; set @@ -69,7 +70,7 @@ public string SelectedDirectory } } - public string SelectedIconsDirectory + private string SelectedIconsDirectory { get => _selectedIconsDirectory; set @@ -88,17 +89,17 @@ public string SelectedIconsDirectory public ObservableCollection Directories { get => _directories; - set => SetProperty(ref _directories, value); + private set => SetProperty(ref _directories, value); } public ObservableCollection Icons { get => _icons; - set => SetProperty(ref _icons, value); + private set => SetProperty(ref _icons, value); } public int Index { get => _index; set => SetProperty(ref _index, value); } public int TotalIcons { get => _totalIcons; set => SetProperty(ref _totalIcons, value); } - public bool StopSearch { get => _stopSearch; set => SetProperty(ref _stopSearch, value); } + private bool StopSearch { get => _stopSearch; set => SetProperty(ref _stopSearch, value); } #region Declare Delegates public DelegateCommand LoadDirectory { get; set; } @@ -145,7 +146,7 @@ private async void UndoCreatedIcons() var info = new GrowlInfo { - Message = LangProvider.GetLang("UndoSuccessful"), + Message = Lang.UndoSuccessful, ShowDateTime = false, StaysOpen = false }; @@ -159,7 +160,7 @@ private async void UndoCreatedIcons() private void LoadDirectoryMethod() { - var folderBrowserDialog = DialogUtils.NewFolderBrowserDialog(LangProvider.GetLang("SelectFolder")); + var folderBrowserDialog = DialogUtils.NewFolderBrowserDialog(Lang.SelectFolder); var dialogResult = folderBrowserDialog.ShowDialog(); if (dialogResult != null && (bool)!dialogResult) { @@ -173,7 +174,7 @@ private void LoadDirectoryMethod() private void LoadIconsMethod() { - var folderBrowserDialog = DialogUtils.NewFolderBrowserDialog(LangProvider.GetLang("SelectIconsDirectory")); + var folderBrowserDialog = DialogUtils.NewFolderBrowserDialog(Lang.SelectIconsDirectory); var dialogResult = folderBrowserDialog.ShowDialog(); if (dialogResult != null && (bool)!dialogResult) { @@ -201,7 +202,7 @@ protected virtual void CloseDialog(string parameter) RaiseRequestClose(new DialogResult(result)); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) => + protected virtual void RaiseRequestClose(IDialogResult dialogResult) => RequestClose?.Invoke(dialogResult); public virtual bool CanCloseDialog() => true; @@ -222,20 +223,20 @@ private void StartProcessing() if (Directories.Count <= 0 || SelectedDirectory is null) { Logger.Warn("No folders to process"); - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("NoFolderOrIconAlready"), LangProvider.GetLang("NoFoldersToProcess"))); + MessageBox.Show(CustomMessageBox.Error(Lang.NoFolderOrIconAlready, Lang.NoFoldersToProcess)); return; } if (Icons.Count <= 0 || SelectedIconsDirectory is null) { - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("NoIconsSelected"), LangProvider.GetLang("NoIconsToApply"))); + MessageBox.Show(CustomMessageBox.Error(Lang.NoIconsSelected, Lang.NoIconsToApply)); return; } var iconProcessedCount = MakeIcons(); var info = new GrowlInfo { - Message = LangProvider.GetLang("IconCreatedWithCount").Format(iconProcessedCount), + Message = Lang.IconCreatedWithCount.Format(iconProcessedCount), ShowDateTime = false, StaysOpen = false }; @@ -246,8 +247,8 @@ private void StartProcessing() Growl.SuccessGlobal(info); if (MessageBox.Show( CustomMessageBox.Ask( - $"{LangProvider.GetLang("IconReloadMayTakeTime")} {Environment.NewLine}{LangProvider.GetLang("ToForceReload")} {Environment.NewLine}{LangProvider.GetLang("ConfirmToOpenFolder")}", - LangProvider.GetLang("IconCreated"))) == MessageBoxResult.Yes) + $"{Lang.IconReloadMayTakeTime} {Environment.NewLine}{Lang.ToForceReload} {Environment.NewLine}{Lang.ConfirmToOpenFolder}", + Lang.IconCreated)) == MessageBoxResult.Yes) { ProcessUtils.StartProcess(SelectedDirectory + Path.DirectorySeparatorChar); } diff --git a/FoliCon/ViewModels/DialogControlViewModel.cs b/FoliCon/ViewModels/DialogControlViewModel.cs index c2a1e95..1f3ee5c 100644 --- a/FoliCon/ViewModels/DialogControlViewModel.cs +++ b/FoliCon/ViewModels/DialogControlViewModel.cs @@ -13,7 +13,7 @@ public class DialogControlViewModel : BindableBase, IDialogAware public string Message { get => _message; - set => SetProperty(ref _message, value); + private set => SetProperty(ref _message, value); } private string _title = "Notification"; @@ -21,7 +21,7 @@ public string Message public string Title { get => _title; - set => SetProperty(ref _title, value); + private set => SetProperty(ref _title, value); } public event Action RequestClose; @@ -39,7 +39,7 @@ protected virtual void CloseDialog(string parameter) RaiseRequestClose(new DialogResult(result)); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) + protected virtual void RaiseRequestClose(IDialogResult dialogResult) { RequestClose?.Invoke(dialogResult); } diff --git a/FoliCon/ViewModels/MainWindowViewModel.cs b/FoliCon/ViewModels/MainWindowViewModel.cs index bced57d..f486670 100644 --- a/FoliCon/ViewModels/MainWindowViewModel.cs +++ b/FoliCon/ViewModels/MainWindowViewModel.cs @@ -62,7 +62,7 @@ public bool IsSearchModeVisible public ListViewData FinalListViewData { get => _finalListViewData; - set => SetProperty(ref _finalListViewData, value); + private set => SetProperty(ref _finalListViewData, value); } private readonly IDialogService _dialogService; @@ -70,7 +70,7 @@ public ListViewData FinalListViewData private DirectoryPermissionsResult _directoryPermissionResult; public StatusBarData StatusBarProperties { get; set; } public ProgressBarData BusyIndicatorProperties { get => _busyIndicatorProperties; set => SetProperty(ref _busyIndicatorProperties, value); } - public List Fnames { get; set; } = []; + private List Fnames { get; set; } = []; public bool IsMakeEnabled { @@ -84,13 +84,13 @@ public bool IsSkipAmbiguous set => SetProperty(ref _isSkipAmbiguous, value); } - public bool StopIconDownload + private bool StopIconDownload { get => _stopIconDownload; set => SetProperty(ref _stopIconDownload, value); } - public string IconMode + private string IconMode { get => _iconMode; set @@ -100,7 +100,7 @@ public string IconMode } } - public string SearchMode + private string SearchMode { get => _searchMode; set => SetProperty(ref _searchMode, value); @@ -200,8 +200,8 @@ public FoliconThemes Theme public DelegateCommand RestartExCommand { get; } = new(delegate { - if (MessageBox.Show(CustomMessageBox.Ask(LangProvider.GetLang("RestartExplorerConfirmation"), - LangProvider.GetLang("ConfirmExplorerRestart"))) != MessageBoxResult.Yes) + if (MessageBox.Show(CustomMessageBox.Ask(Lang.RestartExplorerConfirmation, + Lang.ConfirmExplorerRestart)) != MessageBoxResult.Yes) { return; } @@ -260,7 +260,7 @@ private void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvai private void LoadMethod() { - var folderBrowserDialog = DialogUtils.NewFolderBrowserDialog(LangProvider.GetLang("SelectFolder")); + var folderBrowserDialog = DialogUtils.NewFolderBrowserDialog(Lang.SelectFolder); if (!SelectedFolder.IsNullOrEmpty()) { folderBrowserDialog.SelectedPath = SelectedFolder; @@ -329,14 +329,14 @@ private bool ValidateFolder() } Logger.Warn("SearchAndMakeMethod: Folder is empty: {SelectedFolder}", SelectedFolder); - MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("IconsAlready"), - LangProvider.GetLang("FolderError"))); + MessageBox.Show(CustomMessageBox.Warning(Lang.IconsAlready, + Lang.FolderError)); return false; } Logger.Error("Folder does not exist: {SelectedFolder}", SelectedFolder); - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("FolderDoesNotExist"), - LangProvider.GetLang("InvalidPath"))); + MessageBox.Show(CustomMessageBox.Error(Lang.FolderDoesNotExist, + Lang.InvalidPath)); return false; } @@ -347,8 +347,8 @@ private static bool ValidateNetwork() return true; } - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("NoInternet"), - LangProvider.GetLang("NetworkError"))); + MessageBox.Show(CustomMessageBox.Error(Lang.NoInternet, + Lang.NetworkError)); return false; } @@ -376,7 +376,7 @@ private async Task DownloadIconsOrEnableMake() StatusBarProperties.TotalIcons = BusyIndicatorProperties.Max = StatusBarProperties.ProgressBarData.Max = _imgDownloadList.Count; BusyIndicatorProperties.Text = - LangProvider.GetLang("DownloadingIconWithCount").Format(1, _imgDownloadList.Count); + Lang.DownloadingIconWithCount.Format(1, _imgDownloadList.Count); if (_imgDownloadList.Count > 0) { @@ -392,7 +392,7 @@ private void HandleException(Exception e) { Logger.ForErrorEvent().Message("SearchAndMakeMethod: Exception Occurred. message: {Message}", e.Message) .Exception(e).Log(); - MessageBox.Show(CustomMessageBox.Error(e.Message, LangProvider.GetLang("ExceptionOccurred"))); + MessageBox.Show(CustomMessageBox.Error(e.Message, Lang.ExceptionOccurred)); StatusBarProperties.ResetData(); IsMakeEnabled = true; IsBusy = false; @@ -405,7 +405,7 @@ private async Task ProcessPosterModeAsync() IsMakeEnabled = false; await ProcessPosterFolderAsync(SelectedFolder); - StatusBarProperties.AppStatus = "Idle"; + StatusBarProperties.AppStatus = Lang.Idle; StatusBarProperties.AppStatusAdditional = ""; } @@ -497,7 +497,7 @@ private static void ProcessSubfolders(string folderPath, Queue folderQue private async Task<(ResultResponse response, ParsedTitle parsedTitle, bool isPickedById, string mediaType)> PerformPreprocessing(string itemTitle, string fullFolderPath) { - StatusBarProperties.AppStatus = "Searching"; + StatusBarProperties.AppStatus = Lang.Searching; StatusBarProperties.AppStatusAdditional = itemTitle; var parsedTitle = TitleCleaner.CleanAndParse(itemTitle); var (id, mediaType) = FileUtils.ReadMediaInfo(fullFolderPath); @@ -547,8 +547,8 @@ private int CalculateResultCount(ResultResponse response, bool isPickedById) string parsedTitle, bool isPickedById) { Logger.Debug("No result found for {ItemTitle}, {Mode}", itemTitle, SearchMode); - MessageBox.Show(CustomMessageBox.Info(LangProvider.GetLang("NothingFoundFor").Format(itemTitle), - LangProvider.GetLang("NoResultFound"))); + MessageBox.Show(CustomMessageBox.Info(Lang.NothingFoundFor.Format(itemTitle), + Lang.NoResultFound)); return await ShowSearchResultDialog(parsedTitle, fullFolderPath, response, isPickedById); } @@ -580,10 +580,10 @@ private void ProcessSingleResultCase(string itemTitle, ResultResponse response, .Exception(ex).Log(); if (ex.Message == "NoPoster") { - MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), itemTitle)); + MessageBox.Show(CustomMessageBox.Warning(Lang.NoPosterFound, itemTitle)); } #if DEBUG - MessageBox.Show(CustomMessageBox.Warning(ex.Message, LangProvider.GetLang("ExceptionOccurred"))); + MessageBox.Show(CustomMessageBox.Warning(ex.Message, Lang.ExceptionOccurred)); #endif } } @@ -652,7 +652,7 @@ private void ProcessProfessionalMode(string initialFolderPath) continue; } StatusBarProperties.TotalFolders+= subfolderNames.Count; - StatusBarProperties.AppStatus = "Searching"; + StatusBarProperties.AppStatus = Lang.Searching; _dialogService.ShowProSearchResult(folderPath, subfolderNames, _pickedListDataTable, _imgDownloadList, _dArtObject, _ => { }); Logger.Debug("ProcessProfessionalMode: found {ResultCount} results, adding to final list", _pickedListDataTable.Count); @@ -729,8 +729,8 @@ private void DeleteMediaInfo() { if (Directory.Exists(SelectedFolder)) { - if (MessageBox.Show(CustomMessageBox.Ask(LangProvider.GetLang("DeleteMediaInfoConfirmation"), - LangProvider.GetLang("ConfirmMediaInfoDeletion"))) == MessageBoxResult.Yes) + if (MessageBox.Show(CustomMessageBox.Ask(Lang.DeleteMediaInfoConfirmation, + Lang.ConfirmMediaInfoDeletion)) == MessageBoxResult.Yes) { FileUtils.DeleteMediaInfoFromSubfolders(SelectedFolder); } @@ -738,15 +738,15 @@ private void DeleteMediaInfo() else { Logger.Debug("DeleteMediaInfoMethod: Directory does not exist: {SelectedFolder}", SelectedFolder); - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("DirectoryIsEmpty"), - LangProvider.GetLang("EmptyDirectory"))); + MessageBox.Show(CustomMessageBox.Error(Lang.DirectoryIsEmpty, + Lang.EmptyDirectory)); } } catch (Exception e) { Logger.ForErrorEvent().Message("DeleteMediaInfoMethod: Exception Occurred. message: {Message}", e.Message) .Exception(e).Log(); - MessageBox.Show(CustomMessageBox.Error(e.Message, LangProvider.GetLang("ExceptionOccurred"))); + MessageBox.Show(CustomMessageBox.Error(e.Message, Lang.ExceptionOccurred)); } } @@ -758,7 +758,7 @@ private async Task InitializeProperties() { Max = 100, Value = 0, - Text = LangProvider.GetLang("DownloadIt") + Text = Lang.DownloadIt }; StatusBarProperties = new StatusBarData { @@ -817,8 +817,8 @@ private async void DeleteIconsMethod() { if (Directory.Exists(SelectedFolder)) { - if (MessageBox.Show(CustomMessageBox.Ask(LangProvider.GetLang("DeleteIconsConfirmation"), - LangProvider.GetLang("ConfirmIconDeletion"))) == MessageBoxResult.Yes) + if (MessageBox.Show(CustomMessageBox.Ask(Lang.DeleteIconsConfirmation, + Lang.ConfirmIconDeletion)) == MessageBoxResult.Yes) { await FileUtils.DeleteIconsFromSubfoldersAsync(SelectedFolder); } @@ -826,8 +826,8 @@ private async void DeleteIconsMethod() else { Logger.Debug("DeleteIconsMethod: Directory does not exist: {SelectedFolder}", SelectedFolder); - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("DirectoryIsEmpty"), - LangProvider.GetLang("EmptyDirectory"))); + MessageBox.Show(CustomMessageBox.Error(Lang.DirectoryIsEmpty, + Lang.EmptyDirectory)); } } catch (Exception e) @@ -867,7 +867,7 @@ private async Task StartDownloadingAsync() IsMakeEnabled = false; StatusBarProperties.AppStatus = LangProvider.GetLang("Creating Icons"); await DownloadAndMakeIconsAsync(); - StatusBarProperties.AppStatus = "Idle"; + StatusBarProperties.AppStatus = Lang.Idle; StatusBarProperties.AppStatusAdditional = ""; } @@ -905,12 +905,12 @@ private async Task DownloadAndMakeIconsAsync() " message: {Message}", e.Message) .Property("Image", img) .Log(); - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("FailedFileAccessAt").Format(Directory.GetParent(img.LocalPath)), - LangProvider.GetLang("UnauthorizedAccess"))); + MessageBox.Show(CustomMessageBox.Error(Lang.FailedFileAccessAt.Format(Directory.GetParent(img.LocalPath)), + Lang.UnauthorizedAccess)); continue; } i += 1; - BusyIndicatorProperties.Text = LangProvider.GetLang("DownloadingIconWithCount") + BusyIndicatorProperties.Text = Lang.DownloadingIconWithCount .Format(i, BusyIndicatorProperties.Max); BusyIndicatorProperties.Value = i; StatusBarProperties.ProgressBarData.Value = i; @@ -940,16 +940,16 @@ private async Task MakeIcons() IsBusy = false; var info = new GrowlInfo { - Message = LangProvider.GetLang("IconCreatedWithCount").Format(iconProcessedCount), + Message = Lang.IconCreatedWithCount.Format(iconProcessedCount), ShowDateTime = false, StaysOpen = false, - ConfirmStr = LangProvider.GetLang("Confirm") + ConfirmStr = Lang.Confirm }; Growl.SuccessGlobal(info); if (MessageBox.Show( CustomMessageBox.Ask( - $"{LangProvider.GetLang("IconReloadMayTakeTime")} {Environment.NewLine}{LangProvider.GetLang("ToForceReload")} {Environment.NewLine}{LangProvider.GetLang("ConfirmToOpenFolder")}", - LangProvider.GetLang("IconCreated"))) == MessageBoxResult.Yes) + $"{Lang.IconReloadMayTakeTime} {Environment.NewLine}{Lang.ToForceReload} {Environment.NewLine}{Lang.ConfirmToOpenFolder}", + Lang.IconCreated)) == MessageBoxResult.Yes) { ProcessUtils.StartProcess(SelectedFolder + Path.DirectorySeparatorChar); } @@ -974,9 +974,9 @@ private async Task InitializeClientObjects() return; } - MessageBox.Show(CustomMessageBox.Error($"{LangProvider.GetLang("APIKeysNotProvided")}{Environment.NewLine}" + - LangProvider.GetLang("AppWillClose"), - LangProvider.GetLang("ClosingApplication"))); + MessageBox.Show(CustomMessageBox.Error($"{Lang.APIKeysNotProvided}{Environment.NewLine}" + + Lang.AppWillClose, + Lang.ClosingApplication)); Logger.Warn("API Keys not provided, Closing Application."); Environment.Exit(0); }); diff --git a/FoliCon/ViewModels/ManualExplorerViewModel.cs b/FoliCon/ViewModels/ManualExplorerViewModel.cs index 3f3d34e..1eec5dd 100644 --- a/FoliCon/ViewModels/ManualExplorerViewModel.cs +++ b/FoliCon/ViewModels/ManualExplorerViewModel.cs @@ -1,5 +1,6 @@ namespace FoliCon.ViewModels; +[Localizable(false)] public class ManualExplorerViewModel : BindableBase, IDialogAware { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -18,7 +19,7 @@ private void PickMethod(object localImagePath) CloseDialog(ButtonResult.OK, (string)localImagePath); } - private string _title = LangProvider.GetLang("ManualExplorer"); + private string _title = Lang.ManualExplorer; private bool _isBusy; private ObservableCollection _directory; private DArt _dArtObject; @@ -28,9 +29,9 @@ private void PickMethod(object localImagePath) public string Title { get => _title; set => SetProperty(ref _title, value); } public bool IsBusy { get => _isBusy; set => SetProperty(ref _isBusy, value); } - public DArt DArtObject { get => _dArtObject; set => SetProperty(ref _dArtObject, value); } + private DArt DArtObject { get => _dArtObject; set => SetProperty(ref _dArtObject, value); } public ProgressBarData ProgressInfo { get => _progressInfo; set => SetProperty(ref _progressInfo, value); } - public DArtDownloadResponse DArtDownloadResponse { get => _dArtDownloadResponse; set => SetProperty(ref _dArtDownloadResponse, value); } + private DArtDownloadResponse DArtDownloadResponse { get => _dArtDownloadResponse; set => SetProperty(ref _dArtDownloadResponse, value); } public ObservableCollection Directory { get => _directory; set => SetProperty(ref _directory, value); } public DelegateCommand PickCommand { get; set; } @@ -68,7 +69,7 @@ protected virtual void CloseDialog(ButtonResult result, string localPath) RaiseRequestClose(new DialogResult(result, dialogParams)); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) + protected virtual void RaiseRequestClose(IDialogResult dialogResult) { RequestClose?.Invoke(dialogResult); } diff --git a/FoliCon/ViewModels/PosterPickerViewModel.cs b/FoliCon/ViewModels/PosterPickerViewModel.cs index 49c0d41..2f0f19a 100644 --- a/FoliCon/ViewModels/PosterPickerViewModel.cs +++ b/FoliCon/ViewModels/PosterPickerViewModel.cs @@ -3,6 +3,7 @@ namespace FoliCon.ViewModels; +[Localizable(false)] public class PosterPickerViewModel : BindableBase, IDialogAware { private const string PosterPathMessage = "Poster Path: {PosterPath}"; @@ -11,7 +12,7 @@ public class PosterPickerViewModel : BindableBase, IDialogAware private string _title = ""; private bool _stopSearch; private int _index; - private string _busyContent = LangProvider.GetLang("LoadingPosters"); + private string _busyContent = Lang.LoadingPosters; private bool _isBusy; public event Action RequestClose; private ResultResponse _result; @@ -68,7 +69,7 @@ protected virtual void CloseDialog(string parameter) RaiseRequestClose(new DialogResult(result)); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) + protected virtual void RaiseRequestClose(IDialogResult dialogResult) { RequestClose?.Invoke(dialogResult); } @@ -93,7 +94,8 @@ public void OnDialogOpened(IDialogParameters parameters) LoadData(); } - public async Task LoadData() + + private async Task LoadData() { var resultType = _result.MediaType; var response = GetResponse(resultType); @@ -249,7 +251,7 @@ private void AddImageToCollection(string qualityUrl, string thumbnailUrl, string private void HandleNoImagesFound() { Logger.Warn("No posters found for {Title}", Title); - MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), Title)); + MessageBox.Show(CustomMessageBox.Warning(Lang.NoPosterFound, Title)); } #endregion diff --git a/FoliCon/ViewModels/PreviewerViewModel.cs b/FoliCon/ViewModels/PreviewerViewModel.cs index a6c9267..806e547 100644 --- a/FoliCon/ViewModels/PreviewerViewModel.cs +++ b/FoliCon/ViewModels/PreviewerViewModel.cs @@ -1,5 +1,6 @@ namespace FoliCon.ViewModels { + [Localizable(false)] public class PreviewerViewModel : BindableBase, IDialogAware { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -25,7 +26,7 @@ public PreviewerViewModel() public PosterIcon PosterIconInstance { get => _posterIconInstance; - set => SetProperty(ref _posterIconInstance, value); + private set => SetProperty(ref _posterIconInstance, value); } public string Rating { @@ -73,7 +74,7 @@ public bool OverlayVisibility private void SelectImage() { Logger.Debug("Opening image selection dialog"); - var fileDialog = DialogUtils.NewOpenFileDialog(LangProvider.GetLang("ChooseAnImage"), "Image files (*.png, *.jpg, *.gif, *.bmp, *.ico)|*.png;*.jpg;*.gif;*.bmp;*.ico"); + var fileDialog = DialogUtils.NewOpenFileDialog(Lang.ChooseAnImage, "Image files (*.png, *.jpg, *.gif, *.bmp, *.ico)|*.png;*.jpg;*.gif;*.bmp;*.ico"); var selected = fileDialog.ShowDialog(); if (selected != null && (bool)!selected) diff --git a/FoliCon/ViewModels/ProSearchResultViewModel.cs b/FoliCon/ViewModels/ProSearchResultViewModel.cs index 94fae1e..a8e8544 100644 --- a/FoliCon/ViewModels/ProSearchResultViewModel.cs +++ b/FoliCon/ViewModels/ProSearchResultViewModel.cs @@ -2,15 +2,16 @@ namespace FoliCon.ViewModels; +[Localizable(false)] public class ProSearchResultViewModel : BindableBase, IDialogAware { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private string _title = LangProvider.GetLang("SearchResult"); + private string _title = Lang.SearchResult; private bool _stopSearch; private string _searchTitle; private string _searchAgainTitle; private int _i; - private string _busyContent = LangProvider.GetLang("Searching"); + private string _busyContent = Lang.Searching; private bool _isBusy; private DArt _dArtObject; private List _listDataTable; @@ -25,15 +26,16 @@ public class ProSearchResultViewModel : BindableBase, IDialogAware private string _folderPath; private bool _isSearchFocused; - public string Title { get => _title; set => SetProperty(ref _title, value); } + public string Title { get => _title; + private set => SetProperty(ref _title, value); } public ObservableCollection ImageUrl { get; set; } - public string SearchTitle { get => _searchTitle; set => SetProperty(ref _searchTitle, value); } + private string SearchTitle { get => _searchTitle; set => SetProperty(ref _searchTitle, value); } public bool StopSearch { get => _stopSearch; set => SetProperty(ref _stopSearch, value); } - public List Fnames { get; set; } + private List Fnames { get; set; } public string SearchAgainTitle { get => _searchAgainTitle; set => SetProperty(ref _searchAgainTitle, value); } public string BusyContent { get => _busyContent; set => SetProperty(ref _busyContent, value); } public bool IsBusy { get => _isBusy; set => SetProperty(ref _isBusy, value); } - public DArt DArtObject { get => _dArtObject; set => SetProperty(ref _dArtObject, value); } + private DArt DArtObject { get => _dArtObject; set => SetProperty(ref _dArtObject, value); } public int Index { get => _index; set => SetProperty(ref _index, value); } public int TotalPosters { get => _totalPosters; set => SetProperty(ref _totalPosters, value); } @@ -104,9 +106,9 @@ private async void PrepareForSearch() ImageUrl.Clear(); SearchTitle = null; SearchTitle = !string.IsNullOrEmpty(SearchAgainTitle) ? SearchAgainTitle : TitleCleaner.Clean(Fnames[_i]); - BusyContent = LangProvider.GetLang("SearchingWithName").Format(SearchTitle); + BusyContent = Lang.SearchingWithName.Format(SearchTitle); IsBusy = true; - Title = LangProvider.GetLang("PickIconWithName").Format(SearchTitle); + Title = Lang.PickIconWithName.Format(SearchTitle); await Search(SearchTitle); SearchAgainTitle = SearchTitle; IsBusy = false; @@ -151,8 +153,8 @@ private void ProcessNoResults(string query, int offset) { MessageBox.Show( CustomMessageBox.Error( - LangProvider.GetLang("NoResultFoundTryCorrectTitle"), - LangProvider.GetLang("NoResult") + Lang.NoResultFoundTryCorrectTitle, + Lang.NoResult ) ); } @@ -218,7 +220,7 @@ private void PickMethod(object parameter) var currentPath = $@"{_folderPath}\{Fnames[_i]}"; var tempImage = new ImageToDownload { - LocalPath = $"{currentPath}\\{IconUtils.GetImageName()}.png", + LocalPath = $@"{currentPath}\{IconUtils.GetImageName()}.png", RemotePath = new Uri(link) }; Logger.Debug("Adding Image to Download List {@Image}", tempImage); @@ -266,7 +268,7 @@ protected virtual void CloseDialog(string parameter) RaiseRequestClose(new DialogResult(result)); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) + protected virtual void RaiseRequestClose(IDialogResult dialogResult) { RequestClose?.Invoke(dialogResult); } diff --git a/FoliCon/ViewModels/SearchResultViewModel.cs b/FoliCon/ViewModels/SearchResultViewModel.cs index b282aa8..810471f 100644 --- a/FoliCon/ViewModels/SearchResultViewModel.cs +++ b/FoliCon/ViewModels/SearchResultViewModel.cs @@ -2,19 +2,20 @@ namespace FoliCon.ViewModels; +[Localizable(false)] public class SearchResultViewModel : BindableBase, IDialogAware { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); #region Variables - private string _title = LangProvider.GetLang("SearchResult"); + private string _title = Lang.SearchResult; private string _searchTitle; private string _busyContent; private bool _isBusy; private string _searchMode; private ListViewData _resultListViewData; private string _searchAgainTitle; - private string _skipAllText = LangProvider.GetLang("SkipThisPlaceholder"); + private string _skipAllText = Lang.SkipThisPlaceholder; private List _fileList; private ResultResponse _searchResult; private string _fullFolderPath; @@ -163,7 +164,7 @@ protected virtual void CloseDialog(string parameter, bool skipAll) RaiseRequestClose(new DialogResult(result, parameters)); } - public virtual void RaiseRequestClose(IDialogResult dialogResult) + protected virtual void RaiseRequestClose(IDialogResult dialogResult) { RequestClose?.Invoke(dialogResult); } @@ -189,7 +190,7 @@ public virtual void OnDialogOpened(IDialogParameters parameters) var parent = Directory.GetParent(_fullFolderPath); if (parent != null) { - SkipAllText = LangProvider.GetLang("SkipThisPlaceholderParent").Format(parent.Name); + SkipAllText = Lang.SkipThisPlaceholderParent.Format(parent.Name); } _dialogParams = new PosterPickerDialogParams { @@ -215,7 +216,7 @@ private async Task StartSearch(bool useBusy) _isPickedById = false; var titleToSearch = SearchAgainTitle ?? SearchTitle; Logger.Info("Searching for {TitleToSearch}", titleToSearch); - BusyContent = LangProvider.GetLang("SearchingWithName").Format(titleToSearch); + BusyContent = Lang.SearchingWithName.Format(titleToSearch); var result = SearchMode == MediaTypes.Game ? await _igdbObject.SearchGameAsync(titleToSearch.Replace(@"\", " ")) : await _tmdbObject.SearchAsync(titleToSearch.Replace(@"\", " "), SearchMode); @@ -320,7 +321,7 @@ private void PickMethod(MouseButtonEventArgs eventArgs) .Exception(ex) .Log(); MessageBox.Show(ex.Message == "NoPoster" - ? CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), SearchTitle) + ? CustomMessageBox.Warning(Lang.NoPosterFound, SearchTitle) : CustomMessageBox.Error(ex.Message, SearchTitle)); } @@ -345,7 +346,7 @@ private void MouseDoubleClick() if (SearchResult.MediaType == MediaTypes.Game && SearchResult.Result[pickedIndex].Artworks is null) { Logger.Warn("No more poster found for {SearchTitle}", SearchTitle); - MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), SearchTitle)); + MessageBox.Show(CustomMessageBox.Warning(Lang.NoPosterFound, SearchTitle)); return; } _dialogParams.PickedIndex = pickedIndex; @@ -360,7 +361,7 @@ private void MouseDoubleClick() .Log(); if (ex.Message == "NoPoster") { - MessageBox.Show(CustomMessageBox.Warning(LangProvider.GetLang("NoPosterFound"), SearchTitle)); + MessageBox.Show(CustomMessageBox.Warning(Lang.NoPosterFound, SearchTitle)); } } } diff --git a/FoliCon/ViewModels/SubfolderProcessingViewModel.cs b/FoliCon/ViewModels/SubfolderProcessingViewModel.cs index c942a30..8eba344 100644 --- a/FoliCon/ViewModels/SubfolderProcessingViewModel.cs +++ b/FoliCon/ViewModels/SubfolderProcessingViewModel.cs @@ -6,7 +6,7 @@ public class SubfolderProcessingViewModel : BindableBase, IDialogAware #region Variables private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public string Title => LangProvider.GetLang("SubfolderProcessing"); + public string Title => Lang.SubfolderProcessing; private ObservableCollection _patterns; private bool _subfolderProcessingEnabled; @@ -66,8 +66,8 @@ private bool IsValidPattern(string pattern) } if (!DataUtils.IsValidRegex(pattern)) { - MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("InvalidRegexMessage"), - LangProvider.GetLang("InvalidRegex"))); + MessageBox.Show(CustomMessageBox.Error(Lang.InvalidRegexMessage, + Lang.InvalidRegex)); } return false; } diff --git a/FoliCon/ViewModels/posterIconConfigViewModel.cs b/FoliCon/ViewModels/posterIconConfigViewModel.cs index a9083de..47b90ec 100644 --- a/FoliCon/ViewModels/posterIconConfigViewModel.cs +++ b/FoliCon/ViewModels/posterIconConfigViewModel.cs @@ -1,5 +1,6 @@ namespace FoliCon.ViewModels; +[Localizable(false)] public class PosterIconConfigViewModel : BindableBase, IDialogAware { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); @@ -10,7 +11,7 @@ public PosterIconConfigViewModel() { Logger.Debug("PosterIconConfigViewModel created"); Services.Tracker.Configure() - .Property(p => p.IconOverlay, defaultValue: "Liaher") + .Property(p => p.IconOverlay, defaultValue: Models.Enums.IconOverlay.Liaher.ToString()) .PersistOn(nameof(PropertyChanged)); Services.Tracker.Track(this); Logger.Info("Current IconOverlay is {IconOverlay}", IconOverlay); @@ -28,7 +29,7 @@ public string IconOverlay set => SetProperty(ref _iconOverlay, value); } - public string Title => LangProvider.GetLang("SelectPosterIconOverlay"); + public string Title => Lang.SelectPosterIconOverlay; #region DialogMethods diff --git a/FoliCon/Views/HtmlBox.xaml.cs b/FoliCon/Views/HtmlBox.xaml.cs index 5a2bc78..3271928 100644 --- a/FoliCon/Views/HtmlBox.xaml.cs +++ b/FoliCon/Views/HtmlBox.xaml.cs @@ -5,12 +5,15 @@ namespace FoliCon.Views; /// /// Interaction logic for HtmlBox.xaml /// +[Localizable(false)] public partial class HtmlBox { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private const string VideoUnavailable = "Video not available!"; private readonly string _backgroundColor; - + private const string DarkGray = "#1C1C1C"; + private const string White = "#FFFFFF"; + public static readonly DependencyProperty HtmlTextProperty = DependencyProperty.Register( nameof(HtmlText), @@ -18,12 +21,12 @@ public static readonly DependencyProperty HtmlTextProperty typeof(HtmlBox), new PropertyMetadata(default(string), OnHtmlTextPropertyChanged)); - public bool IsVideoAvailable { get; private set; } + private bool IsVideoAvailable { get; set; } public HtmlBox() { InitializeComponent(); - _backgroundColor = ThemeManager.Current.ApplicationTheme == ApplicationTheme.Dark ? "#1C1C1C" : "#FFFFFF"; + _backgroundColor = ThemeManager.Current.ApplicationTheme == ApplicationTheme.Dark ? DarkGray : White; } public string HtmlText diff --git a/FoliCon/Views/ImageGalleryControl.xaml.cs b/FoliCon/Views/ImageGalleryControl.xaml.cs index 6caa697..c434fbe 100644 --- a/FoliCon/Views/ImageGalleryControl.xaml.cs +++ b/FoliCon/Views/ImageGalleryControl.xaml.cs @@ -2,6 +2,7 @@ namespace FoliCon.Views; +[Localizable(false)] public partial class ImageGalleryControl {