示例#1
0
        private static void SetUpLocalization()
        {
            string installedStringFileFolder = FileLocator.GetDirectoryDistributedWithApplication("localization");
            string targetTmxFilePath         = Path.Combine(GlyssenInfo.kCompany, GlyssenInfo.kProduct);
            string desiredUiLangId           = Settings.Default.UserInterfaceLanguage;

            LocalizationManager = LocalizationManager.Create(desiredUiLangId, GlyssenInfo.kApplicationId, Application.ProductName, Application.ProductVersion,
                                                             installedStringFileFolder, targetTmxFilePath, Resources.glyssenIcon, IssuesEmailAddress, "Glyssen");

            if (string.IsNullOrEmpty(desiredUiLangId))
            {
                if (LocalizationManager.GetUILanguages(true).Count() > 1)
                {
                    using (var dlg = new LanguageChoosingSimpleDialog(Resources.glyssenIcon))
                        if (DialogResult.OK == dlg.ShowDialog())
                        {
                            Analytics.Track("SetUiLanguage", new Dictionary <string, string> {
                                { "uiLanguage", dlg.SelectedLanguage }, { "initialStartup", "true" }
                            });

                            LocalizationManager.SetUILanguage(dlg.SelectedLanguage, true);
                            Settings.Default.UserInterfaceLanguage = dlg.SelectedLanguage;
                        }
                }
            }

            var uiLanguage = LocalizationManager.UILanguageId;

            LocalizationManager.Create(uiLanguage, "Palaso", "Palaso", Application.ProductVersion,
                                       installedStringFileFolder, targetTmxFilePath, Resources.glyssenIcon, IssuesEmailAddress,
                                       "SIL.Windows.Forms.WritingSystems", "SIL.DblBundle", "SIL.Windows.Forms.DblBundle", "SIL.Windows.Forms.Miscellaneous");
        }
示例#2
0
        public void TestSetup()
        {
            var installedTmxDir = "../../src/L10NSharpTests/TestTmx";

            m_manager  = LocalizationManager.Create("en", "Test", "Test", "1.0", installedTmxDir, "", null, "");
            m_tmxPath  = m_manager.GetTmxPathForLanguage("en", true);
            m_extender = new L10NSharpExtender();
            m_extender.LocalizationManagerId = "Test";
        }
示例#3
0
        public static void SetUpLocalization()
        {
            var installedStringFileFolder = FileLocator.GetDirectoryDistributedWithApplication("localization");

            try
            {
                _applicationContainer.LocalizationManager = LocalizationManager.Create(Settings.Default.UserInterfaceLanguage,
                                                                                       "Bloom", "Bloom", Application.ProductVersion,
                                                                                       installedStringFileFolder,
                                                                                       "SIL/Bloom",
                                                                                       Resources.Bloom, "*****@*****.**",
                                                                                       //the parameters that follow are namespace beginnings:
                                                                                       "Bloom");

                //We had a case where someone translated stuff into another language, and sent in their tmx. But their tmx had soaked up a bunch of string
                //from their various templates, which were not Bloom standard templates. So then someone else sitting down to localize bloom would be
                //faced with a bunch of string that made no sense to them, because they don't have those templates.
                //So for now, we only soak up new strings if it's a developer, and hope that the Commit process will be enough for them to realize "oh no, I
                //don't want to check that stuff in".

#if DEBUG
                _applicationContainer.LocalizationManager.CollectUpNewStringsDiscoveredDynamically = true;
#else
                _applicationContainer.LocalizationManager.CollectUpNewStringsDiscoveredDynamically = false;
#endif

                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,
                                                                      "SIL/Bloom",
                                                                      Resources.Bloom, "*****@*****.**", "Palaso.UI");

                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;
            }
        }
