I'm using OrchardCore.Localization.Core
NuGet package and follow this tutorial for making an asp.net core project localized.
everything is works well and fine, I have files like en.po
and fr.po
for localizations for english and french languages. but i want to separate some words into separate file like splitting po files into en.po
, fr.po
, errorlist.en.po
and errorlist.fr.po
.
I'm not looking for a smart way of separating some words just for a special files or etc. i just want to have some words in separate files to avoid having one big po file for each language.
I'm not quite sure i can't find any doc for this matter. Is OrchardCore.Localization.Core
NuGet already have this feature? or can i implement something that can achieve this?
-
1You can read about it on https://gist.github.com/sebastienros/7980aad2ab33dd3a1c011fcf5a3f350c#implementing-a-custom-logic-for-finding-localization-files "In case some more complex logic is needed to locate PO files, the interface OrchardCore.Localization.PortableObject.ILocalizationFileLocationProvider can be implemented and registered as a service. For instance if PO files can be in a difference locations, or have to be found in a hierarchy of folders." – Pavisa Apr 05 '19 at 17:30
1 Answers
NOTE
I asked this question on product own github issue list here and i want to add the owner answer here for future reference, all credits to Sébastien Ros:
On the same documentation page, it mentions you can provide your own logic to file the files: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/portable-object-localization?view=aspnetcore-2.2#implementing-a-custom-logic-for-finding-localization-files
Which means you can copy this file: https://github.com/OrchardCMS/OrchardCore/blob/dev/src/OrchardCore/OrchardCore.Localization.Core/ContentRootPoFileLocationProvider.cs
And adapt the GetLocations()
method to your needs, by for instance listing all the files that end with the specific culture instead of returning a single IFileInfo
.
Here is another example whe use in OC Framework to find file in multiple module folders: https://github.com/OrchardCMS/OrchardCore/blob/dev/src/OrchardCore.Modules/OrchardCore.Localization/ModularPoFileLocationProvider.cs
Then you can register you provider like this:
services.AddSingleton<ILocalizationFileLocationProvider, MyPoFileLocationProvider>();

- 4,188
- 3
- 33
- 55