Hi,
I want to use multiple resource files to have separation of localized keys/texts. I tried to add multiple resource files in Localization Source list (in PreInitilizae method of Core module) which I was able to do with no issue, but as I see we can only provide one LocalizationSourceName, hence only one resource file.
How can we use multiple resource files?
Thanks
5 Answer(s)
-
0
Hi,
If I understand you correctly (I assume you want to use Resource-1-en.xml and Resource-2-en.xml in the same localization source for a single language.), you need to define multiple localization sources.
-
0
Hi,
You got it right!
But my question is how to specify multiple LocationSourceNames?
We set LocalizationSourceName in base classes like the one which derives from AbpWebViewPage. Below is the code snippet:
public abstract class DemoWebViewPageBase<TModel> : AbpWebViewPage<TModel> { public IAbpSession AbpSession { get; private set; } protected DemoWebViewPageBase() { AbpSession = IocManager.Instance.Resolve<IAbpSession>(); LocalizationSourceName = DemoConsts.LocalizationSourceName; } }
In above code we can speficy only one LocalizationSourceName. How can we specify multiple here?
Thanks
-
0
Hi,
You are right, there is single LocalizationSourceName in AbpWebViewPage<TModel>. But you can use Ls helper method instead of L helper method and give it to your new LocalizationSourceName.
You can also define helper methods similar to L in your DemoWebViewPageBase and use your new LocalizationSourceName inside it. Then you can use your new helper method in your *.cshtml files.
-
0
Thanks!
Is there any way to use localization in Dtos? I want to use localization in Dtos in DataAnnotations for custom server side error messages.
For example, I want to use localization in TenantEditDto class like below:
[Required(ErrorMessage = "Please provide Name")] public string Name { get; set; }
-
0
Hi,
Currently there is nothing like that.