logo
Tags down

shadow

Asp .Net Core Show DateTime based on localization


By : Zac St. Clair
Date : September 13 2020, 09:00 PM
it fixes the issue I'm assuming that what you're actually referring to is the HTML5 date input and how it's rendered by browsers. What you're seeing is localized, but it's localized based on the culture set on the client machine. In other words, you can't control this from the server. That's actually the way it should be. The end-user decides their own culture preferences. Additionally, the date input type doesn't support any date format but ISO (YYYY-MM-DD). Passing a date formatted in any other way will be treated as a null value.
If you don't want this behavior, your only choice is to use a regular text input, which you can achieve by manually specifying the type attribute:
code :
<input type="text" asp-for="Process.Date" class="form-control" />


Share : facebook icon twitter icon

What is the best way of localization LOCBaml or Resx based localization?


By : user2258343
Date : March 29 2020, 07:55 AM
may help you . I think the document linked in this post contains a lot of information about localization in WPF. In the end, it is up to you to decide which mechanism to use.
Since you are talking about a custom control, I would consider to give it a Culture dependency property which the consumer of your control can use to specify the desired culture. This way, the consumer can use your localized control, relatively independent of the localization strategy he/she chose.

AngularJS datetime format get wrong hour and minute value based on localization


By : Wongnat
Date : March 29 2020, 07:55 AM
should help you out You can add timezone as the third argument when you're using the date filter.
code :
{{ date_expression | date : format : timezone}}
<i   title="Baxıldı {{item.ViewedDate | date: 'dd.MM.yyyy hh:mm:ss Z': 'utc'}}"></i>

EF Core + npgsql DateTime uses windows 10 localization for formatting


By : Matt
Date : March 29 2020, 07:55 AM
it helps some times If the problem occurs only in migrations, then you can specify the default value with HasDefaultValueSql instead of HasDefaultValue:
code :
builder.Entity<Question>()
    .Property(b => b.AskingTime)
    .HasDefaultValueSql("'2000-01-01 15:00:00'");

Localization based on country in asp.net core 2.1


By : user3061232
Date : March 29 2020, 07:55 AM
wish help you to fix your issue There is an existing feature in .Net that you can know what is the origin. It's called Culture Info.
By default, each client will pass in a culture info or they can specify what is the current language/country they intended to use.
code :
 public class LanguageMessageHandler : DelegatingHandler
{
    private const string LangenUS = "en-US";

    private readonly List<string> _supportedLanguages = new List<string> { LangenUS };

    private bool SetHeaderIfAcceptLanguageMatchesSupportedLanguage(HttpRequestMessage request)
    {
        foreach (var lang in request.Headers.AcceptLanguage)
        {
            if (_supportedLanguages.Contains(lang.Value))
            {
                SetCulture(request, lang.Value);
                return true;
            }
        }

        return false;
    }

    private void SetCulture(HttpRequestMessage request, string lang)
    {
        request.Headers.AcceptLanguage.Clear();
        request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(lang));
        Thread.CurrentThread.CurrentCulture = new CultureInfo(lang);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
    }

    protected override async Task<HttpResponseMessage> SendAsync(
        HttpRequestMessage request, CancellationToken cancellationToken)
    {
        if (!SetHeaderIfAcceptLanguageMatchesSupportedLanguage(request))
        {
            // Whoops no localization found. Lets try Globalisation
            if (!SetHeaderIfGlobalAcceptLanguageMatchesSupportedLanguage(request))
            {
                // no global or localization found
                SetCulture(request, LangenUS);
            }
        }

        var response = await base.SendAsync(request, cancellationToken);
        return response;
    }

    private bool SetHeaderIfGlobalAcceptLanguageMatchesSupportedLanguage(HttpRequestMessage request)
    {
        foreach (var lang in request.Headers.AcceptLanguage)
        {
            var globalLang = lang.Value.Substring(0, 2);
            if (_supportedLanguages.Any(t => t.StartsWith(globalLang)))
            {
                SetCulture(request, _supportedLanguages.FirstOrDefault(i => i.StartsWith(globalLang)));
                return true;
            }
        }

        return false;
    }
}

Localization based on URL .NET Core 3.0


