Пример #1
0
        public override void LoadSettings()
        {
            base.SaveSettings();

            cboLanguage.Items.Clear();
            cboLanguage.Items.Add(Language.strLanguageDefault);

            foreach (var nativeName in SupportedCultures.CultureNativeNames)
            {
                cboLanguage.Items.Add(nativeName);
            }
            if (!string.IsNullOrEmpty(mRemoteNG.Settings.Default.OverrideUICulture) &&
                SupportedCultures.IsNameSupported(mRemoteNG.Settings.Default.OverrideUICulture))
            {
                cboLanguage.SelectedItem = SupportedCultures.get_CultureNativeName(mRemoteNG.Settings.Default.OverrideUICulture);
            }
            if (cboLanguage.SelectedIndex == -1)
            {
                cboLanguage.SelectedIndex = 0;
            }

            chkShowDescriptionTooltipsInTree.Checked      = mRemoteNG.Settings.Default.ShowDescriptionTooltipsInTree;
            chkShowFullConnectionsFilePathInTitle.Checked = mRemoteNG.Settings.Default.ShowCompleteConsPathInTitle;
            chkShowSystemTrayIcon.Checked   = mRemoteNG.Settings.Default.ShowSystemTrayIcon;
            chkMinimizeToSystemTray.Checked = mRemoteNG.Settings.Default.MinimizeToTray;
        }
Пример #2
0
        public string GetText(string resourceName, string uiCultureTab = null, params Object[] list)
        {
            var rc = "[not found]";

            try
            {
                if (SupportedCultures != null)
                {
                    if (_rm == null)
                    {
                        var baseName = GetResourcesAsm().GetName().Name + ".Properties.Resources";
                        _rm = new ResourceManager(baseName, GetResourcesAsm());
                    }

                    var cookies = new MxCookies(HttpContextAccessor);
                    if (SupportedCultures.IsSupported(uiCultureTab) == false)
                    {
                        uiCultureTab = SupportedCultures.GetUiCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
                    }
                    var uiCultureInfo = SupportedCultures.GetCultureInfo(uiCultureTab);
                    if (uiCultureInfo != null)
                    {
                        var res = _rm?.GetString(resourceName ?? "NotFound", uiCultureInfo) ?? "[Not Found]";
                        rc = string.Format(uiCultureInfo, res, list);
                    }
                }
            }
            catch (Exception e)
            {
                // ReSharper disable once UnusedVariable
                var msg = e.Message;
                //ignore
            }
            return(rc);
        }
        /// <summary>
        /// Processes the response to the SupportedCultures command.
        /// </summary>
        /// <param name="supportedCulturesResponse">Command response data.</param>
        private void ProcessSupportedCulturesResponse(XElement supportedCulturesResponse)
        {
            //Expected response
            //<SupportedCultures>
            //  <Culture Key="..." Name="..."/>
            //  ...
            //</SupportedCultures>

            using (SupportedCultures.AcquireLock())
            {
                SupportedCultures.Clear();

                foreach (var languageElement in supportedCulturesResponse.Elements("Culture"))
                {
                    var key  = languageElement.Attribute("Key").Value;
                    var name = languageElement.Attribute("Name").Value;

                    SupportedCultures.Add(new LanguageElement(key, name));
                }

                if (SupportedCultures.Count > 0)
                {
                    SelectedLanguage = SupportedCultures[0];
                }
            }
        }
    /// <summary>
    /// Returns WHERE condition for given site.
    /// </summary>
    private string GetWhereConditionInternal()
    {
        int    siteId = (SiteID > 0) ? SiteID : SiteContext.CurrentSiteID;
        string retval = string.Format("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = {0})", siteId);

        if (!string.IsNullOrEmpty(AdditionalWhereCondition))
        {
            retval = SqlHelper.AddWhereCondition(retval, AdditionalWhereCondition, "AND");
        }

        // Add supported cultures
        if (!String.IsNullOrEmpty(SupportedCultures))
        {
            StringBuilder sb = new StringBuilder(retval);

            sb.Append(" AND CultureCode IN (");

            List <string> suppCultures = SupportedCultures.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();

            sb.Append(String.Join(",", suppCultures.Select(t => "'" + SqlHelper.GetSafeQueryString(t) + "'")));

            sb.Append(")");

            retval = sb.ToString();
        }

        return(retval);
    }
