public static string GetPathFromMemberNameAndDir(string memberName, string dir, LanguageUtil.ELanguage lang) { if (!LanguageUtil.IsEnglish(lang)) { dir = Path.Combine(dir, lang.ToString()); } return(Path.Combine(dir, DirectoryUtil.MemberNameWithExtension(memberName, DirectoryUtil.MemExtension))); }
/// <summary> /// Saves content to given locale /// </summary> /// <param name="content">content to save into file</param> /// <param name="locale">locale to save</param> /// <returns>true if succeeds</returns> public bool SaveDocumentOfLocale(String content, LanguageUtil.ELanguage locale) { String savingPath = null; if (FileMap.ContainsKey(locale)) { savingPath = FileMap[locale]; } else { var filename = DirectoryUtil.MemberNameWithExtension(signature, DirectoryUtil.MemExtension); if (LanguageUtil.IsEnglish(locale)) { savingPath = Path.Combine(baseDocDirPath, filename); } else { savingPath = string.Concat(Path.Combine(baseDocDirPath, locale.ToString()), Path.DirectorySeparatorChar, filename); } } try { File.WriteAllText(savingPath, content); if (!FileMap.ContainsKey(locale)) { FileMap.Add(locale, savingPath); } return(true); } catch (Exception e) { Console.Out.WriteLine("saveDocumentOfLocale failed:{0}", e.Message); FileMap.Remove(locale); } return(false); }
public static string LocalizedDir(string path, LanguageUtil.ELanguage locale) { var localizedPath = LanguageUtil.IsEnglish(locale) ? path : Path.Combine(path, locale.ToString()); return(localizedPath); }