/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new instance of a localization manager for the specified application id. /// If a localization manager has already been created for the specified id, then /// that is returned. /// </summary> /// <param name="kind">Translation memory type to use</param> /// <param name="desiredUiLangId">The language code of the desired UI language. If /// there are no translations for that ID, a message is displayed and the UI language /// falls back to the default.</param> /// <param name="appId">The application Id (e.g. 'Pa' for Phonology Assistant). /// This should be a unique name that identifies the manager for an assembly or /// application.</param> /// <param name="appName">The application's name. This will appear to the user /// in the localization dialog box as a parent item in the tree.</param> /// <param name="appVersion"></param> /// <param name="directoryOfInstalledFiles">The full folder path of the original Xliff/TMX /// files installed with the application.</param> /// <param name="relativeSettingPathForLocalizationFolder">The path, relative to /// %appdata%, where your application stores user settings (e.g., "SIL\SayMore"). /// A folder named "localizations" will be created there.</param> /// <param name="applicationIcon"> </param> /// <param name="emailForSubmissions">This will be used in UI that helps the translator /// know what to do with their work</param> /// <param name="namespaceBeginnings">A list of namespace beginnings indicating /// what types to scan for localized string calls. For example, to only scan /// types found in Pa.exe and assuming all types in that assembly begin with /// 'Pa', then this value would only contain the string 'Pa'.</param> /// ------------------------------------------------------------------------------------ public static ILocalizationManager Create(TranslationMemory kind, string desiredUiLangId, string appId, string appName, string appVersion, string directoryOfInstalledFiles, string relativeSettingPathForLocalizationFolder, Icon applicationIcon, string emailForSubmissions, params string[] namespaceBeginnings) { TranslationMemoryKind = kind; EmailForSubmissions = emailForSubmissions; switch (kind) { case TranslationMemory.Tmx: return(LocalizationManagerInternal <TMXDocument> .CreateTmx(desiredUiLangId, appId, appName, appVersion, directoryOfInstalledFiles, relativeSettingPathForLocalizationFolder, applicationIcon, namespaceBeginnings)); case TranslationMemory.XLiff: return(LocalizationManagerInternal <XLiffDocument> .CreateXliff(desiredUiLangId, appId, appName, appVersion, directoryOfInstalledFiles, relativeSettingPathForLocalizationFolder, applicationIcon, namespaceBeginnings)); default: throw new ArgumentException($"Unknown translation memory kind {kind}", nameof(kind)); } }
/// ------------------------------------------------------------------------------------ public static void SetUILanguage(string langId, bool reapplyLocalizationsToAllObjectsInAllManagers) { if (UILanguageId == langId || string.IsNullOrEmpty(langId)) { return; } var ci = L10NCultureInfo.GetCultureInfo(langId); if (ci.RawCultureInfo != null) { Thread.CurrentThread.CurrentUICulture = ci.RawCultureInfo; } else { Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; } L10NCultureInfo.CurrentCulture = ci; s_uiLangId = langId; switch (TranslationMemoryKind) { default: LocalizationManagerInternal <TMXDocument> .SetAvailableFallbackLanguageIds(GetAvailableLocalizedLanguages()); break; case TranslationMemory.XLiff: LocalizationManagerInternal <XLiffDocument> .SetAvailableFallbackLanguageIds(GetAvailableLocalizedLanguages()); break; } if (reapplyLocalizationsToAllObjectsInAllManagers) { ReapplyLocalizationsToAllObjectsInAllManagers(); } }