示例#4
0
        public static Dictionary <string, LocalizationManager> SetupLocalization(Dictionary <string, string> commandLineArgs)
        {
            var results = new Dictionary <string, LocalizationManager>(3);

            var desiredUiLangId           = commandLineArgs[CommandLineProcessor.locale];
            var installedTmxBaseDirectory = Path.Combine(
                Path.GetDirectoryName(StripFilePrefix(Assembly.GetExecutingAssembly().CodeBase)), localizations);
            var userTmxBaseDirectory = Path.Combine("SIL", FlexBridge);

            // Now set it up for the handful of localizable elements in FlexBridge itself.
            // This is safer than Application.ProductVersion, which might contain words like 'alpha' or 'beta',
            // which (on the SECOND run of the program) fail when L10NSharp tries to make a Version object out of them.
            var versionObj = Assembly.GetExecutingAssembly().GetName().Version;
            // We don't need to reload strings for every "revision" (that might be every time we build).
            var version          = "" + versionObj.Major + "." + versionObj.Minor + "." + versionObj.Build;
            var flexBridgeLocMan = LocalizationManager.Create(desiredUiLangId, FlexBridge, Application.ProductName,
                                                              version,
                                                              installedTmxBaseDirectory,
                                                              userTmxBaseDirectory,
                                                              CommonResources.chorus,
                                                              FlexBridgeEmailAddress, new[]
            {
                FlexBridge, "TriboroughBridge_ChorusPlugin",
                "FLEx_ChorusPlugin", "SIL.LiftBridge"
            });

            results.Add("FlexBridge", flexBridgeLocMan);

            // In case the UI language was unavailable, change it, so we don't frustrate the user with three dialogs.
            desiredUiLangId = LocalizationManager.UILanguageId;

            versionObj = Assembly.GetAssembly(typeof(ChorusSystem)).GetName().Version;
            version    = "" + versionObj.Major + "." + versionObj.Minor + "." + versionObj.Build;
            var chorusLocMan = LocalizationManager.Create(desiredUiLangId, "Chorus", "Chorus",
                                                          version,
                                                          installedTmxBaseDirectory,
                                                          userTmxBaseDirectory,
                                                          CommonResources.chorus,
                                                          FlexBridgeEmailAddress, "Chorus");

            results.Add("Chorus", chorusLocMan);

            versionObj = Assembly.GetAssembly(typeof(ErrorReport)).GetName().Version;
            version    = "" + versionObj.Major + "." + versionObj.Minor + "." + versionObj.Build;
            var palasoLocMan = LocalizationManager.Create(desiredUiLangId, "Palaso", "Palaso",
                                                          version,
                                                          installedTmxBaseDirectory,
                                                          userTmxBaseDirectory,
                                                          CommonResources.chorus,
                                                          FlexBridgeEmailAddress, "Palaso");

            results.Add("Palaso", palasoLocMan);

            return(results);
        }
示例#5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Setup for each test.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void TestSetup(TranslationMemory kind, string installedTranslationDir)
        {
            var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            m_manager = LocalizationManager.Create(kind, "en", "Test", "Test", "1.0",
                                                   Path.Combine(dir, installedTranslationDir),
                                                   "", null, "")
                        as ILocalizationManagerInternal <T>;
            m_translationPath = m_manager.GetPathForLanguage("en", true);
            m_extender        = new L10NSharpExtender {
                LocalizationManagerId = "Test"
            };
        }
示例#6
0
        private static void SetUpLocalization(string desiredUiLangId)
        {
            var assembly   = Assembly.GetExecutingAssembly();
            var attributes = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
            var company    = attributes.Length == 0 ? "SIL" : ((AssemblyCompanyAttribute)attributes[0]).Company;
            var installedStringFileFolder = FileLocationUtilities.GetDirectoryDistributedWithApplication("localization");
            var relativeSettingPathForLocalizationFolder = Path.Combine(company, pluginName);
            var version = assembly.GetName().Version.ToString();

            LocalizationManager.Create(TranslationMemory.XLiff, desiredUiLangId, pluginName, pluginName, version,
                                       installedStringFileFolder, relativeSettingPathForLocalizationFolder, new Icon(FileLocationUtilities.GetFileDistributedWithApplication("TXL no TXL.ico")), emailAddress,
                                       "SIL.Transcelerator", "SIL.Utils");
        }