By : user3337271
Date : March 29 2020, 07:55 AM
To fix this issue There are three default RequestCultureProviders, among them is: AcceptLanguageHeaderRequestCultureProvider which use the browser headers for the culture info. You need to overwrite the list instead of inserting the QueryStringRequestCultureProvider into it, thus removing the AcceptLanguageHeaderRequestCultureProvider.
code :
options =>
    {
        var supportedCultures = new List<CultureInfo>
        {
            new CultureInfo("en"),
            new CultureInfo("de"),
            new CultureInfo("nl"),
            new CultureInfo("fr")
        };

        options.DefaultRequestCulture = new RequestCulture(culture: "nl", uiCulture: "nl");
        options.SupportedCultures = supportedCultures;
        options.SupportedUICultures = supportedCultures;

        options.RequestCultureProviders = new List<IRequestCultureProvider>
        {
            new QueryStringRequestCultureProvider(),
            new CookieRequestCultureProvider()
        };
    }
public class UrlRequestCultureProvider : RequestCultureProvider
{
    public override Task<ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext)
    {
        var validCultures = new []{"en", "de", "fr", "nl"};
        if (httpContext == null)
        {
            throw new ArgumentNullException(nameof(httpContext));
        }

        var culture = httpContext.Request.Path.Value
                        .Split("/")
                        .FirstOrDefault( (p) => validCultures.IndexOf(p.ToLower()) >= 0);

        if (culture == null)
        {
            return Task.FromResult((ProviderCultureResult)null);
        }

        return Task.FromResult(new ProviderCultureResult(culture));
    }
}
Related Posts Related Posts :
  • Visual Studio 2019: how to disable specific CodeAnalysis messages in .editorconfig?
  • Pass ID to controller on prev or next
  • What are the difference using app.run and app.useendpoints in asp.net-core?
  • Why string Method(Object object) may not match Func<Object, string> delegate type?
  • Check inside loop if *txt file has been created
  • C# retry logic While loop
  • Convert object {object[]} to string[]
  • Difference between initialize a string to "" or to "".ToString() - Which one should I use?
  • How to make the console wait but then continue without pressing a Key?
  • extract text in rich text format from range
  • how to handle 1000 concurrent user requests per second in asp.net web api
  • In C# How to get Windows Credentials from credential manager
  • Override default value of null conditional operator
  • How to fix override ToString method
  • System.IO.FileNotFoundException when creating EF migrations on .net core
  • Login limit attempts in C#
  • Loop into ListView elements
  • Changing Blazor folder gives me "Cannot find the fallback endpoint"
  • creating class from JSON with different types of a node
  • How to define models for Database tables in C# without using Linq To DB?
  • Understanding Identityserver4 with Identity (cookies/tokens, server architecture)
  • How to Deserialize a JSON into a list using SIMPLE JSON?
  • another option instead using AsEnumerable() in linq EF, when using custom method in linq
  • Parameterized query that returns TEXT column(s) always returns zero for INT columns
  • Why format is not working while appending zeros?
  • SqlConnection string
  • Entity Framework Core Update Database - Code First Approach Without Migration
  • Unity Update Method
  • Custom Middleware is causing Blazor Server-side page to stop working
  • Declaring hex number: The name 'B9780' does not exist in the current context
  • Invalid cast from 'System.Int32' to Enum using reflections
  • Why does my webrequest line need updating? (error (426) Upgrade Required )
  • How to generate Key and Key IV aes in C#
  • How can I display view inside content control in wpf
  • How can I wait for form2 to finish?
  • Is Application.DoEvents() a form of Multitasking?
  • In C#, how can I see if the first character in an account is a specific value?
  • C# Determine if a char at index is between two characters in a string
  • C# - Winform Timer - Disposing and emptying the timer
  • if else condition in Regex c# and return constant value
  • Ternary operator for 3 conditions
  • Fineuploader with Azure, Empty image problem
  • How do I unit test the event raised by class under test?
  • How to set up .net core service that uses a generic repository
  • ASP.NET Core 3.0 Endpoint Routing doesn't work for default route
  • use gmail API token on localhost and hosting at the same time
  • Try-catch FormatException
  • why do sql procedure retuns 0 rows when called from applciation?
  • .Net core 3: The namespace internal does not exist in Microsoft.Extensions.Logging.Internal
  • how to interpolate a variable into string method
  • I want to instantiate an object at the location of another object which is destroyed
  • How to display full path of ALL currently running process in C#?
  • How do I return a LinkedList collection from a lambda?
  • How would I represent the following JSON layout as a C# object?
  • Need a fix for this implicit cast error in my find median method
  • How to write code for Server side pagination in ASP.NET Core
  • Bot Emulator Framework Unable to resolve service
  • How to use WebSocket in one server and access it in another PC in the same LAN?
  • Handling an ViewModel command on Item Select
  • Descending Order By Month SQL when date type is varchar using C# csharp
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk