public void Should_Localize_AbpWebCommon_Text()
 {
     using (CultureInfoHelper.Use("en"))
     {
         _localizationManager
         .GetSource(AbpWebConsts.LocalizaionSourceName)
         .GetString("ValidationError")
         .ShouldBe("Your request is not valid!");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Gets a localized string value.
        /// </summary>
        /// <param name="tenantId">TenantId or null for host</param>
        /// <param name="sourceName">Source name</param>
        /// <param name="culture">Culture</param>
        /// <param name="key">Localization key</param>
        /// <param name="tryDefaults">True: fallbacks to default languages if can not find in given culture</param>
        public string GetStringOrNull(int?tenantId, string sourceName, CultureInfo culture, string key, bool tryDefaults = true)
        {
            var source = _localizationManager.GetSource(sourceName);

            if (!(source is IMultiTenantLocalizationSource))
            {
                return(source.GetStringOrNull(key, culture, tryDefaults));
            }

            return(source
                   .As <IMultiTenantLocalizationSource>()
                   .GetStringOrNull(tenantId, key, culture, tryDefaults));
        }
Beispiel #3
0
        public void Should_Get_Localized_Strings()
        {
            var source = _localizationManager.GetSource(AbpWebLocalizedMessages.SourceName);

            source.GetString("Yes", new CultureInfo("en-US")).ShouldBe("Yes");
            source.GetString("Yes", new CultureInfo("tr-TR")).ShouldBe("Evet");
        }
Beispiel #4
0
        public async Task <string> SendMessage(SendChatMessageInput input)
        {
            var sender   = Context.ToUserIdentifier();
            var receiver = new UserIdentifier(input.TenantId, input.UserId);

            try
            {
                using (ChatAbpSession.Use(Context.GetTenantId(), Context.GetUserId()))
                {
                    await _chatMessageManager.SendMessageAsync(sender, receiver, input.Message, input.TenancyName, input.UserName, input.ProfilePictureId);

                    return(string.Empty);
                }
            }
            catch (UserFriendlyException ex)
            {
                Logger.Warn("Could not send chat message to user: "******"Could not send chat message to user: "******"AbpWeb").GetString("InternalServerError"));
            }
        }
Beispiel #5
0
 public ImportUsersToExcelJob(
     RoleManager roleManager,
     IUserListExcelDataReader userListExcelDataReader,
     IInvalidUserExporter invalidUserExporter,
     IUserPolicy userPolicy,
     IEnumerable <IPasswordValidator <User> > passwordValidators,
     IPasswordHasher <User> passwordHasher,
     IAppNotifier appNotifier,
     IRepository <Shift> shiftRepository,
     IRepository <OrganizationUnitExtended, long> organizationUnitRepository,
     IRepository <User, long> userRepository,
     IBinaryObjectManager binaryObjectManager,
     ILocalizationManager localizationManager,
     IObjectMapper objectMapper)
 {
     _roleManager             = roleManager;
     _userRepository          = userRepository;
     _userListExcelDataReader = userListExcelDataReader;
     _invalidUserExporter     = invalidUserExporter;
     _userPolicy = userPolicy;
     _organizationUnitRepository = organizationUnitRepository;
     _shiftRepository            = shiftRepository;
     _passwordValidators         = passwordValidators;
     _passwordHasher             = passwordHasher;
     _appNotifier         = appNotifier;
     _binaryObjectManager = binaryObjectManager;
     _objectMapper        = objectMapper;
     _localizationSource  = localizationManager.GetSource(AttendanceConsts.LocalizationSourceName);
 }
Beispiel #6
0
        public IActionResult Get()
        {
            var localizationSource = localizationManager.GetSource(Constants.LocalizationSourceName);

            var localizedHelloMessage = localizationSource.GetString(GlobalizationKey.Hello);

            return(Json(localizedHelloMessage));
        }
        public async Task ShouldHelloInPortugueseCulture()
        {
            // Arrange
            SetRequestCulture(CultureInfo.GetCultureInfo("pt-BR"));

            // Act
            var response = await GetResponseAsObjectAsync <string>(
                @"api/hello",
                HttpStatusCode.OK);

            // Assert
            var localizationSource = localizationManager.GetSource(Constants.LocalizationSourceName);

            var localizedHelloMessage = localizationSource.GetString(GlobalizationKey.Hello, requestCulture);

            Assert.Equal(localizedHelloMessage, response);
        }
Beispiel #8
0
        public void Should_Get_Localized_Strings()
        {
            var names = Assembly.GetAssembly(typeof(AbpWebModule)).GetManifestResourceNames();

            var source = _localizationManager.GetSource(AbpWebLocalizedMessages.SourceName);

            source.GetString("Yes", new CultureInfo("en-US")).ShouldBe("Yes");
            source.GetString("Yes", new CultureInfo("tr-TR")).ShouldBe("Evet");
        }
        public void ShouldGetLocalizedStrings()
        {
            var names = Assembly.GetAssembly(typeof(StudioXWebModule)).GetManifestResourceNames();

            var source = localizationManager.GetSource(StudioXWebConsts.LocalizaionSourceName);

            source.GetString("Yes", new CultureInfo("en-US")).ShouldBe("Yes");
            source.GetString("Yes", new CultureInfo("tr-TR")).ShouldBe("Evet");
        }
 public FirebaseNotificationService(
     IOptions <FirebaseCloudMessagingOptions> options,
     ILocalizationManager localizationManager,
     ILogger <FirebaseNotificationService> logger)
 {
     _options = options.Value;
     _applicationLocalizationSource = localizationManager.GetSource(LocalizationSources.Application);
     _logger = logger;
 }
Beispiel #11
0
 public EngageSpotNotificationService(
     IHttpClientFactory httpClientFactory,
     ILocalizationManager localizationManager,
     ILogger <EngageSpotNotificationService> logger,
     IOptions <EngageSpotOptions> options)
 {
     _httpClientFactory             = httpClientFactory;
     _applicationLocalizationSource = localizationManager.GetSource(LocalizationSources.Application);
     _logger  = logger;
     _options = options.Value;
 }
Beispiel #12
0
 public StateImportAppService(IRepository <StateInfo> stateInfoRepository,
                              IRepository <CityInfo> cityInfoRepository, IRepository <RegionInfo> regionInfoRepository
                              , IRepository <VillageInfo> villageInfoRepository, ILocalizationManager localizationManager,
                              IUnitOfWorkManager unitOfWorkManager)
 {
     _stateInfoRepository   = stateInfoRepository;
     _cityInfoRepository    = cityInfoRepository;
     _villageInfoRepository = villageInfoRepository;
     _unitOfWorkManager     = unitOfWorkManager;
     _regionInfoRepository  = regionInfoRepository;
     _localizationSource    = localizationManager.GetSource(BreedConsts.LocalizationSourceName);
 }
        public AbpFluentValidationLanguageManager(
            ILocalizationManager localizationManager,
            ILanguageManager languageManager,
            IAbpFluentValidationConfiguration configuration)
        {
            if (!configuration.LocalizationSourceName.IsNullOrEmpty())
            {
                var source    = localizationManager.GetSource(configuration.LocalizationSourceName);
                var languages = languageManager.GetLanguages();

                AddAllTranslations(source, languages);
            }
        }
        public async Task Should_Return_With_Notifications()
        {
            // Act
            var response = await GetResponseAsObjectAsync <List <NotificationEvent> >(
                @"api/hash",
                HttpStatusCode.BadRequest);

            var notificatioEvent = _localizationManager
                                   .GetSource(Case2Consts.LocalizationSourceName)
                                   .GetString(HashService.Error.CalculateHashInvalidValue, _culture);

            // Assert
            Assert.Contains(response, c => c.Message == notificatioEvent);
        }
        private static string LocalizeErrorMessage(string identityErrorMessage, ILocalizationManager localizationManager)
        {
            var localizationSource = localizationManager.GetSource(CodeZeroConsts.LocalizationSourceName);

            foreach (var identityLocalization in IdentityLocalizations)
            {
                if (FormattedStringValueExtracter.IsMatch(identityErrorMessage, identityLocalization.Key, out var values))
                {
                    return(localizationSource.GetString(identityLocalization.Value, values.Cast <object>().ToArray()));
                }
            }

            return(localizationSource.GetString("Identity.DefaultError"));
        }
        public async Task ShouldNotAllowNewOrderDuplicated()
        {
            var purchaseOrderService = Resolve <IPurchaseOrderService>();

            var newOrder = await purchaseOrderService.CreateNewPurchaseOrder(purchaseOrder);

            Assert.True(LocalNotification.HasNotification());

            // Assert
            var localizationSource = localizationManager.GetSource(Constants.LocalizationSourceName);

            var duplicatedMessage = localizationSource.GetString(GlobalizationKey.DuplicatePurchaseOrder);

            Assert.Contains(LocalNotification.GetAll(), w => w.DetailedMessage == GlobalizationKey.DuplicatePurchaseOrder.ToString());
            Assert.Contains(LocalNotification.GetAll(), w => w.Message == string.Format(duplicatedMessage, purchaseOrder.ClientId, purchaseOrder.Data));
        }
Beispiel #17
0
        public static string LocalizeErrors(this IdentityResult identityResult, ILocalizationManager localizationManager, string localizationSourceName)
        {
            if (identityResult.Succeeded)
            {
                throw new ArgumentException("identityResult.Succeeded should be false in order to localize errors.");
            }

            if (identityResult.Errors == null)
            {
                throw new ArgumentException("identityResult.Errors should not be null.");
            }

            var localizationSource = localizationManager.GetSource(localizationSourceName);

            return(identityResult.Errors.Select(err => LocalizeErrorMessage(err.Description, localizationSource)).JoinAsString(" "));
        }
Beispiel #18
0
 public ImportShipmentsFromExcelJob(
     IShipmentListExcelDataReader shippmentListExcelDataReader,
     IInvalidShipmentExporter invalidUserExporter,
     IAppNotifier appNotifier,
     IBinaryObjectManager binaryObjectManager,
     ILocalizationManager localizationManager,
     IOrderManager orderManager,
     IOrderImportor orderImportor,
     IOrderProcessingManager orderProcessingManager,
     ILogisticsManager logisticsManager)
 {
     _shipmentListExcelDataReader = shippmentListExcelDataReader;
     _invalidUserExporter         = invalidUserExporter;
     _appNotifier            = appNotifier;
     _binaryObjectManager    = binaryObjectManager;
     _orderImportor          = orderImportor;
     _orderManager           = orderManager;
     _orderProcessingManager = orderProcessingManager;
     _logisticsManager       = logisticsManager;
     LocalizationSourceName  = VappsConsts.ServerSideLocalizationSourceName;
     _localizationSource     = localizationManager.GetSource(VappsConsts.ServerSideLocalizationSourceName);
 }
Beispiel #19
0
        public string SendMessage(SendChatMessageInput input)
        {
            var sender   = InfrastructureSession.ToUserIdentifier();
            var receiver = new UserIdentifier(input.TenantId, input.UserId);

            try
            {
                _chatMessageManager.SendMessage(sender, receiver, input.Message, input.TenancyName, input.UserName, input.Avatar);
                return(string.Empty);
            }
            catch (UserFriendlyException ex)
            {
                Logger.Warn("Could not send chat message to user: "******"Could not send chat message to user: "******"Web").GetString("InternalServerError"));
            }
        }
 public ImportUsersToExcelJob(
     RoleManager roleManager,
     IUserListExcelDataReader userListExcelDataReader,
     IInvalidUserExporter invalidUserExporter,
     IUserPolicy userPolicy,
     IEnumerable <IPasswordValidator <User> > passwordValidators,
     IPasswordHasher <User> passwordHasher,
     IAppNotifier appNotifier,
     IBinaryObjectManager binaryObjectManager,
     ILocalizationManager localizationManager,
     IObjectMapper objectMapper)
 {
     _roleManager             = roleManager;
     _userListExcelDataReader = userListExcelDataReader;
     _invalidUserExporter     = invalidUserExporter;
     _userPolicy          = userPolicy;
     _passwordValidators  = passwordValidators;
     _passwordHasher      = passwordHasher;
     _appNotifier         = appNotifier;
     _binaryObjectManager = binaryObjectManager;
     _objectMapper        = objectMapper;
     _localizationSource  = localizationManager.GetSource(PhoneBookDemoConsts.LocalizationSourceName);
 }
        public ImportUsersToExcelJob(
            RoleManager roleManager,
            IUserListExcelDataReader userListExcelDataReader,
            IInvalidUserExporter invalidUserExporter,
            IUserPolicy userPolicy,
            IEnumerable <IPasswordValidator <User> > passwordValidators,
            IPasswordHasher <User> passwordHasher,


            ILocalizationManager localizationManager,
            IObjectMapper objectMapper, IDataFileObjectManager dataFileObjectManager, IAppMessage appMessage)
        {
            _roleManager             = roleManager;
            _userListExcelDataReader = userListExcelDataReader;
            _invalidUserExporter     = invalidUserExporter;
            _userPolicy         = userPolicy;
            _passwordValidators = passwordValidators;
            _passwordHasher     = passwordHasher;

            _objectMapper          = objectMapper;
            _dataFileObjectManager = dataFileObjectManager;
            _appMessage            = appMessage;
            _localizationSource    = localizationManager.GetSource(AppConsts.LocalizationSourceName);
        }
 /// <summary>
 /// Gets a localized string in specified language.
 /// </summary>
 /// <param name="localizationManager">Localization manager instance</param>
 /// <param name="sourceName">Name of the localization source</param>
 /// <param name="name">Key name to get localized string</param>
 /// <param name="culture">culture</param>
 /// <returns>Localized string</returns>
 public static string GetString(this ILocalizationManager localizationManager, string sourceName, string name, CultureInfo culture)
 {
     return(localizationManager.GetSource(sourceName).GetString(name, culture));
 }
