question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question regarding the functionality of the localization

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
amendez1000commented, May 26, 2019

@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.

0reactions
malimingcommented, May 20, 2019

@amendez1000 Can you provide a simple recurring project?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Starting a Localization Project? 15 Questions to Answer ...
Here are 15 critical questions to ask yourself before you embark on a localization project. Have you done sufficient research on your target ......
Read more >
5 Key Questions to Prepare for Localization
What content can you localize? · Where is your content located? · Is your app internationalized? · Who is your target audience? ·...
Read more >
5 Continuous Localization Questions to Ask
Is this continuous enough? We think it's debatable. · Is there a minimum fee applied? · How often can I submit a string...
Read more >
227 questions with answers in LOCALIZATION
Review and cite LOCALIZATION protocol, troubleshooting and other methodology information | Contact experts in LOCALIZATION to get answers.
Read more >
5 common questions about localisation…
When do I need to think about localisation? · What should I localise? · Who needs to be involved? · I'm targeting 6...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found