aspnetboilerplate: localization not work when disable one of languages

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

About this issue

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

Most upvoted comments

@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

@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