Hello there !
In my .web project,I have 2 SPA.
- /App/Dashboard (aspnetzero)
- /App/MainApp
I would like to use 2 differents xml localization files foreach SPA.
When I define ""ConstsLocalizationSourceName = "Dashboard"" it works fine for the dashboard but not for "MainApp". When I define ""ConstsLocalizationSourceName = "MainApp"" it works fine for the MainApp but not for Dashboard.
It's perfectly logic.
I would like to keep all my solution with ""ConstsLocalizationSourceName = "Dashboard"". (for all dashboard SPA & MVC view [login etc]))
In my "MainApp", i'll configure the layout page with "MainApp" localization souce name.
It also works fine when I do this way : abp.localization.localize('Loading', 'MainApp'));
In the header of layout.cshml of MainApp, I set thi script :
<script>
abp.localization.defaultSourceName = "Mainapp";
moment.locale('@Thread.CurrentThread.CurrentUICulture.Name.Left(2)'); //Localizing moment.js
</script>
<header>
<script type="text/javascript">
//This is used to get the application's root path from javascript. It's useful if you're running application in a virtual directory under IIS.
var abp = abp || {}; abp.appPath = '@ApplicationPath';
</script>
@Scripts.Render("~/Bundles/App/vendor/js")
<script>
abp.localization.defaultSourceName = 'WebAero';
moment.locale('@Thread.CurrentThread.CurrentUICulture.Name.Left(2)'); //Localizing moment.js
</script>
... // Loading my app js files
</header>
<body>
<li>
<label>
@L("ShowAll")
</label>
</li>
</body>
in this last example, @L("ShowAll") is not loading.
Is it possible to do like I did ?
If yes, when is it the correct time to set the abp.localization.defaultSourceName in JS ? after/before abp/MyApp scripts; before the page loading, ... etc
thks for the help !
2 Answer(s)
-
0
Hello,
Yes it is possible. You can define another ViewBase for your MainApp like.
public abstract class MainAppWebViewPageBase<TModel> : AbpWebViewPage<TModel> { protected AbpZeroTemplateWebViewPageBase() { LocalizationSourceName = "MainApp" } }
Then you can configure it in the web.config file under "/App/MainApp" directory like (Add if it does not exist)
<system.web.webPages.razor> <pages pageBaseType="MainAppWebViewPageBase"> .... </pages> </system.web.webPages.razor>
Then it should work like you expected.
I hope this helps.
-
0
Works like a charm !
thanks for the help ;)