Skip to content

Commit

Permalink
Merge pull request #1010 from AdmiringWorm/translating-null-values
Browse files Browse the repository at this point in the history
(#1003) Handle null keys during source translation
  • Loading branch information
gep13 committed Jun 7, 2023
2 parents b692313 + 77d302c commit 4022954
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/ChocolateyGui.Common/Utilities/TranslationSource.cs
@@ -1,4 +1,4 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Chocolatey" file="TranslationSource.cs">
// Copyright 2017 - Present Chocolatey Software, LLC
// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC
Expand Down Expand Up @@ -47,6 +47,14 @@ public CultureInfo CurrentCulture
{
get
{
if (string.IsNullOrEmpty(key))
{
// If the key is null we can't pass it to the resource manager.
// As it also doesn't make sense to pass in an empty value we check for both.
// We pass this empty string as we don't want anything to break even on empty values.
return string.Empty;
}

var value = _resourceManager.GetString(key, CurrentCulture);
#if DEBUG
if (string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(key))
Expand Down

0 comments on commit 4022954

Please sign in to comment.