示例#7
0
        public void Create_PreferredUiLanguageIsGenericVariant_CreatesLocalizationManagerForSpecificVariant(
            string genericLocaleId, string countrySpecificLocalId)
        {
            LocalizationManager.ClearLoadedManagers();
            var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
            var lm  = LocalizationManager.Create(TranslationMemory.XLiff, genericLocaleId, "Test", "Test", "1.0",
                                                 Path.Combine(dir, "../../../src/L10NSharpTests/TestXliff2"), "", null, "");

            Assert.AreEqual($"Protección de configuraciones ({genericLocaleId})...",
                            lm.GetLocalizedString("SettingsProtection.LauncherButtonLabel", "don't use this"));
            // The next two lines prove that the test data was not changed in a way that nullifies the expected pre-conditions
            Assert.IsFalse(lm.GetAvailableUILanguageTags().Contains(genericLocaleId));
            Assert.IsTrue(lm.GetAvailableUILanguageTags().Contains(countrySpecificLocalId));
        }
示例#8
0
        public static void SetUpLocalization()
        {
            //your installer should have a folder where you place the Xliff files you're shipping with the program
            var directoryOfInstalledXliffFiles = "../../LocalizationFilesFromInstaller";

            Directory.CreateDirectory(directoryOfInstalledXliffFiles);

            try
            {
                // By using "null" for the following two things, we get AppData/Product.
                // Note: non-admin-rights users can't write to that folder.
                string directoryOfDefaultXliffFile = null;
                // When a user does some translation, their work goes in this directory.
                string directoryOfUserModifiedXliffFiles = null;

                //if this is your first time running the app, the library will query the OS for the
                //the default language. If it doesn't have that, it puts up a dialog listing what
                //it does have to offer.

                var theLanguageYouRememberedFromLastTime = Settings.Default.UserInterfaceLanguage;

                _localizationManager = LocalizationManager.Create(TranslationMemory.XLiff,
                                                                  theLanguageYouRememberedFromLastTime,
                                                                  "SampleApp", "SampleApp", Application.ProductVersion,
                                                                  directoryOfInstalledXliffFiles,
                                                                  "MyCompany/L10NSharpSample",
                                                                  Resources.Icon, //replace with your icon
                                                                  "*****@*****.**", "SampleApp");

                Settings.Default.UserInterfaceLanguage = LocalizationManager.UILanguageId;
            }
            catch (Exception error)
            {
                if (Process.GetProcesses().Count(p => p.ProcessName.ToLower().Contains("SampleApp")) > 1)
                {
                    MessageBox.Show("There is another copy of SampleApp already running while SampleApp was trying to set up localization.");
                    Environment.FailFast("SampleApp couldn't set up localization");
                }

                if (error.Message.Contains("SampleApp.en.xlf"))
                {
                    MessageBox.Show("Sorry. SampleApp 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("SampleApp couldn't set up localization");
                }

                //otherwise, we don't know what caused it.
                throw;
            }
        }
        public void Setup()
        {
            _collectionSettings = new Mock <CollectionSettings>();
            _collectionSettings.SetupGet(x => x.IsSourceCollection).Returns(false);
            _collectionSettings.SetupGet(x => x.Language1Iso639Code).Returns("xyz");
            _collectionSettings.SetupGet(x => x.Language2Iso639Code).Returns("fr");
            _collectionSettings.SetupGet(x => x.Language3Iso639Code).Returns("es");
            _collectionSettings.SetupGet(x => x.XMatterPackName).Returns("Factory");
            ErrorReport.IsOkToInteractWithUser = false;

            LocalizationManager.UseLanguageCodeFolders = true;
            var localizationDirectory = FileLocationUtilities.GetDirectoryDistributedWithApplication("src/BloomTests/TestLocalization");

            _localizationManager = LocalizationManager.Create(TranslationMemory.XLiff, "en", "Bloom", "Bloom", "1.0.0", localizationDirectory, "SIL/BloomTests", null, "");
        }
示例#10
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;
            }
        }
        public void Setup()
        {
            Logger.Init();
            _folder = new TemporaryFolder("ImageServerTests");
            var localizationDirectory = FileLocator.GetDirectoryDistributedWithApplication("localization");

            LocalizationManager.Create("fr", "Bloom", "Bloom", "1.0.0", localizationDirectory, "SIL/Bloom", null, "", new string[] { });


            ErrorReport.IsOkToInteractWithUser = false;
            _collectionPath = Path.Combine(_folder.Path, "TestCollection");
            var cs = new CollectionSettings(Path.Combine(_folder.Path, "TestCollection.bloomCollection"));

            _fileLocator = new BloomFileLocator(cs, new XMatterPackFinder(new string[] { BloomFileLocator.GetInstalledXMatterDirectory() }), ProjectContext.GetFactoryFileLocations(),
                                                ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations());
        }