Пример #5
0
        /// <summary>
        /// Initializer.
        /// </summary>
        static CultureResources()
        {
            if (!BFoundInstalledCultures)
            {
                foreach (var dir in Directory.GetDirectories(System.Windows.Forms.Application.StartupPath))
                {
                    try
                    {
                        var dirinfo  = new DirectoryInfo(dir);
                        var tCulture = CultureInfo.GetCultureInfo(dirinfo.Name);

                        if (dirinfo.GetFiles(
                                Path.GetFileNameWithoutExtension(System.Windows.Forms.Application.ExecutablePath) +
                                ".resources.dll").Length <= 0)
                        {
                            continue;
                        }

                        SupportedCulturesFullNames.Add(tCulture.NativeName);
                        SupportedCultures.Add(tCulture);
                    }
                    catch (ArgumentException)
                    {
                        // ignored
                    }
                }

                SupportedCulturesFullNames.Remove(
                    SupportedCulturesFullNames.Find(x => x == Properties.Settings.Default.LanguageName));
                SupportedCulturesFullNames.Insert(0, Properties.Settings.Default.LanguageName);

                BFoundInstalledCultures = true;
            }
        }
Пример #6
0
        public SettingsViewModel(Settings settings)
        {
            _settings          = settings;
            _soundPing         = _settings.SoundPing;
            _supportedCultures = new ObservableCollection <CultureItem>();
            SupportedCultures.Add(new CultureItem(CultureInfo.InstalledUICulture, true));
            ResourceManager rm = new ResourceManager(typeof(Localization.Localization));

            CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
            foreach (CultureInfo culture in cultures)
            {
                try
                {
                    ResourceSet rs = rm.GetResourceSet(culture, true, false);
                    if (rs == null || culture.Equals(CultureInfo.InvariantCulture))
                    {
                        continue;
                    }
                    SupportedCultures.Add(new CultureItem(culture));
                }
                catch (CultureNotFoundException)
                {
                    Debug.WriteLine(culture + " is not available on the machine or is an invalid culture identifier.");
                }
            }
            CurrentCulture = SupportedCultures.Where(c => c.CultureInfo.Equals(_settings.Language.CultureInfo)).First();
        }
Пример #7
0
 private static void SetSupportedCulture()
 {
     if (mRemoteNG.Settings.Default.OverrideUICulture != "" && SupportedCultures.IsNameSupported(mRemoteNG.Settings.Default.OverrideUICulture))
     {
         Thread.CurrentThread.CurrentUICulture = new CultureInfo(mRemoteNG.Settings.Default.OverrideUICulture);
         Logger.Instance.InfoFormat("Override Culture: {0}/{1}", Thread.CurrentThread.CurrentUICulture.Name, Thread.CurrentThread.CurrentUICulture.NativeName);
     }
 }
