Example #1
0
        public static void SetUpLocalization()
        {
            var installedStringFileFolder = FileLocator.GetDirectoryDistributedWithApplication("localization");

            try
            {
                _applicationContainer.LocalizationManager = LocalizationManager.Create(Settings.Default.UserInterfaceLanguage,
                                                                                       "Bloom", "Bloom", Application.ProductVersion,
                                                                                       installedStringFileFolder,
                                                                                       Path.Combine(ProjectContext.GetBloomAppDataFolder(), "Localizations"), Resources.Bloom, "*****@*****.**", "Bloom");

                var uiLanguage           = LocalizationManager.UILanguageId;        //just feeding this into subsequent creates prevents asking the user twice if the language of their os isn't one we have a tmx for
                var unusedGoesIntoStatic = LocalizationManager.Create(uiLanguage,
                                                                      "Palaso", "Palaso", /*review: this is just bloom's version*/ Application.ProductVersion,
                                                                      installedStringFileFolder,
                                                                      Path.Combine(ProjectContext.GetBloomAppDataFolder(), "Localizations"), Resources.Bloom, "*****@*****.**", "Palaso.UI");

                /*                var l10nSystem = L10NSystem.BeginInit(preferredLanguage, installedStringFileFolder, targetStringFileFolder, icon, "*****@*****.**");
                 *                                    l10nSystem.AddLocalizationPackage(NameSpace="Bloom", ID="Bloom", DisplayName="Bloom", Version=Application.ProductVersion);
                 *                                    l10nSystem.AddLocalizationPackage(NameSpace = "Palaso", ID = "Palaso", DisplayName = "Palaso", Version = Application.ProductVersion);
                 *                            or better
                 *                                            [Localizable(NameSpace="Bloom", ID="Bloom", DisplayName="Bloom", Version=Application.ProductVersion)]
                 *                            l10nSystem.EndInit();
                 */

                Settings.Default.UserInterfaceLanguage = LocalizationManager.UILanguageId;
            }
            catch (Exception error)
            {
                //handle http://jira.palaso.org/issues/browse/BL-213
                if (Process.GetProcesses().Count(p => p.ProcessName.ToLower().Contains("bloom")) > 1)
                {
                    ErrorReport.NotifyUserOfProblem("Whoops. There is another copy of Bloom already running while Bloom was trying to set up L10NSharp.");
                    Environment.FailFast("Bloom couldn't set up localization");
                }

                if (error.Message.Contains("Bloom.en.tmx"))
                {
                    ErrorReport.NotifyUserOfProblem(error,
                                                    "Sorry. Bloom is trying to set up your machine to use this new version, but something went wrong getting at the file it needs. If you restart your computer, all will be well.");

                    Environment.FailFast("Bloom couldn't set up localization");
                }

                //otherwise, we don't know what caused it.
                throw;
            }
        }
Example #2
0
        private static void CopyRelevantNewReaderSettings()
        {
            var readerToolsPath = _projectContext.Settings.DecodableLevelPathName;
            var bloomFolder     = ProjectContext.GetBloomAppDataFolder();
            var newReaderTools  = Path.Combine(bloomFolder, Path.GetFileName(readerToolsPath));

            if (!File.Exists(newReaderTools))
            {
                return;
            }
            if (File.Exists(readerToolsPath) && File.GetLastWriteTime(readerToolsPath) > File.GetLastWriteTime(newReaderTools))
            {
                return;                 // don't overwrite newer settings?
            }
            File.Copy(newReaderTools, readerToolsPath, true);
        }