示例#12
0
        public LocalizationManager CreateLocalizationManager()
        {
            var installedStringFileFolder      = Path.GetDirectoryName(FileLocator.GetFileDistributedWithApplication("SayMore.es.tmx"));
            var relativePathForWritingTmxFiles = Path.Combine(Program.kCompanyAbbrev, Application.ProductName);

            LocalizationManager.DeleteOldTmxFiles(kSayMoreLocalizationId,
                                                  Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), relativePathForWritingTmxFiles),
                                                  installedStringFileFolder);

            var localizationManager = LocalizationManager.Create(Settings.Default.UserInterfaceLanguage, kSayMoreLocalizationId,
                                                                 "SayMore", Application.ProductVersion, installedStringFileFolder, relativePathForWritingTmxFiles,
                                                                 Resources.SayMore, "*****@*****.**", "SayMore", "SIL.Archiving", "SIL.Windows.Forms.FileSystem");

            Settings.Default.UserInterfaceLanguage = LocalizationManager.UILanguageId;

            return(localizationManager);
        }
        public void Setup()
        {
            _collectionSettings = new CollectionSettings
            {
                IsSourceCollection  = false,
                Language1Iso639Code = "xyz",
                Language2Iso639Code = "fr",
                Language3Iso639Code = "es",
                XMatterPackName     = "Factory"
            };
            ErrorReport.IsOkToInteractWithUser = false;

            LocalizationManager.UseLanguageCodeFolders = true;
            var localizationDirectory = FileLocationUtilities.GetDirectoryDistributedWithApplication("src/BloomTests/TestLocalization");

            _localizationManager = LocalizationManager.Create(TranslationMemory.XLiff, "en", "Bloom", "Bloom", "1.0.0", localizationDirectory, "SIL/BloomTests", null, "");
        }
示例#14
0
        /// <summary>
        /// Typically root directory of installed files is something like [application exe directory]/localizations.
        /// root directory of user modifiable tmx files has to be outside program files, something like
        /// GetXAppDataFolder()/localizations, where GetXAppDataFolder would typically return something like
        /// Company/Program (e.g. SIL/SayMore)
        /// </summary>
        /// <param name="desiredUiLangId"></param>
        /// <param name="rootDirectoryOfInstalledTmxFiles">The folder path of the original TMX files
        /// installed with the application.  The Chorus TMX files will be in a Chorus subdirectory of this directory.</param>
        /// <param name="relativeDirectoryOfUserModifiedTmxFiles">The path, relative to %appdata%, where your
        /// application stores user settings (e.g., "SIL\SayMore"). A folder named "Chorus\localizations" will be created there.</param>
        public static void SetUpLocalization(string desiredUiLangId, string rootDirectoryOfInstalledTmxFiles,
                                             string relativeDirectoryOfUserModifiedTmxFiles)
        {
            string directoryOfInstalledTmxFiles    = Path.Combine(rootDirectoryOfInstalledTmxFiles, "Chorus");
            string directoryOfUserModifiedTmxFiles = Path.Combine(relativeDirectoryOfUserModifiedTmxFiles, "Chorus");

            // This is safer than Application.ProductVersion, which might contain words like 'alpha' or 'beta',
            // which (on the SECOND run of the program) fail when L10NSharp tries to make a Version object out of them.
            var versionObj = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            // We don't need to reload strings for every "revision" (that might be every time we build).
            var version = "" + versionObj.Major + "." + versionObj.Minor + "." + versionObj.Build;

            LocalizationManager.Create(desiredUiLangId, "Chorus", Application.ProductName,
                                       version, directoryOfInstalledTmxFiles,
                                       directoryOfUserModifiedTmxFiles,
                                       Icon.FromHandle(Properties.Resources.chorus32x32.GetHicon()),             // should call DestroyIcon, but when?
                                       "*****@*****.**", "Chorus");
        }
        // POST
        // CREATE
        public IHttpActionResult Post(Localization localization)
        {
            try
            {
                var mng = new LocalizationManager();
                mng.Create(localization);

                apiResp         = new ApiResponse();
                apiResp.Message = "Action was executed.";

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-"
                                                         + bex.AppMessage.Message)));
            }
        }