Пример #8
0
 /// <summary>
 /// Change the current culture used in the application.
 /// If the desired culture is available all localized elements are updated.
 /// </summary>
 /// <param name="culture">Culture to change to</param>
 public static void ChangeCulture(CultureInfo culture)
 {
     if (SupportedCultures.Contains(culture))
     {
         Resources.Culture = culture;
         ResourceProvider.Refresh();
     }
 }
        public override string ToString()
        {
            List <string> cultures     = SupportedCultures?.Select(selector: s => s.EnglishName).ToList() ?? new List <string>();
            string        culturesText = cultures.Any()
                ? $" - ({ string.Join(separator: ", ", values: cultures)})"
                : " - No specific Culture";

            return($"{Name}{culturesText}");
        }
        protected MiscSettingsPageViewModelBase(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, INotificationService notificationService, IPlatformService platformService, ITrackingManager trackingManager, IPersistenceLayer persistenceLayer) : base(workbook, navigationService)
        {
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (notificationService == null)
            {
                throw new ArgumentNullException(nameof(notificationService));
            }
            if (platformService == null)
            {
                throw new ArgumentNullException(nameof(platformService));
            }
            if (trackingManager == null)
            {
                throw new ArgumentNullException(nameof(trackingManager));
            }
            if (persistenceLayer == null)
            {
                throw new ArgumentNullException(nameof(persistenceLayer));
            }

            this.messageBoxService   = messageBoxService;
            this.notificationService = notificationService;
            this.platformService     = platformService;
            this.trackingManager     = trackingManager;
            this.persistenceLayer    = persistenceLayer;

            this.languages = new List <string> {
                " "
            };
            this.languages.AddRange(SupportedCultures.Languages);

            this.clearSearchHistoryCommand   = new RelayCommand(this.ClearSearchHistoryExecute);
            this.openWelcomeScreenCommand    = new RelayCommand(this.OpenWelcomeScreenExecute);
            this.deleteAllCommand            = new RelayCommand(this.DeleteAllExecute);
            this.deleteTasksCommand          = new RelayCommand(this.DeleteTasksExecute);
            this.deleteCompletedTasksCommand = new RelayCommand(this.DeleteCompletedTasksExecute);
            this.completeTasksCommand        = new RelayCommand(this.CompleteTasksExecute);
            this.createBackupCommand         = new RelayCommand(this.CreateBackupExecute);
            this.restoreBackupCommand        = new RelayCommand(this.RestoreBackupExecute);
            this.sortFoldersCommand          = new RelayCommand(() => this.SortElements(SortType.Folders));
            this.sortSmartViewsCommands      = new RelayCommand(() => this.SortElements(SortType.SmartViews));
            this.sortContextsCommand         = new RelayCommand(() => this.SortElements(SortType.Contexts));
            this.sortTagsCommand             = new RelayCommand(() => this.SortElements(SortType.Tags));

            string language = this.Workbook.Settings.GetValue <string>(CoreSettings.OverrideLanguage);

            if (!string.IsNullOrEmpty(language))
            {
                this.selectedLanguage = SupportedCultures.GetLanguageNameFromCode(language);
                this.previousLanguage = this.selectedLanguage;
            }

            this.sendAnalytics = this.Workbook.Settings.GetValue <bool>(CoreSettings.SendAnalytics);
        }
Пример #11
0
        public static void ChangeCulture(string CultureName)
        {
            CultureInfo culture = SupportedCultures.SingleOrDefault(x => x.Name == CultureName);

            if (culture != null)
            {
                CurrentCulture = culture;
            }
        }
 private void SetSupportedCulture()
 {
     if (mRemoteNG.Settings.Default.OverrideUICulture == "" ||
         !SupportedCultures.IsNameSupported(mRemoteNG.Settings.Default.OverrideUICulture))
     {
         return;
     }
     Thread.CurrentThread.CurrentUICulture = new CultureInfo(mRemoteNG.Settings.Default.OverrideUICulture);
     _messageCollector.AddMessage(MessageClass.InformationMsg, $"Override Culture: {Thread.CurrentThread.CurrentUICulture.Name}/{Thread.CurrentThread.CurrentUICulture.NativeName}", true);
 }
