public void Should_Localize_AbpWebCommon_Texts() { using (CultureInfoHelper.Use("en")) { _localizationManager .GetSource(AbpWebConsts.LocalizaionSourceName) .GetString("ValidationError") .ShouldBe("Your request is not valid!"); } }
public IActionResult Index() { var hello = LocalizationManager.GetSource("MySource").GetStringOrNull("hello"); using (CultureInfoHelper.Use("tr", "tr")) { var hellotr = LocalizationManager.GetSource("MySource").GetStringOrNull("hello"); } return(Redirect("/swagger")); }
public void ToSentenceCase_Test() { (null as string).ToSentenceCase().ShouldBe(null); "HelloWorld".ToSentenceCase().ShouldBe("Hello world"); using (CultureInfoHelper.Use("en-US")) { "HelloIsparta".ToSentenceCase().ShouldBe("Hello isparta"); } "HelloIsparta".ToSentenceCase(new CultureInfo("tr-TR")).ShouldBe("Hello ısparta"); }
public void Test_Json_Override() { var mananger = LocalIocManager.Resolve <ILocalizationManager>(); using (CultureInfoHelper.Use("en")) { var abpSource = mananger.GetSource(AbpConsts.LocalizationSourceName); abpSource.GetString("TimeZone").ShouldBe("Time-zone"); var abpZeroSource = mananger.GetSource(AbpZeroConsts.LocalizationSourceName); abpZeroSource.GetString("Email").ShouldBe("Email address"); } }
public void Should_Localize_AbpWebCommon_Texts() { using (CultureInfoHelper.Use("en")) { var texts = _localizationManager .GetSource(AbpWebConsts.LocalizaionSourceName) .GetStrings(new List <string> { "ValidationError", "InternalServerError" }); texts.ShouldContain(x => x == "Your request is not valid!"); texts.ShouldContain(x => x == "An internal error occurred during your request!"); } }
public override async Task ExecuteAsync(UserIdentifier args) { using (UnitOfWorkManager.Current.SetTenantId(args.TenantId)) { var userLanguage = await _settingManager.GetSettingValueForUserAsync( LocalizationSettingNames.DefaultLanguage, args.TenantId, args.UserId ); var culture = CultureHelper.GetCultureInfoByChecking(userLanguage); using (CultureInfoHelper.Use(culture)) { var files = new List <FileDto>(); using (var scope = IocManager.Instance.CreateScope()) { var providers = scope.ResolveAll <IUserCollectedDataProvider>(); foreach (var provider in providers) { var providerFiles = await provider.GetFiles(args); if (providerFiles.Any()) { files.AddRange(providerFiles); } } } var zipFile = new BinaryObject ( args.TenantId, CompressFiles(files), $"{args.UserId} {DateTime.UtcNow} UserCollectedDataPrepareJob result" ); // Save zip file to object manager. await _binaryObjectManager.SaveAsync(zipFile); // Send notification to user. await _appNotifier.GdprDataPrepared(args, zipFile.Id); } } }
public void EnsureStartsWith_Test() { //Expected use-cases "Test".EnsureStartsWith('~').ShouldBe("~Test"); "~Test".EnsureStartsWith('~').ShouldBe("~Test"); //Case differences "Turkey".EnsureStartsWith('t').ShouldBe("tTurkey"); "Turkey".EnsureStartsWith('t', StringComparison.OrdinalIgnoreCase).ShouldBe("Turkey"); //Edge cases for Turkish 'i'. #if NET46 "İstanbul".EnsureStartsWith('i', true, new CultureInfo("tr-TR")).ShouldBe("İstanbul"); "İstanbul".EnsureStartsWith('i', false, new CultureInfo("tr-TR")).ShouldBe("iİstanbul"); #else using (CultureInfoHelper.Use("tr-TR")) { "İstanbul".EnsureStartsWith('i', StringComparison.CurrentCultureIgnoreCase).ShouldBe("İstanbul"); "İstanbul".EnsureStartsWith('i', StringComparison.CurrentCulture).ShouldBe("iİstanbul"); } #endif }
public override void Execute(UserIdentifier args) { using (UnitOfWorkManager.Current.SetTenantId(args.TenantId)) { var userLanguage = AsyncHelper.RunSync(() => _settingManager.GetSettingValueForUserAsync(LocalizationSettingNames.DefaultLanguage, args.TenantId, args.UserId)); var culture = CultureHelper.GetCultureInfoByChecking(userLanguage); using (CultureInfoHelper.Use(culture)) { var files = new List <FileDto>(); using (var scope = IocManager.Instance.CreateScope()) { var providers = scope.ResolveAll <IUserCollectedDataProvider>(); foreach (var provider in providers) { var providerFiles = AsyncHelper.RunSync(() => provider.GetFiles(args)); if (providerFiles.Any()) { files.AddRange(providerFiles); } } } var zipFile = new BinaryObject { TenantId = args.TenantId, Bytes = CompressFiles(files) }; // Save zip file to object manager. _binaryObjectManager.SaveAsync(zipFile); //AsyncHelper.RunSync(() => ); // Send notification to user. AsyncHelper.RunSync(() => _appNotifier.GdprDataPrepared(args, zipFile.Id)); } } }
public void Test_Xml_Json() { var mananger = LocalIocManager.Resolve <LocalizationManager>(); using (CultureInfoHelper.Use("en")) { var source = mananger.GetSource("Lang"); source.GetString("Apple").ShouldBe("Apple"); source.GetString("Banana").ShouldBe("Banana"); source.GetString("ThisIsATest").ShouldBe("This is a test."); source.GetString("HowAreYou").ShouldBe("How are you?"); } using (CultureInfoHelper.Use("zh-Hans")) { var source = mananger.GetSource("Lang"); source.GetString("Apple").ShouldBe("苹果"); source.GetString("Banana").ShouldBe("香蕉"); source.GetString("ThisIsATest").ShouldBe("这是一个测试."); source.GetString("HowAreYou").ShouldBe("你好吗?"); } }
public void EnsureEndsWith_Test() { //Expected use-cases "Test".EnsureEndsWith('!').ShouldBe("Test!"); "Test!".EnsureEndsWith('!').ShouldBe("Test!"); @"C:\test\folderName".EnsureEndsWith('\\').ShouldBe(@"C:\test\folderName\"); @"C:\test\folderName\".EnsureEndsWith('\\').ShouldBe(@"C:\test\folderName\"); //Case differences "TurkeY".EnsureEndsWith('y').ShouldBe("TurkeYy"); "TurkeY".EnsureEndsWith('y', StringComparison.OrdinalIgnoreCase).ShouldBe("TurkeY"); //Edge cases for Turkish 'i'. #if NET46 "TAKSİ".EnsureEndsWith('i', true, new CultureInfo("tr-TR")).ShouldBe("TAKSİ"); "TAKSİ".EnsureEndsWith('i', false, new CultureInfo("tr-TR")).ShouldBe("TAKSİi"); #else using (CultureInfoHelper.Use("tr-TR")) { "TAKSİ".EnsureEndsWith('i', StringComparison.CurrentCultureIgnoreCase).ShouldBe("TAKSİ"); "TAKSİ".EnsureEndsWith('i', StringComparison.CurrentCulture).ShouldBe("TAKSİi"); } #endif }