示例#16
0
        public void Setup()
        {
            _collectionSettings = new CollectionSettings(new NewCollectionSettings()
            {
                PathToSettingsFile  = CollectionSettings.GetPathForNewSettings(new TemporaryFolder("BookDataTests").Path, "test"),
                Language1Iso639Code = "xyz",
                Language2Iso639Code = "en",
                Language3Iso639Code = "fr"
            });
            ErrorReport.IsOkToInteractWithUser = false;

            LocalizationManager.UseLanguageCodeFolders = true;
            var localizationDirectory = FileLocationUtilities.GetDirectoryDistributedWithApplication("localization");

            _localizationManager = LocalizationManager.Create(TranslationMemory.XLiff, "fr", "Bloom", "Bloom", "1.0.0", localizationDirectory, "SIL/Bloom",
                                                              null, "", new string[] { });
            _palasoLocalizationManager = LocalizationManager.Create(TranslationMemory.XLiff, "fr", "Palaso", "Palaso", "1.0.0", localizationDirectory, "SIL/Bloom",
                                                                    null, "", new string[] { });
        }
示例#17
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var installedStringFileFolder = FileLocationUtilities.GetDirectoryDistributedWithApplication(false, "localization");

            LocalizationManager.UseLanguageCodeFolders    = true;
            LocalizationManager.ReturnOnlyApprovedStrings = true;

            // we start with the language of their Operating System
            var uiLanguage = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

            // then if they've chosen a language in the past, use that
            if (Settings.Default.UserInterfaceLanguageSetExplicitly)
            {
                uiLanguage = Settings.Default.UserInterfaceLanguage;
            }

            using (var lm = LocalizationManager.Create(TranslationMemory.XLiff,
                                                       uiLanguage,
                                                       "Palaso", "Palaso", "1.0.0" /*product version*/, installedStringFileFolder, "SIL/Palaso",
                                                       null /*icon*/, ""))
            {
                // if the language we asked for wasn't available, the LocalizationManager will ask the user
                // to choose a different one. If that happens, let's remember their choice for next time
                if (uiLanguage != LocalizationManager.UILanguageId)
                {
                    Settings.Default.UserInterfaceLanguage = LocalizationManager.UILanguageId;
                    Settings.Default.UserInterfaceLanguageSetExplicitly = true;
                    Settings.Default.Save();
                }
                Application.Run(new Form1());
            }

            /*
             * LocalizationManager.SetUILanguage(tag.IsoCode, true);
             * Settings.Default.UserInterfaceLanguage = tag.IsoCode;
             * Settings.Default.UserInterfaceLanguageSetExplicitly = true;
             * Settings.Default.Save();
             */
        }
        public void Setup()
        {
            _collectionSettings = new CollectionSettings(new NewCollectionSettings()
            {
                PathToSettingsFile  = CollectionSettings.GetPathForNewSettings(new TemporaryFolder("BookDataTests").Path, "test"),
                Language1Iso639Code = "xyz",
                Language2Iso639Code = "en",
                Language3Iso639Code = "fr"
            });
            ErrorReport.IsOkToInteractWithUser = false;

            var localizationDirectory = FileLocator.GetDirectoryDistributedWithApplication("localization");

            _localizationManager = LocalizationManager.Create("fr", "Bloom", "Bloom", "1.0.0", localizationDirectory, "SIL/Bloom",
                                                              null, "", new string[] {});
            _palasoLocalizationManager = LocalizationManager.Create("fr", "Palaso", "Palaso", "1.0.0", localizationDirectory, "SIL/Bloom",
                                                                    null, "", new string[] { });

            _brandingFolder            = new TemporaryFolder("unitTestBrandingFolder");
            _pathToBrandingSettingJson = _brandingFolder.Combine("settings.json");
        }
示例#19
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Sldr.Initialize();
            var localizationFolder = Path.GetDirectoryName(FileLocationUtilities.GetFileDistributedWithApplication("Palaso.en.tmx"));

            LocalizationManager.Create("fr", "Palaso", "Palaso", "1.0.0", localizationFolder, "SIL/Palaso",
                                       null, "");
            if (args.Length > 0)          //for testing commandlinerunner
            {
                for (int i = 0; i < 10; i++)
                {
                    Console.WriteLine(i);
                    Thread.Sleep(1000);
                }
                return;
            }

            Application.Run(new TestAppForm());

            Sldr.Cleanup();
        }
示例#20
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string filename;

            var args = Environment.GetCommandLineArgs();

            if (args.Length >= 2)
            {
                filename = args[1];
            }
            else
            {
                using (var dlg = new OpenFileDialog())
                {
                    dlg.Filter          = "Translation Memory File (*.tmx)|*.tmx|All Files (*.*)|*.*";
                    dlg.Title           = "Open Translation Memory File";
                    dlg.CheckPathExists = true;
                    dlg.CheckFileExists = true;
                    dlg.Multiselect     = false;
                    if (dlg.ShowDialog() == DialogResult.Cancel)
                    {
                        return;
                    }

                    filename = dlg.FileName;
                }
            }

            var folder  = Path.GetDirectoryName(filename);
            var file    = Path.GetFileNameWithoutExtension(filename);
            var manager = LocalizationManager.Create(file, file, folder);

            manager.ShowLocalizationDialogBox(true);
        }
示例#21
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Prepares the selected files to be uploaded to REAP using RAMP.
        /// </summary>
        /// <param name="owner">RAMP dialog owner</param>
        /// <param name="dialogFont">RAMP dialog font (for localization and consistency)</param>
        /// <param name="localizationDialogIcon"></param>
        /// <param name="filesToArchive"></param>
        /// <param name="mediator"></param>
        /// <param name="thisapp"></param>
        /// <param name="cache"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public bool ArchiveNow(Form owner, Font dialogFont, Icon localizationDialogIcon,
                               IEnumerable <string> filesToArchive, Mediator mediator, FwApp thisapp, FdoCache cache)
        {
            var viProvider = new VersionInfoProvider(Assembly.LoadFile(thisapp.ProductExecutableFile), false);
            var wsMgr      = cache.ServiceLocator.GetInstance <IWritingSystemManager>();
            var appName    = thisapp.ApplicationName;
            var title      = cache.LanguageProject.ShortName;
            var uiLocale   = wsMgr.Get(cache.DefaultUserWs).IcuLocale;
            var projectId  = cache.LanguageProject.ShortName;

            var model = new RampArchivingDlgViewModel(Application.ProductName, title, projectId, /*appSpecificArchivalProcessInfo:*/ string.Empty, SetFilesToArchive(filesToArchive), GetFileDescription);

            // image files should be labeled as Graphic rather than Photograph (the default).
            model.ImagesArePhotographs = false;

            // show the count of media files, not the duration
            model.ShowRecordingCountNotLength = true;

            // set the general description, in each available language
            IMultiString descr        = cache.LanguageProject.Description;
            var          descriptions = new Dictionary <string, string>();

            foreach (int wsid in descr.AvailableWritingSystemIds)
            {
                var descrText = descr.get_String(wsid).Text;
                if ((!string.IsNullOrEmpty(descrText)) && (descrText != "***"))
                {
                    descriptions[wsMgr.Get(wsid).GetIso3Code()] = descrText;
                }
            }

            if (descriptions.Count > 0)
            {
                model.SetDescription(descriptions);
            }

            AddMetsPairs(model, viProvider.ShortNumericAppVersion, cache);

            const string localizationMgrId = "Archiving";

            if (s_localizationMgr == null)
            {
                s_localizationMgr = LocalizationManager.Create(
                    uiLocale,
                    localizationMgrId, viProvider.ProductName, viProvider.NumericAppVersion,
                    FwDirectoryFinder.GetCodeSubDirectory("ArchivingLocalizations"),
                    Path.Combine(Application.CompanyName, appName),
                    localizationDialogIcon, "*****@*****.**", "SIL.Archiving");
            }
            else
            {
                LocalizationManager.SetUILanguage(uiLocale, true);
            }

            // create the dialog
            using (var dlg = new ArchivingDlg(model, localizationMgrId, dialogFont, new FormSettings()))
                using (var reportingAdapter = new PalasoErrorReportingAdapter(dlg, mediator))
                {
                    ErrorReport.SetErrorReporter(reportingAdapter);
                    dlg.ShowDialog(owner);
                    ErrorReport.SetErrorReporter(null);
                }

            return(true);
        }