Пример #13
0
        /// <summary>
        /// Checks if we have a localization for the specified language and if not falls back
        /// the CurrentCulture and CurrentUICulture to the ones defined in the default resources.
        /// It also sets the language of the root visual. This affects all converters in data bindings.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="forcedCulture">Two Letter ISO Language Name</param>
        /// <remarks>This method should be called after App.InitializeComponent() </remarks>
        public static void InitializeCulture(this Application app, SupportedCultures forcedCulture)
        {
            var forcedLanguageName = "en-US";

            if (forcedCulture == SupportedCultures.Japanese)
            {
                forcedLanguageName = "ja-JP";
            }

            app.InitializeCulture(forcedLanguageName);
        }
Пример #14
0
        protected DefaultApiLocalization AddSupportedCulture(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            SupportedCultures ??= new List <CultureInfo>();

            SupportedCultures.Add(CultureInfo.GetCultureInfo(name));

            return(this);
        }
Пример #15
0
        static void Main(string[] arguments)
        {
            SupportedCultures.SetCulture();
            // Command line switches will only be expected
            // when the first instance starts, when more app instances
            // pass args into this instance, they will not be processed
            // and we will assume they are filenames.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var app = new SingleAppInstance(arguments);

            app.Run(arguments);
        }
Пример #16
0
 /// <summary>
 /// Load last used culture from application settings.
 /// </summary>
 private static void LoadCulture()
 {
     if (IsolatedStorageSettings.ApplicationSettings.Contains("CurrentCulture"))
     {
         // Load previously saved culture from app settings
         var savedCulture = (string)IsolatedStorageSettings.ApplicationSettings["CurrentCulture"];
         CurrentCulture = SupportedCultures.SingleOrDefault(info => info.ToString() == savedCulture);
     }
     else
     {
         // Determine user's current culture setting and if it is in the supported list - use it, or fallback to default culture
         var culture =
             SupportedCultures.FirstOrDefault(info => info.TwoLetterISOLanguageName == CurrentCulture.TwoLetterISOLanguageName);
         CurrentCulture = culture ?? DefaultCulture;
     }
 }
Пример #17
0
        public Instant ParseTimeDate(string timeDate, bool withoutDaylightSaving = false, MxCultureInfo.FormatType formatType = MxCultureInfo.FormatType.DateTime, bool longFormat = false, string cultureTab = null)
        {
            var rc = ExtNodatime.InstantError;

            var cookies = new MxCookies(HttpContextAccessor);

            if (SupportedCultures.IsSupported(cultureTab) == false)
            {
                cultureTab = SupportedCultures.GetCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
            }

            if (timeDate.ParseDateTime(DateTimeZoneProviders.Tzdb[SupportedTimeZones.GetTzDbName(cultureTab)], cultureTab, withoutDaylightSaving, formatType, longFormat, out var result))
            {
                rc = result;
            }

            return(rc);
        }
Пример #18
0
        /// <inherit/>
        public void Validate()
        {
            Validator.ValidateObject(this, new ValidationContext(this), true);

            bool valid = GenericHelper.IsGenericCulture(DefaultCulture);

            SupportedCultures.ForEach(culture => {
                valid &= GenericHelper.IsGenericCulture(culture);
            });
            SupportedUiCultures?.ForEach(culture => {
                valid &= GenericHelper.IsGenericCulture(culture);
            });

            if (!valid)
            {
                throw new ValidationException("Invalid culture code in the config file");
            }
        }
Пример #19
0
        /// <summary>
        /// private list of supported CultureInfo,
        /// </summary>
        private IEnumerable <CultureInfo> GetSupportedCultures()
        {
            // if the user didn't specify manually list of supported cultures,
            // then create cultures list with reference to supported cultures defined in localization settings in startup</para>
            if (string.IsNullOrWhiteSpace(SupportedCultures))
            {
                return(_ops.Value.SupportedCultures);
            }

            //if the user will specify supported cultures manually, then this list will be created accordingly
            var cList = new List <CultureInfo>();

            foreach (var c in SupportedCultures.Split(new[] { ',', '|', ';', ' ' }, System.StringSplitOptions.RemoveEmptyEntries))
            {
                cList.Add(new CultureInfo(c));
            }

            return(cList);
        }
