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.

localization not work when disable one of languages

See original GitHub issue

hi dears,

  • Your Abp package version: 5.1.

  • Your base framework: .Net Framework or .Net Core: .Net Core.

  • Steps needed to reproduce the problem. in class DefaultLanguagesCreator.cs when disable ‘us’ language and add ‘gb’ language, the expected behavior is localization use fallback localization file (default localization file with same culure) but it not shows the localization in site

please note this was working before

private static List<ApplicationLanguage> GetInitialLanguages()
        {
            var tenantId = MyProjectConsts.MultiTenancyEnabled ? null : (int?)MultiTenancyConsts.DefaultTenantId;
            return new List<ApplicationLanguage>
            {
                new ApplicationLanguage(tenantId, "en", "English", "famfamfam-flags us", true),
                new ApplicationLanguage(tenantId, "en-GB", "English", "famfamfam-flags us"),
                new ApplicationLanguage(tenantId, "ar-KW", "العربية", "famfamfam-flags kw"),
            };
        }

to see issue you can download template andmake upper changes

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:28 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
sajasbanacommented, Jul 6, 2020

@demirmusa I download new template from the site and issue still there image

i updated these files like below image image

but as you can see issue still there image

is there something wrong i did in my modifications? is there something i need to add to make localization work?

I think solution maybe to change this part in the code in line 83 of this file (https://github.com/aspnetboilerplate/aspnetboilerplate/pull/5670/commits/d2e552c0825ee635548b2ba4996b5e5c3dda050d#diff-16a7725abffda170921fb5b428593585)

var internalDictionary =
                _internalProvider.Dictionaries.GetOrDefault(language.Name) ??
                new EmptyDictionary(CultureInfo.GetCultureInfo(language.Name));

to something like this

var internalDictionary =
                _internalProvider.Dictionaries.GetOrDefault(language.Name) ??
                //maybe you need to add this line and send 2 left letter e.g. en-GB then you send en as parameter
               _internalProvider.Dictionaries.GetOrDefault(string.left(language.Name,2)) ??
                new EmptyDictionary(CultureInfo.GetCultureInfo(language.Name));

image

1reaction
sajasbanacommented, Jun 3, 2020

@demirmusa first thanks for set issue in milestone second, hope your solution take care of the issue i mentioned and details i put, for summary: i have 2 .xml file

  • xml with culture (‘en’)
  • xml with culture (‘ar’)

in db there are 4 languages

  • en (disabled)
  • ar (disabled)
  • en-GB (enabled - default)
  • ar-KW (enabled)

expected result as mentioned in the issue: when user select language e.g (en-GB) translations come from xml with culture (en) as fallback languages (as mentioned above this behavior was working before)

Thanks again for your time

Read more comments on GitHub >

github_iconTop Results From Across the Web

localization not work when disable one of languages #5701
If what you need is using default "en" culture as a fallback mechanism even if you disable it, It is not possible. Defualt...
Read more >
Disabled localization for component doesn't work #12775
When you create a component with a relation to another element it's not possible to reuse the same relation for all languages. I...
Read more >
Disable localization in Android application
Is there any way to disable localization in an Android application? It must use only English strings. We have library projects with French ......
Read more >
What's the best way to disable a language while it's being ...
One way would be to put the locale into a separate addressable group and set that group to not be exported in the...
Read more >
How to disable language localization? - Forum
Hi,. I updated NPM from 10.3 to 10.4.1 last Friday. Today I had a deeper look into the new installed NPM and saw...
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