public void VerifyAllSharedPropsAreInEnglishResx() { var options = Options.Create(new LocalizationOptions { ResourcesPath = "Resources" }); var factory = new ResourceManagerStringLocalizerFactory(options, NullLoggerFactory.Instance); var localizer = new StringLocalizer <SharedResource>(factory); var sharedResourceAsm = Assembly.Load("SIL.XForge.Scripture"); Assert.NotNull(sharedResourceAsm, "Um, what did you refactor?"); var sharedResourceClass = sharedResourceAsm.GetType("SIL.XForge.Scripture.SharedResource"); var sharedKeys = sharedResourceClass?.GetNestedType("Keys"); Assert.NotNull(sharedKeys, "Um, what did you refactor?"); // grab all the localization keys from SharedResource.Keys static class var publicProps = sharedKeys.GetFields(BindingFlags.Public | BindingFlags.Static); foreach (var propInfo in publicProps.Where(x => x.FieldType == typeof(string))) { var keyValue = (string)propInfo.GetValue(null); var englishStringFromResource = localizer.GetString(keyValue); // verify that each key is found Assert.IsFalse(englishStringFromResource.ResourceNotFound, "Missing english string from .resx for " + propInfo.Name); } Assert.AreEqual(publicProps.Length, localizer.GetAllStrings().Count(), "There are extra strings in the SharedResources.en.resx which are not in the SharedResource.Keys class"); }
public AddPlotPageViewModel( INavigationService navigationService, IStringLocalizer <AddPlotPageViewModel> stringLocalizer, IAppDataService appDataService) : base(navigationService, stringLocalizer) { randomColor = new Random(); AppDataService = appDataService; Plot = new Core.Entities.Plot(); PlantingDate = DateTime.Today; CropSelected = false; CropPickerEnabled = true; PickerCropTypesSelectedIndex = -1; PickerClimateTypesSelectedIndex = -1; PickerMaturityClassesSelectedIndex = -1; ClimateTypes = new List <string> { StringLocalizer.GetString("cold"), StringLocalizer.GetString("tempered"), StringLocalizer.GetString("tropical"), StringLocalizer.GetString("hybrid") }; CropTypes = new List <string> { StringLocalizer.GetString("none"), StringLocalizer.GetString("maize"), StringLocalizer.GetString("barley"), StringLocalizer.GetString("bean"), StringLocalizer.GetString("wheat"), StringLocalizer.GetString("triticale"), StringLocalizer.GetString("sorghum"), StringLocalizer.GetString("alfalfa"), StringLocalizer.GetString("oats"), StringLocalizer.GetString("sesame"), StringLocalizer.GetString("amaranth"), StringLocalizer.GetString("rice"), StringLocalizer.GetString("canola"), StringLocalizer.GetString("cartamo"), StringLocalizer.GetString("zucchini"), StringLocalizer.GetString("chickpea"), StringLocalizer.GetString("havabean"), StringLocalizer.GetString("soy"), StringLocalizer.GetString("other") }; MaturityClasses = new List <string> { StringLocalizer.GetString("early"), StringLocalizer.GetString("semi_early"), StringLocalizer.GetString("intermediate"), StringLocalizer.GetString("semi_late"), StringLocalizer.GetString("late") }; }
public override void InitPlugin() { Logger.LogInformation($"init tmp plugin {Guid.NewGuid()}"); Logger.LogInformation(StringLocalizer.GetString("hello")); var sb = new StringBuilder("===================\nall strings:\n"); foreach (var str in StringLocalizer.GetAllStrings(true)) { sb.AppendLine($"{str.Name}: {str.Value} ({str.SearchedLocation})"); } Logger.LogInformation(sb.ToString()); Logger.LogInformation(StringLocalizer.GetString("bye")); }
public WeatherHistoryPageViewModel(INavigationService navigationService, IStringLocalizer <WeatherHistoryPageViewModel> stringLocalizer) : base(navigationService, stringLocalizer) { DatasetNames = new List <string> { StringLocalizer.GetString("precip"), StringLocalizer.GetString("rhh"), StringLocalizer.GetString("rhl"), StringLocalizer.GetString("sr"), StringLocalizer.GetString("tl"), StringLocalizer.GetString("th"), StringLocalizer.GetString("wa"), StringLocalizer.GetString("wdh"), StringLocalizer.GetString("wmh") }; SelectedDataset = -1; }
public void OnGet() { ViewData["Title"] = StringLocalizer.GetString("Title"); }
public void LocalizerHomeController() { ViewData["Title"] = StringLocalizer.GetString("Title"); ViewData["About"] = StringLocalizer.GetString("About"); }
public LocalizedString GetString(string name) { return(StringLocalizer.GetString(name)); }
/// <summary> /// Gets localized string for given key name and current language. /// </summary> protected string L(string name) => StringLocalizer.GetString(name);