Пример #20
0
        public string InstantToString(Instant timeInstant, string cultureTab = null, bool withoutDaylightSaving = false, MxCultureInfo.FormatType formatType = MxCultureInfo.FormatType.DateTime, bool longFormat = false)
        {
            var rc = "[error]";

            try
            {
                var cookies = new MxCookies(HttpContextAccessor);
                if (SupportedCultures.IsSupported(cultureTab) == false)
                {
                    cultureTab = SupportedCultures.GetCultureTab(cookies.GetValue(MxSupportedCultures.CookieName));
                }

                rc = timeInstant.ToString(cultureTab, DateTimeZoneProviders.Tzdb[SupportedTimeZones.GetTzDbName(cultureTab)]);
            }
            catch (Exception)
            {
                //ignore
            }
            return(rc);
        }
Пример #21
0
        protected async Task LoadLocalizationRecords(LocalizationRecordKey key)
        {
            if (key != null)
            {
                try
                {
                    if (currentKey != null)
                    {
                        currentKey.LocalizationRecords = null;
                    }

                    currentKey = key;
                    localizationApiClient.ClearEntitiesCache();
                    var result = await localizationApiClient.GetLocalizationRecords(key);

                    currentKey.LocalizationRecords = new List <LocalizationRecord>(result);

                    LocalizationCultures.Clear();

                    LocalizationCultures.AddRange(SupportedCultures
                                                  .Where(i => !currentKey.LocalizationRecords.Any(l => l.Culture == i)));

                    if (LocalizationCultures.Count > 0)
                    {
                        newLocalizationRecord = new LocalizationRecord()
                        {
                            ContextId = currentKey.ContextId, MsgId = currentKey.MsgId, Culture = LocalizationCultures[0]
                        }
                    }
                    ;

                    viewNotifier.Show(L["One item found", Plural.From("{0} items found", result.Count())], ViewNotifierType.Success, L["Operation Successful"]);
                }
                catch (Exception ex)
                {
                    viewNotifier.Show(ex.GetBaseException().Message, ViewNotifierType.Error, L["Operation Failed"]);
                }
            }

            StateHasChanged();
        }
Пример #22
0
    /// <summary>
    /// Returns WHERE condition for given site.
    /// </summary>
    private string GetWhereConditionInternal()
    {
        // If site id is -1 return all cultures
        if (SiteID < 0)
        {
            return(string.Empty);
        }

        StringBuilder sb = new StringBuilder("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = ");

        if (SiteID > 0)
        {
            sb.Append(SiteID);
        }
        else
        {
            sb.Append(CMSContext.CurrentSiteID);
        }
        sb.Append(")");

        // Add supported cultures
        if (!String.IsNullOrEmpty(SupportedCultures))
        {
            sb.Append(" AND CultureCode IN (");
            string[] suppCultures = SupportedCultures.Split(new string[1] {
                Environment.NewLine
            }, StringSplitOptions.None);
            foreach (string s in suppCultures)
            {
                sb.Append("'");
                sb.Append(s);
                sb.Append("', ");
            }
            sb.Remove(sb.Length - 2, 2);
            sb.Append(")");
        }

        return(sb.ToString());
    }
Пример #23
0
        public bool SetCurrentCulture(string cultureTab = null, string uiCultureTab = null)
        {
            var rc = false;

            try
            {
                if (SupportedCultures.IsSupported(cultureTab))
                {
                    Thread.CurrentThread.CurrentCulture = SupportedCultures.GetCultureInfo(cultureTab);
                }
                if (SupportedCultures.IsSupported(uiCultureTab))
                {
                    Thread.CurrentThread.CurrentUICulture = SupportedCultures.GetCultureInfo(uiCultureTab);
                }
                rc = true;
            }
            catch (Exception)
            {
                //ignore
            }
            return(rc);
        }
Пример #24
0
        public override void SaveSettings()
        {
            if (cboLanguage.SelectedIndex > 0 &&
                SupportedCultures.IsNativeNameSupported(Convert.ToString(cboLanguage.SelectedItem)))
            {
                Settings.Default.OverrideUICulture =
                    SupportedCultures.get_CultureName(Convert.ToString(cboLanguage.SelectedItem));
            }
            else
            {
                Settings.Default.OverrideUICulture = string.Empty;
            }

            Settings.Default.ShowDescriptionTooltipsInTree = chkShowDescriptionTooltipsInTree.Checked;
            Settings.Default.ShowCompleteConsPathInTitle   = chkShowFullConnectionsFilePathInTitle.Checked;
            frmMain.Default.ShowFullPathInTitle            = chkShowFullConnectionsFilePathInTitle.Checked;

            Settings.Default.ShowSystemTrayIcon = chkShowSystemTrayIcon.Checked;
            if (Settings.Default.ShowSystemTrayIcon)
            {
                if (Runtime.NotificationAreaIcon == null)
                {
                    Runtime.NotificationAreaIcon = new NotificationAreaIcon();
                }
            }
            else
            {
                if (Runtime.NotificationAreaIcon != null)
                {
                    Runtime.NotificationAreaIcon.Dispose();
                    Runtime.NotificationAreaIcon = null;
                }
            }

            Settings.Default.MinimizeToTray = chkMinimizeToSystemTray.Checked;

            Settings.Default.Save();
        }
Пример #25
0
        protected async Task LoadPluralFormRules()
        {
            PluralFormRules = new List <PluralFormRule>();

            try
            {
                localizationApiClient.ClearEntitiesCache();
                var result = await localizationApiClient.GetPluralFormRules();

                PluralFormRules = new List <PluralFormRule>(result);

                LocalizationCultures.Clear();

                LocalizationCultures.AddRange(SupportedCultures
                                              .Where(i => !PluralFormRules.Any(l => l.Language == i)));

                viewNotifier.Show(L["One item found", Plural.From("{0} items found", PluralFormRules.Count)], ViewNotifierType.Success, L["Operation Successful"]);
            }
            catch (Exception ex)
            {
                viewNotifier.Show(ex.GetBaseException().Message, ViewNotifierType.Error, L["Operation Failed"]);
            }
        }
        /// <summary>
        /// Called when a property change notification is raised on this view model. This view model
        /// uses this method to monitor when the Connected property is changed. This logic could have
        /// been placed in the Connected property setter, but putting it here keeps the property setter simple.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        void ConnectionViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Connected")
            {
                LoggedOn    = false;
                LogOnResult = String.Empty;

                if (Connected)
                {
                    //We have become connected, so send a to get general information about
                    //the instrument we have connected to. These commands can be executed without
                    //first executing a Logon command.
                    SendData(new SendDataEventArgs(_versionCommandDocument.ToString(), this));
                    SendData(new SendDataEventArgs(_supportedCulturesCommandDocument.ToString(), this));
                    SendData(new SendDataEventArgs(_instrumentInfoCommandDocument.ToString(), this));
                }
                else
                {
                    //We have become disconnected, so clear out our data.
                    InstrumentVersion = String.Empty;
                    ProtocolVersion   = String.Empty;
                    SelectedLanguage  = null;
                    Options           = String.Empty;
                    Family            = string.Empty;

                    using (SupportedCultures.AcquireLock())
                    {
                        SupportedCultures.Clear();
                    }

                    using (InstrumentInfo.AcquireLock())
                    {
                        InstrumentInfo.Clear();
                    }
                }
            }
        }
Пример #27
0
 /// <summary>
 /// 获得支持多语言集合
 /// </summary>
 /// <returns></returns>
 public IList <CultureInfo> GetSupportedCultures()
 {
     // 用户设置时使用用户设置,未设置时使用内置中英文文化
     _cultures ??= new Lazy <List <CultureInfo> >(() => SupportedCultures?.Select(name => new CultureInfo(name)).ToList() ?? JsonLocalizationOptions.SupportedCultures);
     return(_cultures.Value);
 }
