Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PO files ❤️ Localization in ASP.NET Core 2.0 using Orchard Core #48

Open
hishamco opened this issue Dec 1, 2018 · 5 comments
Open

Comments

@hishamco
Copy link
Owner

@hishamco hishamco commented Dec 1, 2018

No description provided.

@nyghtrocker
Copy link

@nyghtrocker nyghtrocker commented Jan 7, 2019

Hi how can i override ContentRootPoFileLocationProvider and replace using dependency injection. I’m using orchard core as nuget package and tring to override po files location . Is any difference between content root po file location provider and ModularPoFileLocationProvider?

@hishamco
Copy link
Owner Author

@hishamco hishamco commented Jan 7, 2019

Things are change since I wrote my blog post, but let me check or forward your question there ..

@hishamco
Copy link
Owner Author

@hishamco hishamco commented Jan 7, 2019

According to the Orchard Core docs PO files are found via the following steps:

  • For each module and theme all files matching [ModuleLocation]/App_Data/Localization/[CultureName].po
  • Then all files matching /App_Data/Localization/[CultureName].po
  • For each tenant all files matching /App_Data/Sites/[TenantName]/Localization/[CultureName].po

So you can simply override the ContentRootPoFileLocationProvider by injecting your CustomContentRootPoFileLocationProvider into DI as the following:

services.AddSingleton<ILocalizationFileLocationProvider, CustomContentRootPoFileLocationProvider>()
@nyghtrocker
Copy link

@nyghtrocker nyghtrocker commented Jan 8, 2019

In startup.cs I have like this:
services.AddOrchardCms().AddSingleton<ILocalizationFileLocationProvider, MyLIModularPoFileLocationProvider>();
and then I have

public class  MyLIModularPoFileLocationProvider : ILocalizationFileLocationProvider
{
        public MyLIModularPoFileLocationProvider(IOptions<LocalizationOptions> localizationOptions )
        {
            _resourcesContainer = localizationOptions.Value.ResourcesPath; // Localization
        }
        public IEnumerable<IFileInfo> GetLocations(string cultureName)
        {

        }
}

breakpoint hit in constructor but my breakpoint never hit on GetLocations(string cultureName) method.
Do you know what should I do? I also tried with services.Replace(ServiceDescriptor.Singleton<ILocalizationFileLocationProvider, MyLIModularPoFileLocationProvider>());

@hishamco
Copy link
Owner Author

@hishamco hishamco commented Jan 9, 2019

While the topic go further I think we need to move this to Orchard Core repo for better tracking and involve the community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants