Question regarding the functionality of the localization
See original GitHub issueHi,
I got a question regarding the functionality of the localization.
I’m using three localization sources; top, middle, bottom. The override hierarchy should be bottom > middle > top. So if I create a key called “Hello_World” in middle, it should override any values for the same key in the top localization source, but the bottom should override the middle.
The top is added using the Configuration.Localization.Sources.Add
-method while the middle and bottom is added using the Configuration.Localization.Sources.Extensions.Add
.
public override void PreInitialize()
{
Configuration.Localization.Sources.Add(
new DictionaryBasedLocalizationSource(
LocalizationSourceName,
new JsonFileLocalizationDictionaryProvider(
HttpContext.Current.Server.MapPath("~/Localization/Top"))
)
);
Configuration.Localization.Sources.Extensions.Add(
new Abp.Localization.Sources.LocalizationSourceExtensionInfo(
LocalizationSourceName,
new JsonFileLocalizationDictionaryProvider(
HttpContext.Current.Server.MapPath("~/Localization/Middle"))
)
);
Configuration.Localization.Sources.Extensions.Add(
new Abp.Localization.Sources.LocalizationSourceExtensionInfo(
LocalizationSourceName,
new JsonFileLocalizationDictionaryProvider(
HttpContext.Current.Server.MapPath("~/Localization/Bottom"))
)
);
}
This seems to be working fine in the default language.
However, when switching to e.g. ‘fr’ language it has some unexpected behaviour when it comes to the fall back values.
If there are no localization files for ‘fr’ and the ‘Bottom’ is the only localization source that has e.g. the key “Hello_World” with value “Hello World!”, it will not show the “Hello World!” value, but the clamped version of the key.
But if I add the bottom localization source with the Configuration.Localization.Sources.Add
-method and add the top with the Configuration.Localization.Sources.Extensions.Add
-method instead, the fall back works fine (but now the override hierarchy is wrong).
It seems like it’s first checking if there are any localization files for ‘fr’, if not it just checks if the key is to be found in the source, not the extensions.
Am I missing something? Should I have implemented it in another way? Is it possible to have the functionality I explained?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
@maliming
I don’t really now what I was doing wrong. I took the last version of abp 4.6.0 and it is working as I was expecting. Thanks so much.
@amendez1000 Can you provide a simple recurring project?