Skip to content

Commit

Permalink
(chocolatey#533) Updated new translation strings to use dynamic language
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Jan 21, 2022
1 parent f34a1f9 commit 38dc322
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using chocolatey.infrastructure.app.utility;
using ChocolateyGui.Common.Properties;
using ChocolateyGui.Common.Providers;
using ChocolateyGui.Common.Utilities;
using IFileSystem = chocolatey.infrastructure.filesystem.IFileSystem;
using ILogger = Serilog.ILogger;

Expand Down Expand Up @@ -54,15 +55,15 @@ public IEnumerable<string> DecryptPackageArgumentsFile(string id, string version
}
catch (Exception ex)
{
var message = Resources.Application_PackageArgumentsError.format_with(version, id);
var message = L(nameof(Resources.Application_PackageArgumentsError), version, id);
Logger.Error(ex, message);
}

if (string.IsNullOrEmpty(arguments))
{
_dialogService.ShowMessageAsync(
string.Empty,
Resources.PackageView_UnableToFindArgumentsFile.format_with(version, id));
L(nameof(Resources.PackageView_UnableToFindArgumentsFile), version, id));
yield break;
}

Expand Down Expand Up @@ -98,5 +99,15 @@ public IEnumerable<string> DecryptPackageArgumentsFile(string id, string version
string.IsNullOrWhiteSpace(optionValue) ? string.Empty : "=" + optionValue);
}
}

private static string L(string key)
{
return TranslationSource.Instance[key];
}

private static string L(string key, params object[] parameters)
{
return TranslationSource.Instance[key, parameters];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public async Task ShowArguments()
var decryptedArguments = _packageArgumentsService.DecryptPackageArgumentsFile(Id, Version.ToString()).ToList();

await _dialogService.ShowMessageAsync(
Resources.PackageViewModel_ArgumentsForPackageFormat.format_with(Title),
L(nameof(Resources.PackageViewModel_ArgumentsForPackageFormat), Title),
string.Join(Environment.NewLine, decryptedArguments));
}

Expand Down
2 changes: 1 addition & 1 deletion Source/ChocolateyGui.Common.Windows/Views/PackageView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
Command="{commands:DataContextCommandAdapter ShowArguments}">
<StackPanel Orientation="Horizontal">
<iconPacks:PackIconEntypo Kind="Info" Margin="0 0 5 0 " VerticalAlignment="Center" />
<TextBlock Text="{x:Static properties:Resources.PackageView_ButtonPackageArguments}" FontSize="16"/>
<TextBlock Text="{lang:Localize PackageView_ButtonPackageArguments}" FontSize="16"/>
</StackPanel>
</Button>
<StackPanel Orientation="Horizontal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void CheckOperatingSystemCompatibility()
!_chocolateyConfigurationProvider.IsChocolateyExecutableBeingUsed)
{
// TODO: Possibly make these values translatable, do not use Resources directly, instead Use TranslationSource.Instance["KEY_NAME"];

ChocolateyMessageBox.Show(
"Usage of the PowerShell Version of Chocolatey (i.e. <= 0.9.8.33) has been detected. Chocolatey GUI does not support using this version of Chocolatey on Windows 10. Please update Chocolatey to the new C# Version (i.e. > 0.9.9.0) and restart Chocolatey GUI. This application will now close.",
"Incompatible Operating System Version",
Expand Down

0 comments on commit 38dc322

Please sign in to comment.