Example #1
0
        public Language FindBestLanguage(string languageName)
        {
            if (string.IsNullOrEmpty(languageName))
            {
                languageName = "en";
            }

            try
            {
                var cultureInfo = new CultureInfo(languageName);
                return(LanguageLoader.FindBestLanguage(cultureInfo));
            }
            catch (CultureNotFoundException)
            {
            }

            var language = LanguageLoader.GetAvailableLanguages().FirstOrDefault(x => x.Iso2 == languageName);

            if (language != null)
            {
                return(language);
            }

            return(LanguageLoader.FindBestLanguage(new CultureInfo("en")));
        }
Example #2
0
        public void SetUp()
        {
            _translationTestHelper = new TranslationTestHelper();

            var a      = Assembly.GetExecutingAssembly();
            var appDir = Path.GetDirectoryName(a.CodeBase.Replace(@"file:///", ""));

            if (appDir == null)
            {
                throw new InvalidDataException("The app dir may never be null");
            }

            _languagePath = _translationTestHelper.FindTranslationFolder();

            Assert.True(Directory.Exists(_languagePath), "Could not find language path: " + _languagePath);

            var languageLoader = new LanguageLoader(_languagePath);

            _translations = languageLoader.GetAvailableLanguages().ToList();

            _settings = new PdfCreatorSettings(new IniStorage());
            _settings.LoadData("settings.ini");

            var assemblyHelper = Substitute.For <IAssemblyHelper>();

            assemblyHelper.GetPdfforgeAssemblyDirectory().Returns(Path.Combine(_languagePath, ".."));

            LoggingHelper.InitConsoleLogger("PDFCreator-TranslationTest", LoggingLevel.Error);
            var settingsProvider = new DefaultSettingsProvider();

            settingsProvider.UpdateSettings(_settings);

            _translationProxy = new MappedTranslationProxy(new TranslationProxy(), _languagePath + "\\_sectionMappings.txt");

            _translationHelper = new TranslationHelper(_translationProxy, settingsProvider, assemblyHelper);
            _translationHelper.InitTranslator(_settings.ApplicationSettings.Language);

            // TODO extact stuff into separate classes, so this test only contains the actual test code
        }
 public IEnumerable <Language> GetAvailableLanguages()
 {
     return(LanguageLoader.GetAvailableLanguages());
 }
Example #4
0
 public IEnumerable <Language> GetAvailableLanguages()
 {
     return(LanguageLoader.GetAvailableLanguages().OrderBy(t => t.NativeName));
 }