public II18Next CreateInstance() { var instance = new I18NextNet(_backend, _translator, _languageDetector) { Language = _options.Value.DefaultLanguage, DefaultNamespace = _options.Value.DefaultNamespace, Logger = _logger, DetectLanguageOnEachTranslation = _options.Value.DetectLanguageOnEachTranslation }; instance.SetFallbackLanguages(_options.Value.FallbackLanguages.ToArray()); return(instance); }
public static void Main(string[] args) { SetupBackend(); var translator = new DefaultTranslator(_backend); var i18Next = new I18NextNet(_backend, translator); Console.WriteLine("English translation:"); i18Next.Language = "en"; Console.WriteLine(i18Next.T("exampleKey")); Console.WriteLine("German translation:"); i18Next.Language = "de"; Console.WriteLine(i18Next.T("exampleKey")); i18Next.SetFallbackLanguages("en"); Console.WriteLine(i18Next.T("exampleKey2")); // should output "My English text." because of fallback language Console.ReadKey(); }
public void FallbackLanguageIsSet_MissingTranslation_ReturnsFallback() { _i18Next.Language = "de"; _i18Next.SetFallbackLanguages("en"); Assert.AreEqual("My English fallback.", _i18Next.T("exampleKey2")); }