private List <TranslationFile> GetSiteResources() { var resourceFolder = GlobalContext.ContentRootPath + "\\Bin\\Debug\\netcoreapp2.0\\Resources"; if (RuntimeUtil.IsRelease(GetType().Assembly)) { resourceFolder = GlobalContext.ContentRootPath + "\\Bin\\Release\\netcoreapp2.0\\Resources"; } var translationFileList = GetTranslationFiles("Website", resourceFolder); return(translationFileList); }
public List <Theme> ScanThemeDirectory(string path) { var themes = new List <Theme>(); var directoryInfo = new DirectoryInfo(path); foreach (var themeDir in directoryInfo.EnumerateDirectories()) { try { var configFileLocation = Path.Combine(themeDir.FullName, ThemeInfoFileName); if (File.Exists(configFileLocation)) { var themeInfoFileContent = File.ReadAllText(configFileLocation); var theme = JsonConvert.DeserializeObject <Theme>(themeInfoFileContent); theme.Folder = themeDir.Name; theme.ConfigFilePath = configFileLocation; theme.ResourceFolder = themeDir.FullName + "\\Bin\\Debug\\netcoreapp2.0\\Resources"; var themeAssemblyPath = themeDir.FullName + "\\Bin\\Debug\\netcoreapp2.0\\" + theme.ThemeName + ".dll"; var themeAssembly = Assembly.LoadFile(themeAssemblyPath); if (RuntimeUtil.IsRelease(themeAssembly)) { theme.ResourceFolder = themeDir.FullName + "\\Bin\\Release\\netcoreapp2.0\\Resources"; } themes.Add(theme); if (theme.IsActive) { GlobalConfig.ActiveTheme = theme; } } else { RegisterErrorMessage("Theme config file Theme.json not found"); } } catch (Exception ex) { RegisterErrorMessage(ex.Message); throw ex; } } if (GlobalConfig.ActiveTheme == null) { ActivateDefaultTheme(); } return(themes); }
private List <TranslationFile> GetModuleResources() { var list = new List <TranslationFile>(); foreach (var item in GlobalContext.Modules) { var resourceFolder = "\\Bin\\Debug\\netcoreapp2.0\\Resources"; if (RuntimeUtil.IsRelease(item.Assembly)) { resourceFolder = "\\Bin\\Release\\netcoreapp2.0\\Resources"; } var tfList = GetTranslationFiles(item.ModuleTitle, item.Path + resourceFolder); list.AddRange(tfList); } return(list); }
public INccTranslator GetTranslator(string cultureCode) { _cultureCode = cultureCode; if (string.IsNullOrEmpty(cultureCode) || cultureCode.ToLower().Equals("en")) { return(this); } var path = Path.Combine(GlobalContext.ContentRootPath, "bin", "Debug", "netcoreapp2.0", "Resources"); if (RuntimeUtil.IsRelease(typeof(SharedResource).Assembly)) { path = Path.Combine(GlobalContext.ContentRootPath, "bin", "Release", "netcoreapp2.0", "Resources"); } _fileName = "NccTranslationFile." + cultureCode + ".lang"; _resourceFilePath = Path.Combine(path, _fileName); if (!File.Exists(_resourceFilePath)) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } File.Create(_resourceFilePath).Dispose(); } var translationFileData = File.ReadAllText(_resourceFilePath); if (string.IsNullOrWhiteSpace(translationFileData)) { var assembly = typeof(SharedResource).GetTypeInfo().Assembly; using (Stream resource = assembly.GetManifestResourceStream("NetCoreCMS.Framework.Resources.SharedResource.lang")) { var sr = new StreamReader(resource); translationFileData = sr.ReadToEndAsync().Result; } } File.WriteAllText(_resourceFilePath, translationFileData); _translationFile = JsonConvert.DeserializeObject <NccTranslationFile>(translationFileData); return(this); }