Пример #28
0
 /// <summary>
 /// Checks if the given culture is present in the SupportedCultures collection.
 /// </summary>
 /// <param name="culture">Reference to the culture instance being checked</param>
 /// <returns>True if the culture is supported, false otherwise.</returns>
 private static bool IsSupported(CultureInfo culture)
 {
     return(SupportedCultures.ContainsKey(culture));
 }
Пример #29
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app">Defines a class that provides the mechanisms to configure an application's request pipeline.</param>
        public void Configure(IApplicationBuilder app)
        {
            if (HostingEnvironment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.IdentityServerStoreSetup <ExtendedConfigurationDbContext>(Clients.Get(), Resources.GetIdentityResources(), Resources.GetApiResources());
            }
            else
            {
                app.UseHsts();
                app.UseHttpsRedirection();
            }
            app.UseStaticFiles(new StaticFileOptions {
                OnPrepareResponse = context => {
                    const int durationInSeconds = 60 * 60 * 24;
                    context.Context.Response.Headers[HeaderNames.CacheControl] = $"public,max-age={durationInSeconds}";
                    context.Context.Response.Headers.Append(HeaderNames.Expires, DateTime.UtcNow.AddSeconds(durationInSeconds).ToString("R", CultureInfo.InvariantCulture));
                }
            });
            app.UseCookiePolicy();
            app.UseRouting();
            app.UseIdentityServer();
            app.UseCors();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseWhen(context => !context.Request.Path.StartsWithSegments("/api"), branch => {
                if (!HostingEnvironment.IsDevelopment())
                {
                    branch.UseExceptionHandler("/error");
                }
            });
            app.UseWhen(context => context.Request.Path.StartsWithSegments("/api"), branch => {
                branch.UseProblemDetails();
            });
            app.UseRequestLocalization(new RequestLocalizationOptions {
                DefaultRequestCulture   = new RequestCulture(SupportedCultures.Default),
                RequestCultureProviders = new List <IRequestCultureProvider> {
                    new QueryStringRequestCultureProvider(),
                    new CookieRequestCultureProvider()
                },
                SupportedCultures   = SupportedCultures.Get().ToList(),
                SupportedUICultures = SupportedCultures.Get().ToList()
            });
            app.UseResponseCaching();
            app.UseSwagger();
            var enableSwagger = HostingEnvironment.IsDevelopment() || Configuration.GetValue <bool>($"{GeneralSettings.Name}:SwaggerUI");

            if (enableSwagger)
            {
                app.UseSwaggerUI(swaggerOptions => {
                    swaggerOptions.RoutePrefix = "docs";
                    swaggerOptions.SwaggerEndpoint($"/swagger/{IdentityServerApi.Scope}/swagger.json", IdentityServerApi.Scope);
                    swaggerOptions.OAuth2RedirectUrl($"{Settings.Host}/docs/oauth2-redirect.html");
                    swaggerOptions.OAuthClientId("swagger-ui");
                    swaggerOptions.OAuthAppName("Swagger UI");
                    swaggerOptions.DocExpansion(DocExpansion.None);
                });
            }
            app.UseEndpoints(endpoints => {
                endpoints.MapControllers();
            });
            if (!HostingEnvironment.IsDevelopment())
            {
                app.UseSpaStaticFiles();
                app.UseSpa(builder => {
                    builder.Options.SourcePath = "wwwroot/admin-ui";
                });
            }
        }
 public static IRuleBuilderOptions <T, string> SupportedCulture <T>(this IRuleBuilder <T, string> ruleBuilder)
 {
     return(ruleBuilder
            .Must(m => SupportedCultures.ExistsCultureByValue(m) != null)
            .WithMessage("'{PropertyName}' no valida."));
 }