Browse Source
Merge pull request #6293 from abpframework/rel-4.0-localization-fix
Fixed fallback logic for blazor attribute localization
pull/6290/head
Halil İbrahim Kalkan
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
14 additions and
3 deletions
-
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpBlazorMessageLocalizerHelper.cs
|
|
|
@ -32,9 +32,20 @@ namespace Volo.Abp.AspNetCore.Components.WebAssembly |
|
|
|
{ |
|
|
|
foreach (var argument in arguments) |
|
|
|
{ |
|
|
|
yield return stringLocalizer[$"DisplayName:{argument}"] |
|
|
|
?? stringLocalizer[argument] |
|
|
|
?? argument; |
|
|
|
// first try to localize with "DisplayName:{Name}"
|
|
|
|
string localization = stringLocalizer[$"DisplayName:{argument}"]; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(localization) && !localization.StartsWith("DisplayName:")) |
|
|
|
yield return localization; |
|
|
|
|
|
|
|
// then try to localize with just "{Name}"
|
|
|
|
localization = stringLocalizer[argument]; |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(localization) && localization != argument) |
|
|
|
yield return localization; |
|
|
|
|
|
|
|
// no localization found so just return what we got
|
|
|
|
yield return argument; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|