private void _appendLocaleLoaders(RoutesTsModel mod)
 {
     if (string.IsNullOrEmpty(_paths.LocalizationRoot))
     {
         return;
     }
     string[] locales = Shell.SupportedLanguages.ToArray();
     foreach (string loc in locales)
     {
         mod.LocalizationImports += "import { " + loc + "_Loader } from \"./localization/" + loc + "/loader\";\n";
         mod.LocalizationLoaders += $"[\"{loc}\"]:new {loc}_Loader, ";
     }
 }
        public virtual void GenerateRoutes(string modCode)
        {
            string filePath = _fileNameService.GetModuleFilePath(modCode, "AppRouting", createFolder: false) + ".ts";

            Out.Write($"Generating Routes [{modCode}Routes.ts] : ");

            if (!_opts.ReplaceMainRoutes && File.Exists(filePath))
            {
                GotoColumn(SuccessCol);
                WriteColored("Exists", ConsoleColor.Cyan);
                Out.WriteLine();
                return;
            }

            long modId = _unit.TenantRepository.GetSingleValue(d => d.Id, d => d.Code == modCode);

            IEnumerable <DomainWithPagesDTO> domains = _unit.DomainRepository.GetParentModules(modId);
            IEnumerable <NavigationGroupDTO> navs    = _unit.NavigationGroupRepository.GetTenantNavs(modId);
            string routesTemplate = _molds.RoutesMold;

            var tempModel = new RoutesTsModel
            {
                LocalizationImports = "",
                ComponentImports    = "",
                LocalizationLoaders = "",
                Routes       = "",
                Registration = "",
                BaseName     = _paths.CoreAppName
            };

            string homePage = _unit.PageRepository.GetHomePagePath(modCode);

            if (homePage != null)
            {
                var name = homePage.GetAfterLast("/");
                tempModel.ComponentImports += "import { " + name + " } from '" + _fileNameService.GetComponentImportPath(homePage, false) + "'";
                tempModel.Routes           += _homeRoute(name);
            }

            foreach (var domain in domains)
            {
                string dom = domain.DomainName;
                tempModel.Routes += _fileNameService.GetDomainLazyLoadingRoute(domain.DomainName) + ",";
            }
            string sep = "";

            foreach (var nav in navs)
            {
                tempModel.DomainsData += sep + _getNavigationObject(nav);
                sep = ",\n\t\t\t";
            }

            _appendLocaleLoaders(tempModel);

            string builder = _writer.FillStringParameters(routesTemplate, tempModel);

            Utils.CreateFolderForFile(filePath);
            File.WriteAllText(filePath, builder);

            GotoColumn(SuccessCol);
            WriteSuccess();
            Out.WriteLine();
        }