Base solution for your next web application
Open Closed

[Localization] multi SPA #817

daws created

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 :

        abp.localization.defaultSourceName = "Mainapp";
        moment.locale('@Thread.CurrentThread.CurrentUICulture.Name.Left(2)'); //Localizing moment.js
    <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';
        abp.localization.defaultSourceName = 'WebAero';
        moment.locale('@Thread.CurrentThread.CurrentUICulture.Name.Left(2)'); //Localizing moment.js
	... // Loading my app js files
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
    ismcagdas created
    Support Team


    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)

        <pages pageBaseType="MainAppWebViewPageBase">

    Then it should work like you expected.

    I hope this helps.

  • 0
    daws created

    Works like a charm !

    thanks for the help ;)