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.

Embedded localizations extensions not working in late versions of Abp

See original GitHub issue

Hi,

I’m having some issues in adding localization extensions when they are embedded. I’ve tested this in the following versions: 2.3.0, 3.7.2 and 3.8.3. It is only working in 2.3.0. In 3.7.2 and 3.8.3 the Middle localizations extension is not being added, but the Top and Bottom localizations are added.

Current Abp-versions for the assemblies: Top (2.3.0) Middle (2.3.0) Bottom (3.7.2)

However, I’ve also tested updating the Top and Middle to the same version as Bottom, but that didn’t work either. But when I downgraded the Bottom to version 2.3.0, it works.

The localization json files in Top and Middle are in the respective folders “Localization/Top” and “Localization/Middle” in their project where all of the json files have the build action “Embedded Resource”.

This is the code used to add the localization sources/extensions for the Bottom module:

public override void PreInitialize()
{
    var topAssembly = System.Web.Compilation.BuildManager.GetReferencedAssemblies()
                .Cast<Assembly>()
                .FirstOrDefault(a => a.GetName().Name.Equals("TopAssembly"));

    var middleAssembly = System.Web.Compilation.BuildManager.GetReferencedAssemblies()
                .Cast<Assembly>()
                .FirstOrDefault(a => a.GetName().Name.Equals("MiddleAssembly"));

    Configuration.Localization.Sources.Add(
        new DictionaryBasedLocalizationSource(
            "Top",
            new JsonEmbeddedFileLocalizationDictionaryProvider(
                topAssembly,
                $"{topAssembly.GetName().Name}.Localization.Top"
            )
        )
    );
    Configuration.Localization.Sources.Extensions.Add(
        new Abp.Localization.Sources.LocalizationSourceExtensionInfo(
            "Top",
            new JsonEmbeddedFileLocalizationDictionaryProvider(
                middleAssembly,
                $"{middleAssembly.GetName().Name}.Localization.Middle"
            )
        )
    );
    Configuration.Localization.Sources.Extensions.Add(
        new Abp.Localization.Sources.LocalizationSourceExtensionInfo(
            "Top",
            new JsonFileLocalizationDictionaryProvider(
                HttpContext.Current.Server.MapPath("~/Localization/Bottom")
            )
        )
   );
}

Is the way of adding embedded extensions changed in newer versions? I read the newest documentation and this seems like the correct way of doing it.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ryancyqcommented, Oct 25, 2018

@thomkle of course we can add optional parameter to specific localization file name. However, i don’t see much benefits from doing this.

By providing optional localization file name, we are

  1. allowing different localization files to extend the same localization source
  2. making maintainability of localization files hard as it breaks the convention of localization extension.

Currently localization source A in one project can only be extended by localization source A in another project Localization files used for localization source A in both projects must be named as A

1reaction
malimingcommented, Oct 19, 2018

Sorry, I just saw it, I will check it out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem to Extending Localization Sources in abp v 6.3.0
I need to extend localization sources. According to the descriptions in the documentation, I added the localization sources files in a folder ...
Read more >
Localization resource does not load custom localization file in ...
We took an existing application using ABP 6.8 and upgraded it to 7.x. The application works fine, except that our custom localization strings ......
Read more >
Bugs & Problems v3.1.X #282 | Support Center | ABP Commercial
I've got a problem that when I generate new project and create new ... Abp.AutoMapper, Version=3.0.3.0, Culture=neutral, PublicKeyToken=null: Unmapped ...
Read more >
Registering XML Localization Sources
You can set a default localization source and use the abp. localization. localize method without the source name.
Read more >
language management documentation
AspNet Boilerplate (ABP) is an open source and well-documented application framework. See the comprehensive tutorials of ABP for technical information.
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