Base solution for your next web application
Open Closed

[Localization] multi SPA #817


User avatar
0
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 :



    
    @Scripts.Render("~/Bundles/App/vendor/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)
    • User Avatar
      0
      ismcagdas created
      Support Team

      Hello,

      Yes it is possible.
      You can define another ViewBase for your MainApp like.

      public abstract class MainAppWebViewPageBase : AbpWebViewPage
      {
          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)

      
          
          ....
          
      
      

      Then it should work like you expected.

      I hope this helps.

    • User Avatar
      0
      daws created

      Works like a charm !

      thanks for the help ;)