Skip to content

Commit 2de8fdf

Browse files
author
Federico Mazzanti
committed
hotfix when the default value is missing.
1 parent 9cfc74d commit 2de8fdf

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/Localization.Mvc/Localization.Mvc.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<NeutralLanguage>en</NeutralLanguage>
1414
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1515
<PackageId>Mafe.Localization.Mvc</PackageId>
16-
<Version>1.0.1</Version>
16+
<Version>1.0.2</Version>
1717
</PropertyGroup>
1818

1919
<ItemGroup>

src/Localization.Mvc/Rendering/HtmlHelperLabelExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static IHtmlContent TranslateLabelFor<TModel, TResult>(this IHtmlHelper<T
7979
TranslateAttribute attr;
8080
attr = (TranslateAttribute)type.GetProperty(propertyName).GetCustomAttributes(typeof(TranslateAttribute), true).SingleOrDefault();
8181

82-
var s = LocalizationManager.Translate(attr.ResourceKey, attr.DefaultValue);
82+
var s = LocalizationManager.Translate(attr.ResourceKey, attr.DefaultValue ?? attr.ResourceKey);
8383

8484
IHtmlContent html = htmlHelper.LabelFor(expression, labelText: s);
8585
return html;
@@ -98,7 +98,7 @@ public static IHtmlContent TranslateLabelFor<TModel, TResult>(this IHtmlHelper<T
9898
/// <returns>A new Microsoft.AspNetCore.Html.IHtmlContent containing the <label> element.</returns>
9999
public static IHtmlContent TranslateLabel<TModel>(this IHtmlHelper<TModel> htmlHelper, string expression, string resourceKey, string defaultValue, object htmlAttributes = null)
100100
{
101-
var labelText = LocalizationManager.Translate(resourceKey, defaultValue);
101+
var labelText = LocalizationManager.Translate(resourceKey, defaultValue ?? resourceKey);
102102
return htmlHelper.Label(expression, labelText, htmlAttributes);
103103
}
104104
}

src/Localization.Windows/Localization.Windows.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<UseWPF>true</UseWPF>
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
77
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
8-
<Version>1.0.0</Version>
8+
<Version>1.0.1</Version>
99
<PackageId>Mafe.Localization.Windows</PackageId>
1010
<Authors>Federico Mazzanti</Authors>
1111
<Company>Federico Mazzanti</Company>

src/Localization.Windows/TranslateExtention.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public override object ProvideValue(IServiceProvider serviceProvider)
8282
Source = LocalizationManager.Instance,
8383
Path = new PropertyPath($"[{ResourceKey}]"),
8484
Converter = new NullToDefaultConverter(),
85-
ConverterParameter = DefaultValue,
85+
ConverterParameter = DefaultValue ?? ResourceKey,
8686
StringFormat = StringFormat
8787
};
8888
return binding.ProvideValue(serviceProvider);

src/Localization.Xamarin/Localization.Xamarin.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<RepositoryType>GitHub</RepositoryType>
99
<PackageTags>localization, c-sharp, dotnet-standard, dotnet-core, dotnet-framework, xamarin</PackageTags>
1010
<NeutralLanguage>en</NeutralLanguage>
11-
<Version>1.0.0</Version>
11+
<Version>1.0.1</Version>
1212
<PackageId>Mafe.Localization.Xamarin</PackageId>
1313
<Authors>Federico Mazzanti</Authors>
1414
<Company>Federico Mazzanti</Company>

src/Localization.Xamarin/TranslateExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public BindingBase ProvideValue(IServiceProvider serviceProvider)
8080
Source = LocalizationManager.Instance,
8181
StringFormat = StringFormat,
8282
Converter = new NullToDefaultConverter(),
83-
ConverterParameter = DefaultValue
83+
ConverterParameter = DefaultValue ?? ResourceKey,
8484
};
8585
return binding;
8686
}

0 commit comments

Comments
 (0)