Beispiel #23
0
 public UserListExcelDataReader(ILocalizationManager localizationManager)
 {
     _localizationSource = localizationManager.GetSource(PMSDemoConsts.LocalizationSourceName);
 }
 public UserListExcelDataReader(ILocalizationManager localizationManager)
 {
     _localizationSource = localizationManager.GetSource(AbpZeroTemplateConsts.LocalizationSourceName);
 }
 public UngVienListExcelDataReader(ILocalizationManager localizationManager)
 {
     _localizationSource = localizationManager.GetSource(HinnovaConsts.LocalizationSourceName);
 }
Beispiel #26
0
        //public static IList<KeyValuePair<int?, string>> GetNullableEnum(this ILocalizationSource localizationSource, Type enumType)
        //{
        //    return localizationSource.GetUnknown<int>(localizationSource.GetEnum(enumType));
        //}
        //public static IList<KeyValuePair<int?, string>> GetNullableEnum<T>(this ILocalizationSource localizationSource) where T : Enum
        //{
        //    return localizationSource.GetUnknown<int>(localizationSource.GetEnum<T>());
        //}

        public static IDictionary <int, string> GetEnum(this ILocalizationManager localizationManager, string sourceName, Type enumType)
        {
            return(localizationManager.GetSource(sourceName).GetEnum(enumType));
        }
 /// <summary>
 /// Gets a localized string in specified language.
 /// </summary>
 /// <param name="localizationManager">Localization manager instance</param>
 /// <param name="sourceName">Name of the localization source</param>
 /// <param name="name">Key name to get localized string</param>
 /// <param name="culture">culture</param>
 /// <param name="args">Format arguments</param>
 /// <returns>Localized string</returns>
 public static string GetString(this ILocalizationManager localizationManager, string sourceName, string name, CultureInfo culture, params object[] args)
 {
     return(localizationManager.GetSource(sourceName).GetString(name, culture, args));
 }
Beispiel #28
0
 public static IDictionary <int, string> GetEnum <T>(this ILocalizationManager localizationManager, string sourceName) where T : Enum
 {
     return(localizationManager.GetSource(sourceName).GetEnum <T>());
 }
        private static string LocalizeErrorMessage(string identityErrorMessage, ILocalizationManager localizationManager)
        {
            var localizationSource = localizationManager.GetSource(AbpZeroConsts.LocalizationSourceName);

            foreach (var identityLocalization in IdentityLocalizations)
            {
                string[] values;
                if (FormattedStringValueExtracter.IsMatch(identityErrorMessage, identityLocalization.Key, out values))
                {
                    return localizationSource.GetString(identityLocalization.Value, values.Cast<object>().ToArray());
                }
            }

            return localizationSource.GetString("Identity.DefaultError");
        }
 public TencentOrderExcelDataReader(ILocalizationManager localizationManager)
 {
     _localizationSource = localizationManager.GetSource(AppConsts.LocalizationSourceName);
 }
Beispiel #31
0
 public static IDictionary <bool, string> GetBool(this ILocalizationManager localizationManager, string sourceName)
 {
     return(localizationManager.GetSource(sourceName).GetBool());
 }