private string NotesForGetBankDetailsByLevel() { var userLang = ClaimsManager.GetClaimValue(ClaimsNames.Language); var notes = LocalizationProvider.GetTranslation(LocalizationProvider.DefaultApplication, userLang, "STRKEY_API_GETBANKDETAILS_NOTES"); return(notes); }
/// <summary> /// When the action executes, validates the model state. /// </summary> /// <param name="actionContext">The context of the action.</param> public override void OnActionExecuting(HttpActionContext actionContext) { if (actionContext.ModelState.IsValid == false) { var localization = new LocalizationProvider(); var sb = new StringBuilder(); foreach (var value in actionContext.ModelState.Values) { foreach (var error in value.Errors) { var localized = localization.GetString(error.ErrorMessage, this.ResourceFileRoot); if (string.IsNullOrWhiteSpace(localized)) { localized = error.ErrorMessage; } sb.AppendLine(localized); } } actionContext.Response = actionContext.Request.CreateErrorResponse( HttpStatusCode.BadRequest, sb.ToString()); } }
private static void ShowOneButtonAlert(Activity scope, string type, string message, Action action = null, int?actionTitle = null) { var custom_title = new TextView(scope); custom_title.Text = type; custom_title.SetBackgroundResource(Resource.Color.main); custom_title.SetPadding(10, 10, 10, 10); custom_title.Gravity = Android.Views.GravityFlags.Center; custom_title.SetTextColor(Color.White); custom_title.SetTextSize(Android.Util.ComplexUnitType.Dip, 18); custom_title.SetTypeface(custom_title.Typeface, TypefaceStyle.Bold); var buttonTitle = actionTitle ?? Resource.String.ok; var builder = new AlertDialog.Builder(scope) .SetNeutralButton(LocalizationProvider.Translate(buttonTitle), (s, ev) => action?.Invoke()) .SetMessage(message) .SetCustomTitle(custom_title) .SetCancelable(false) .Show(); builder.Window.SetBackgroundDrawableResource(Resource.Drawable.solid_shape); //builder.Window.SetBackgroundDrawableResource(Resource.Color.windowBackground); var button = builder.FindViewById <Button>(Android.Resource.Id.Button3); button.SetTextSize(Android.Util.ComplexUnitType.Dip, 20); button.SetTextColor(Color.Rgb(46, 167, 243));// light_blue button.LayoutParameters = new LinearLayout.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.WrapContent); button.SetBackgroundResource(Resource.Drawable.single_border); button.Gravity = Android.Views.GravityFlags.CenterHorizontal; }
protected override void Init() { base.Init(); if (_localizationProvider == null) _localizationProvider = new LocalizationProvider(); List<LanguageInfo> languageInfos = _localizationProvider.SelectAll(ErrorList); if (languageInfos != null && languageInfos.Count > 0) { object[,] param = new object[2, 3]; param[0, 0] = "@PageIndex"; param[0, 1] = PageIndex; param[1, 0] = "@PageSize"; param[1, 1] = PageSize; rptList.HeaderTemplate = new TranslationTemplate(languageInfos.ToArray(), ListItemType.Header); rptList.ItemTemplate = new TranslationTemplate(languageInfos.ToArray(), ListItemType.Item); rptList.AlternatingItemTemplate = new TranslationTemplate(languageInfos.ToArray(), ListItemType.AlternatingItem); rptList.QueryType = QueryType.StoredProcedure; rptList.QueryParameters = param; rptList.QueryName = "[dbo].[freb_Translation_SelectByPaging]"; rptList.DataBind(); } }
protected virtual OrderShippingMethodViewModel GetShippingMethodViewModel(Shipment shipment, CreateOrderDetailViewModelParam param) { if (param.Order.Cart.Shipments == null) { throw new ArgumentNullException("param.Order.Cart.Shipments"); } if (shipment == null) { return(new OrderShippingMethodViewModel()); } var shippingMethodVm = ViewModelMapper.MapTo <OrderShippingMethodViewModel>(shipment.FulfillmentMethod, param.CultureInfo); if (param.Order.Cart.FulfillmentCost == 0) { var freeLabel = LocalizationProvider.GetLocalizedString(new GetLocalizedParam { Category = "ShoppingCart", Key = "L_Free", CultureInfo = param.CultureInfo }); shippingMethodVm.Cost = freeLabel; } shippingMethodVm.Taxable = shipment.IsShippingTaxable(); return(shippingMethodVm); }
public async Task DoChangeLocale() { Semdelion.Core.User.Settings.Locale = LocalizationProvider.CurrentCultureInfo.Name == "ru-RU" ? "en-US" : "ru-RU"; await LocalizationProvider.ChangeLocale(new CultureInfo(Semdelion.Core.User.Settings.Locale)); await RaiseAllPropertiesChanged(); }
public void WriteBuiltInStylesheetsToAppData(bool overwriteExisting = false) { System.Collections.Generic.List <string> builtInStylesheets = StyleSheetProvider.GetBuiltInStylesheets(); foreach (string current in builtInStylesheets) { string str = current.Replace("MarkdownPad2.Stylesheets.", ""); if (!overwriteExisting && System.IO.File.Exists(StyleSheetProvider.StylesheetDirectory + str)) { StyleSheetProvider._logger.Trace("Style already exists in AppData, skipping: " + str); } else { System.Reflection.Assembly executingAssembly = System.Reflection.Assembly.GetExecutingAssembly(); using (System.IO.StreamReader streamReader = new System.IO.StreamReader(executingAssembly.GetManifestResourceStream(current))) { StyleSheetProvider._logger.Trace("Writing file to " + str); try { if (!System.IO.Directory.Exists(StyleSheetProvider.StylesheetDirectory)) { StyleSheetProvider._logger.Trace("Stylesheet directory doesn't exist, creating it"); System.IO.Directory.CreateDirectory(StyleSheetProvider.StylesheetDirectory); } System.IO.File.WriteAllText(StyleSheetProvider.StylesheetDirectory + str, streamReader.ReadToEnd()); } catch (System.Exception exception) { StyleSheetProvider._logger.ErrorException("Error writing stylesheet to AppData: " + current, exception); MessageBoxHelper.ShowErrorMessageBox(LocalizationProvider.GetLocalizedString("Error_WritingStylesheetToFileMessage", true, "MarkdownPadStrings") + str, LocalizationProvider.GetLocalizedString("Error_WritingStylesheetToFileTitle", false, "MarkdownPadStrings"), exception, ""); } } } } }
/// <summary>Translates the UI using the specified localization provider.</summary> /// <param name="localizationProvider">The localization provider to use for translation.</param> public void Translate(LocalizationProvider localizationProvider) { foreach (IViewItem item in viewItems) { item.Translate(localizationProvider); } }
public async void Save() { try { var sett = new TorrentSettings { DownloadLimited = MXD_Bool, UploadLimited = MXU_Bool, DownloadLimit = MaxDownSp, UploadLimit = MaxUpSp, SeedRatioLimit = SeedRation, SeedIdleLimit = StopSeed, IDs = tors, PeerLimit = PeerLimit, TrackerAdd = toAdd?.Count <= 0 ? null : toAdd?.ToArray(), TrackerRemove = toRm?.Count <= 0 ? null : toRm?.ToArray(), }; var resp = await _transmissionClient.TorrentSetAsync(sett, new CancellationToken()); if (resp.Success) { await TryCloseAsync(); } else { await MessageBoxViewModel.ShowDialog(LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.TorretPropertiesSetError)), _manager); } } finally { IsBusy = Visibility.Collapsed; } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); // Clipboard manager _clipboardMonitor = new ClipboardMonitor(); _clipboardMonitor.ClipboardContentChanged += OnClipboardContentChanged; _hWnd = new WindowInteropHelper(this).Handle; // Notification menu items (when minimized) _exitMenuItem = new System.Windows.Forms.MenuItem(LocalizationProvider.GetLocalizedValue <string>(nameof(Properties.Resources.Trayicon_ExitLabel))); _settingsMenuItem = new System.Windows.Forms.MenuItem(LocalizationProvider.GetLocalizedValue <string>(nameof(Properties.Resources.Trayicon_SettingsLabel))); _compactDbMenuItem = new System.Windows.Forms.MenuItem(LocalizationProvider.GetLocalizedValue <string>(nameof(Properties.Resources.Trayicon_CompactDbLabel))); _toggleClipboardMonitorMenuItem = new System.Windows.Forms.MenuItem(LocalizationProvider.GetLocalizedValue <string>(nameof(Properties.Resources.Trayicon_DisconnectFromClipboardLabel))); _exitMenuItem.Click += OnExitMenuItemClick; _settingsMenuItem.Click += OnSettingsMenuItemClick; _compactDbMenuItem.Click += OnCompactDbMenuItemClick; _toggleClipboardMonitorMenuItem.Click += OnToggleClipboardMonitorMenuItemClick; _notifyIconContextMenu = new System.Windows.Forms.ContextMenu(); _notifyIconContextMenu.MenuItems.Add(_settingsMenuItem); _notifyIconContextMenu.MenuItems.Add(_compactDbMenuItem); _notifyIconContextMenu.MenuItems.Add(_toggleClipboardMonitorMenuItem); _notifyIconContextMenu.MenuItems.Add("-"); _notifyIconContextMenu.MenuItems.Add(_exitMenuItem); _notifyIcon = new System.Windows.Forms.NotifyIcon(); _notifyIcon.Icon = new System.Drawing.Icon(@"../../Resources/Clipboard.ico"); _notifyIcon.MouseClick += OnNotifyIconClick; _notifyIcon.ContextMenu = _notifyIconContextMenu; _notifyIcon.Visible = true; }
public ReloadCultureTests() { _data = new Dictionary <CultureInfo, List <LocalString> >() { { new CultureInfo("en"), new List <LocalString>() { new LocalString("TestTranslations.General:Test1", "Test1en") } }, { new CultureInfo("fr"), new List <LocalString>() { new LocalString("TestTranslations.General:Test1", "Test1fr") } } }; _localizationStorageStorageProvider = new InMemoryLocalizationStorageProvider("1", _data); _provider = new LocalizationProvider(typeof(TestTranslations).Assembly, _localizationStorageStorageProvider) { CurrentCultureFactory = () => new CultureInfo("en") }; }
/// <summary>Translates this view item using the specified localization provider.</summary> /// <param name="localizationProvider">The localization provider to use for translation.</param> /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception> public override void Translate(LocalizationProvider localizationProvider) { if (localizationProvider == null) { throw new ArgumentNullException(nameof(localizationProvider)); } UIComponent panel = UIComponent.parent; if (panel == null) { return; } panel.tooltip = localizationProvider.Translate(UIComponent.name + TranslationKeys.Tooltip); UILabel label = panel.Find <UILabel>(LabelName); if (label != null) { label.text = localizationProvider.Translate(UIComponent.name); } currentCulture = localizationProvider.CurrentCulture; UpdateValueLabel(Value); }
protected virtual SearchPageViewModel GetNextPage(CreateSearchPaginationParam <TParam> param) { var searchCriteria = param.SearchParameters.Criteria; var nextPage = new SearchPageViewModel { DisplayName = LocalizationProvider .GetLocalizedString(new GetLocalizedParam { Category = "List-Search", Key = "B_Next", CultureInfo = searchCriteria.CultureInfo }) }; if (param.CurrentPageIndex < param.TotalNumberOfPages) { searchCriteria.Page = param.CurrentPageIndex + 1; nextPage.Url = GenerateUrl(param); } else { nextPage.IsCurrentPage = true; } return(nextPage); }
protected virtual SearchPageViewModel GetPreviousPage(CreateSearchPaginationParam <TParam> param) { var searchCriteria = param.SearchParameters.Criteria; var previousPage = new SearchPageViewModel { DisplayName = LocalizationProvider .GetLocalizedString(new GetLocalizedParam { Category = "List-Search", Key = "B_Previous", CultureInfo = searchCriteria.CultureInfo }) }; if (param.CurrentPageIndex > 1) { searchCriteria.Page = param.CurrentPageIndex - 1; previousPage.Url = GenerateUrl(param); } else { previousPage.IsCurrentPage = true; } return(previousPage); }
public bool VerifyLicense(string licenseKey, string email) { this.LicenseProcessed = true; return(true); bool result; try { } catch (System.FormatException exception) { LicenseEngine._logger.ErrorException("Bad license format", exception); MessageBoxHelper.ShowWarningMessageBox(LocalizationProvider.GetLocalizedString("License_BadFormat", false, "MarkdownPadStrings") + StringUtilities.GetNewLines(2) + LocalizationProvider.GetLocalizedString("License_PleaseVerify", false, "MarkdownPadStrings"), LocalizationProvider.GetLocalizedString("License_ErrorTitle", false, "MarkdownPadStrings")); result = false; } catch (OpenSslException exception2) { LicenseEngine._logger.ErrorException("Error decrypting license", exception2); MessageBoxHelper.ShowWarningMessageBox(LocalizationProvider.GetLocalizedString("License_ErrorMessage", false, "MarkdownPadStrings") + StringUtilities.GetNewLines(2) + LocalizationProvider.GetLocalizedString("License_PleaseVerify", false, "MarkdownPadStrings"), LocalizationProvider.GetLocalizedString("License_ErrorTitle", false, "MarkdownPadStrings")); result = false; } catch (System.Exception exception3) { LicenseEngine._logger.ErrorException("Error processing license: " + licenseKey, exception3); MessageBoxHelper.ShowErrorMessageBox(LocalizationProvider.GetLocalizedString("License_ErrorMessage", false, "MarkdownPadStrings") + StringUtilities.GetNewLines(2) + LocalizationProvider.GetLocalizedString("License_PleaseVerify", false, "MarkdownPadStrings"), LocalizationProvider.GetLocalizedString("License_ErrorTitle", false, "MarkdownPadStrings"), exception3, ""); result = false; } return(result); }
public void SaveDocument(string fileName) { System.Text.UTF8Encoding encoding = this._settings.IO_ExportTextWithBom ? new System.Text.UTF8Encoding(true) : new System.Text.UTF8Encoding(false); using (System.IO.TextWriter textWriter = new System.IO.StreamWriter(fileName, false, encoding)) { string text = this.Editor.Text; if (this._settings.IO_UseUnixStyleEol) { textWriter.NewLine = "\n"; text = text.ConvertTextToUnixEol(); } else { textWriter.NewLine = "\r\n"; } try { textWriter.Write(text); this.Filename = fileName; this.OnPropertyChanged("Filename"); this.FileLastModified = System.DateTime.Now; MarkdownEditor._logger.Trace("Saved file: " + fileName); this.OriginalDocument = this.Editor.Text; this.OnPropertyChanged("HasChanges"); this.StatusMessage = string.Format(LocalizationProvider.GetLocalizedString("FileSavedNotification", false, "MarkdownPadStrings"), System.IO.Path.GetFileName(fileName), System.DateTime.Now); } catch (System.Exception exception) { MarkdownEditor._logger.ErrorException("Exception while saving text", exception); throw; } } }
public async void Test() { IsTesting = true; string pswd = null; if (SelectedServer.AskForPassword) { var dialog = new DialogBoxViewModel(LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.DialogBox_EnterPWD)), string.Empty, true); var res = await manager.ShowDialogAsync(dialog); if (res == false) { IsTesting = false; return; } pswd = dialog.Value.ToString(); } var result = await TesConnection(pswd); ConnectStatusResult = result ? LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.CM_TestConnectionGood)) : LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.CM_TestConnectionBad)); ConnectStatusColor = result ? new SolidColorBrush { Color = Colors.Green } : new SolidColorBrush { Color = Colors.Red }; }
private void ApplyConfig() { try { if (_view != null) { _view.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; _view.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth; //_view.CategoriesColumn.Width = new GridLength(ConfigService.Instanse.CategoriesWidth); _view.Width = ConfigService.Instanse.MainWindowWidth; _view.Height = ConfigService.Instanse.MainWindowHeight; _view.WindowState = ConfigService.Instanse.MainWindowState; RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; IsShowMoreInfo = ConfigService.Instanse.MoreInfoShow; } else { throw new Exception($" Filed '{nameof(_view)}' is null"); } } catch (Exception ex) { Log.Error(ex); Crashes.TrackError(ex); MessageBoxViewModel.ShowDialog(LocalizationProvider.GetLocalizedValue(nameof(Strings.ConfigApllyError)), manager); } }
private async Task <bool> InitPlugin() { try { var localization = new LocalizationProvider(_logger); _factories = await Dockerize.Init <DriverFactory>(_pluginDir, _logger, localization); var templateFactory = _serviceProvider.GetRequiredService <INodeTemplateFactory>(); foreach (var factory in _factories) { _logger.LogDebug($"Loaded {factory}"); _logger.LogDebug($"Init templates for {factory}"); Dockerize.InitDriverFactory(factory, templateFactory); } return(true); } catch (Exception e) { _logger.LogError(e, "Could not init plugins.."); } return(false); }
public void RequestTranslationForLanguageInsideFallbackList_NoTranslation_NextFallbackLanguageShouldBeUsed() { var resources = new List <LocalizationResource> { new LocalizationResource("DbLocalizationProvider.Tests.JsonConverterTests.SomeResourceClass.PropertyInFrenchAndEnglish", false) { Translations = new LocalizationResourceTranslationCollection(false) { new LocalizationResourceTranslation { Language = "fr", Value = "FR" }, new LocalizationResourceTranslation { Language = "en", Value = "EN" }, new LocalizationResourceTranslation { Language = "", Value = "INVARIANT" } } }, new LocalizationResource("DbLocalizationProvider.Tests.JsonConverterTests.SomeResourceClass.PropertyOnlyInInvariant", false) { Translations = new LocalizationResourceTranslationCollection(false) { new LocalizationResourceTranslation { Language = "", Value = "INVARIANT" } } } }; var keyBuilder = new ResourceKeyBuilder(new ScanState()); var ctx = new ConfigurationContext(); ctx.TypeFactory.ForQuery <GetAllResources.Query>().SetHandler(() => new GetAllResourcesUnitTestHandler(resources)); ctx.FallbackLanguages.Try( new List <CultureInfo> { new CultureInfo("fr"), new CultureInfo("en-GB"), new CultureInfo("en"), CultureInfo.InvariantCulture }); var sut = new LocalizationProvider(keyBuilder, new ExpressionHelper(keyBuilder), ctx.FallbackList, new QueryExecutor(ctx.TypeFactory)); var result = sut.Translate <SomeResourceClass>(new CultureInfo("en-GB")); Assert.NotNull(result); Assert.Equal("EN", result.PropertyInFrenchAndEnglish); // request for last language in the list - invariant should be returned result = sut.Translate <SomeResourceClass>(new CultureInfo("en")); Assert.Equal("INVARIANT", result.PropertyOnlyInInvariant); }
/// <summary> /// Gets a resources list from specified localization provider /// </summary> /// <param name="provider"></param> /// <param name="rootClassName"> </param> /// <returns></returns> private List <Resource> GetResourcesList(LocalizationProvider provider, string rootClassName) { var resourceList = new List <Resource>(); var keyHandler = new ResourceKeyHandler(); foreach (CultureInfo culture in provider.AvailableLanguages) { foreach (ResourceItem resource in provider.GetAllStrings("", new string[] { }, culture)) { var normalized = this.ProcessNormalizedKeys(keyHandler.NormalizeKey(resource.Key), rootClassName); if (normalized.Count == 0) { continue; } var resourceClass = new Resource { Language = culture.ToString(), Key = resource.Key, Value = resource.Value, NormalizedKey = normalized, Level = normalized.Count }; resourceList.Add(resourceClass); } } return(resourceList); }
public DataAnnotationsTests() { var state = new ScanState(); var keyBuilder = new ResourceKeyBuilder(state); var oldKeyBuilder = new OldResourceKeyBuilder(keyBuilder); var ctx = new ConfigurationContext(); ctx.TypeFactory .ForQuery <DetermineDefaultCulture.Query>().SetHandler <DetermineDefaultCulture.Handler>() .ForQuery <GetTranslation.Query>().SetHandler <GetTranslationReturnResourceKeyHandler>(); var queryExecutor = new QueryExecutor(ctx); var translationBuilder = new DiscoveredTranslationBuilder(queryExecutor); _sut = new TypeDiscoveryHelper(new List <IResourceTypeScanner> { new LocalizedModelTypeScanner(keyBuilder, oldKeyBuilder, state, ctx, translationBuilder), new LocalizedResourceTypeScanner(keyBuilder, oldKeyBuilder, state, ctx, translationBuilder), new LocalizedEnumTypeScanner(keyBuilder, translationBuilder), new LocalizedForeignResourceTypeScanner(keyBuilder, oldKeyBuilder, state, ctx, translationBuilder) }, ctx); var expressHelper = new ExpressionHelper(keyBuilder); _provider = new LocalizationProvider(keyBuilder, expressHelper, new FallbackLanguagesCollection(), queryExecutor); }
/// <summary> /// Parse Transmission server statistic. /// </summary> private void ParseStats() { Thread.CurrentThread.CurrentUICulture = LocalizationManager.CurrentCulture; Thread.CurrentThread.CurrentCulture = LocalizationManager.CurrentCulture; IsConnectedStatusText = $"Transmission {_sessionInfo?.Version} (RPC:{_sessionInfo?.RpcVersion}) " + $" {LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.Stats_Uploaded))} {Utils.GetSizeString(_stats.CumulativeStats.UploadedBytes)}" + $" {LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.Stats_Downloaded))} {Utils.GetSizeString(_stats.CumulativeStats.DownloadedBytes)}" + $" {LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.Stats_ActiveTime))} {TimeSpan.FromSeconds(_stats.CurrentStats.SecondsActive).ToPrettyFormat()}"; var dSpeedText = BytesToUserFriendlySpeed.GetSizeString(_stats.DownloadSpeed); var uSpeedText = BytesToUserFriendlySpeed.GetSizeString(_stats.UploadSpeed); var dSpeed = string.IsNullOrEmpty(dSpeedText) ? "0 b/s" : dSpeedText; var uSpeed = string.IsNullOrEmpty(uSpeedText) ? "0 b/s" : uSpeedText; var altUp = _settings?.AlternativeSpeedEnabled == true ? $" [{BytesToUserFriendlySpeed.GetSizeString(_settings.AlternativeSpeedUp * 1000)}]" : string.Empty; var altD = _settings?.AlternativeSpeedEnabled == true ? $" [{BytesToUserFriendlySpeed.GetSizeString(_settings.AlternativeSpeedDown * 1000)}]" : string.Empty; DownloadSpeed = $"D: {dSpeed}{altD}"; UploadSpeed = $"U: {uSpeed}{altUp}"; }
public virtual List <AdditionalFeeSummaryViewModel> GetShipmentAdditionalFeeSummary(IEnumerable <ShipmentAdditionalFeeViewModel> shipmentAdditionalFeeViewModels, CultureInfo cultureInfo) { var shipmentAdditionalFeeSummaryList = new List <AdditionalFeeSummaryViewModel>(); if (shipmentAdditionalFeeViewModels == null) { return(shipmentAdditionalFeeSummaryList); } var additionalFeeViewModels = shipmentAdditionalFeeViewModels as IList <ShipmentAdditionalFeeViewModel> ?? shipmentAdditionalFeeViewModels.ToList(); var taxableAdditionalFeesGroups = additionalFeeViewModels.Where(a => a.Taxable).GroupBy(a => a.DisplayName); shipmentAdditionalFeeSummaryList .AddRange(taxableAdditionalFeesGroups.Select(additionalFeesGroup => new AdditionalFeeSummaryViewModel { GroupName = additionalFeesGroup.Key, TotalAmount = LocalizationProvider.FormatPrice(additionalFeesGroup.Sum(a => a.Amount), cultureInfo), Taxable = true })); var nonTaxableAdditionalFeesGroups = additionalFeeViewModels.Where(a => !a.Taxable).GroupBy(a => a.DisplayName); shipmentAdditionalFeeSummaryList .AddRange(nonTaxableAdditionalFeesGroups.Select(additionalFeesGroup => new AdditionalFeeSummaryViewModel { GroupName = additionalFeesGroup.Key, TotalAmount = LocalizationProvider.FormatPrice(additionalFeesGroup.Sum(a => a.Amount), cultureInfo), Taxable = false })); return(shipmentAdditionalFeeSummaryList); }
public void PrintMarkdown() { PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() != true) { return; } FlowDocument flowDocument = this.CreateFlowDocument(this.Editor); flowDocument.PageHeight = printDialog.PrintableAreaHeight; flowDocument.PageWidth = printDialog.PrintableAreaWidth; flowDocument.PagePadding = new Thickness(72.0); flowDocument.ColumnGap = 0.0; flowDocument.ColumnWidth = flowDocument.PageWidth - flowDocument.ColumnGap - flowDocument.PagePadding.Left - flowDocument.PagePadding.Right; IDocumentPaginatorSource documentPaginatorSource = flowDocument; try { printDialog.PrintDocument(documentPaginatorSource.DocumentPaginator, "MarkdownPad Document"); } catch (System.Exception exception) { MarkdownEditor._logger.ErrorException("Exception while attempting to print Markdown plain text", exception); MessageBoxHelper.ShowErrorMessageBox(LocalizationProvider.GetLocalizedString("Error_PrintMarkdownMessage", false, "MarkdownPadStrings"), LocalizationProvider.GetLocalizedString("Error_PrintMarkdownTitle", false, "MarkdownPadStrings"), exception, ""); } }
internal static bool ValidateLicense(string featureDescription, Window owner) { Settings @default = Settings.Default; LicenseEngine licenseEngine = new LicenseEngine(); bool flag = licenseEngine.VerifyLicense(@default.App_LicenseKey, @default.App_LicenseEmail); if (!flag) { string localizedString = LocalizationProvider.GetLocalizedString("Pro_OneOfManyFeatures", false, "MarkdownPadStrings"); string localizedString2 = LocalizationProvider.GetLocalizedString("Pro_LearnMore", false, "MarkdownPadStrings"); string localizedString3 = LocalizationProvider.GetLocalizedString("Pro_OnlyAvailableInPro", false, "MarkdownPadStrings"); MessageBoxResult messageBoxResult = CustomMessageBox.ShowYesNo(string.Concat(new string[] { featureDescription, " ", localizedString, StringUtilities.GetNewLines(2), localizedString2 }), localizedString3, LocalizationProvider.GetLocalizedString("Yes", false, "MarkdownPadStrings"), LocalizationProvider.GetLocalizedString("No", false, "MarkdownPadStrings"), MessageBoxImage.Asterisk); if (messageBoxResult == MessageBoxResult.Yes) { UpgradeProWindow upgradeProWindow = new UpgradeProWindow { Owner = owner }; upgradeProWindow.ShowDialog(); } } return(flag); }
public void FallbackTranslationTests() { ConfigurationContext.Setup(_ => { // try "sv" -> "no" -> "en" _.FallbackCultures .Try(new CultureInfo("sv")) .Then(new CultureInfo("no")) .Then(new CultureInfo("en")); // for rare cases - configure language specific fallback _.FallbackCultures .When(new CultureInfo("fr-BE")) .Try(new CultureInfo("fr")) .Then(new CultureInfo("en")); _.TypeFactory.ForQuery <GetTranslation.Query>().SetHandler(() => new FallbacksTestsTranslationHandler(_.FallbackList)); }); var sut = new LocalizationProvider(); Assert.Equal("Some Swedish translation", sut.GetString("Resource.With.Swedish.Translation", new CultureInfo("sv"))); Assert.Equal("Some English translation", sut.GetString("Resource.With.English.Translation", new CultureInfo("sv"))); Assert.Equal("Some Norwegian translation", sut.GetString("Resource.With.Norwegian.Translation", new CultureInfo("sv"))); Assert.Equal("Some Norwegian translation", sut.GetString("Resource.With.Norwegian.And.English.Translation", new CultureInfo("sv"))); }
protected override List <ErrorViewModel> GetLocalizedErrors(HttpActionExecutedContext context) { var aggregateException = context.Exception as AggregateException; if (aggregateException == null) { return(new List <ErrorViewModel>()); } var innerExceptions = aggregateException.Flatten().InnerExceptions; if (!innerExceptions.All(e => e is ComposerException)) { return(new List <ErrorViewModel>()); } var query = from exception in innerExceptions.OfType <ComposerException>() from error in exception.Errors let localizedErrorMessage = LocalizationProvider.GetLocalizedErrorMessage(error.ErrorCode, Context.CultureInfo) select new ErrorViewModel { ErrorCode = error.ErrorCode, ErrorMessage = error.ErrorMessage, LocalizedErrorMessage = localizedErrorMessage }; return(query.ToList()); }
public static void MoveFile(string file, string destination) { try { if (System.IO.File.Exists(destination)) { FileUtils._logger.Info("Overwriting existing file: " + destination); System.IO.File.Delete(destination); } System.IO.File.Move(file, destination); } catch (System.Exception exception) { FileUtils._logger.ErrorException(string.Format("Unable to move file from source ({0}) to destination ({1})", file, destination), exception); MessageBoxHelper.ShowErrorMessageBox(string.Concat(new string[] { LocalizationProvider.GetLocalizedString("Error_MovingFile_Message", false, "MarkdownPadStrings"), StringUtilities.GetNewLines(2), LocalizationProvider.GetLocalizedString("Error_MovingFileSource", true, "MarkdownPadStrings"), file, StringUtilities.GetNewLines(2), LocalizationProvider.GetLocalizedString("Error_MovingFileDestination", true, "MarkdownPadStrings"), destination }), LocalizationProvider.GetLocalizedString("Error_MovingFile_Title", false, "MarkdownPadStrings"), exception, ""); } }
public Task HandleAsync(LocalizationCultureChangesMessage message, CancellationToken cancellationToken) { _isChangingLang = true; try { foreach (var item in Languages) { item.IsChecked = Equals((CultureInfo)item.Tag, message.Culture); } if (IsConnected && _stats != null) { IsConnectedStatusText = $"Transmission {_sessionInfo?.Version} (RPC:{_sessionInfo?.RpcVersion}) " + $" {LocalizationProvider.GetLocalizedValue(nameof(Strings.Stats_Uploaded))} {Utils.GetSizeString(_stats.CumulativeStats.UploadedBytes)}" + $" {LocalizationProvider.GetLocalizedValue(nameof(Strings.Stats_Downloaded))} {Utils.GetSizeString(_stats.CumulativeStats.DownloadedBytes)}" + $" {LocalizationProvider.GetLocalizedValue(nameof(Strings.Stats_ActiveTime))} {TimeSpan.FromSeconds(_stats.CurrentStats.SecondsActive).ToPrettyFormat()}"; } var ind = SelectedCategoryIndex; SelectedCategoryIndex = ind; } finally { _isChangingLang = false; } return(Task.CompletedTask); }
public MultipleProviderTests() { var storageProvider = new InMemoryLocalizationStorageProvider("1", new Dictionary <CultureInfo, List <LocalString> >() { { new CultureInfo("fr"), new List <LocalString>() { new LocalString("TestTranslations.General:Test1", "Test1fr") } }, { new CultureInfo("en"), new List <LocalString>() { new LocalString("TestTranslations.General:Test1", "Test1en") } } }); var storageProvider2 = new InMemoryLocalizationStorageProvider("2", new Dictionary <CultureInfo, List <LocalString> >() { { new CultureInfo("fr"), new List <LocalString>() { new LocalString("TestTranslations.General:Test1", "Test1fr2") } } }); _provider = new LocalizationProvider(typeof(TestTranslations).GetTypeInfo().Assembly, storageProvider, storageProvider2) { CurrentCultureFactory = () => new CultureInfo("en") }; }
protected override void Init() { base.Init(); if (_localizationProvider == null) _localizationProvider = new LocalizationProvider(); if (_siteProvider == null) _siteProvider = new SiteProvider(); if (IsEdit) { Title = "Edit Language | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "Edit"; } else { Title = "New Language | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "New"; } }
/// <summary> /// Gets a resources list from specified localization provider /// </summary> /// <param name="provider"></param> /// <param name="rootClassName"> </param> /// <returns></returns> private List<Resource> GetResourcesList(LocalizationProvider provider, string rootClassName) { var resourceList = new List<Resource>(); var keyHandler = new ResourceKeyHandler(); foreach (CultureInfo culture in provider.AvailableLanguages) { foreach (ResourceItem resource in provider.GetAllStrings("", new string[] { }, culture)) { var normalized = ProcessNormalizedKeys(keyHandler.NormalizeKey(resource.Key), rootClassName); if (normalized.Count == 0) { continue; } var resourceClass = new Resource { Language = culture.ToString(), Key = resource.Key, Value = resource.Value, NormalizedKey = normalized, Level = normalized.Count }; resourceList.Add(resourceClass); } } return resourceList; }
protected override void Init() { base.Init(); if (_articleProvider == null) _articleProvider = new ArticleProvider(); if (_localizationProvider == null) _localizationProvider = new LocalizationProvider(); if (_layoutProvider == null) _layoutProvider = new LayoutProvider(); if (_pageProvider == null) _pageProvider = new PageProvider(); if (_blockProvider == null) _blockProvider = new BlockProvider(); if (IsEdit) { Title = "Edit Article | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "Edit Article"; } else { Title = "New Article | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "New Article"; } FillLanguages(); FillPages(); FillLayouts(); }
protected override void Init() { base.Init(); if (_layoutProvider == null) _layoutProvider = new LayoutProvider(); if (_layoutWebPartZoneProvider == null) _layoutWebPartZoneProvider = new LayoutWebPartZoneProvider(); if (_webPartProvider == null) _webPartProvider = new WebPartProvider(); if (_blockProvider == null) _blockProvider = new BlockProvider(); if (_layoutNBlockProvider == null) _layoutNBlockProvider = new LayoutNBlockProvider(); if (_localizationProvider == null) _localizationProvider = new LocalizationProvider(); if (IsEdit) { Title = "Edit Block | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "Edit Block"; } else { Title = "New Block | " + CoreSettings.CurrentSite.Name; ltlTitle.Text = "New Block"; } FillLanguages(); }
/// <summary> /// Uns the load provider. /// </summary> /// <returns> /// [false] if the provider has been unloaded, as it's not initialized anymore. /// </returns> private bool UnLoadProvider(LocalizationProvider localizationProvider) { if (this.LocalizationService == null) { return false; } if (localizationProvider != null) { // If found, remove it. this.LocalizationService.Providers.Remove(localizationProvider); } return false; }
protected override void Init() { base.Init(); if (_localizationProvider == null) _localizationProvider = new LocalizationProvider(); }