Closed HassanBakri closed 4 years ago
Sorry to late!
You can customize the way to determine initial language by setting GetInitialLanguageAsync
property of I18nTextOptions
class to your custom logic at ConfigureServices()
in your Startup
class, like this:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddI18nText<Startup>(options =>
{
options.GetInitialLanguageAsync = ...; // set your custom method or function.
});
...
The signature of getting initial language method/function is:
async ValueTask<string> YourCustomMethodOrFunction(
IServiceProvider serviceProvider,
I18nTextOptions options)
{
// ... do something for determine initial language...
return "<language and country code, ex: "en-US", "ja-JP", etc.>";
}
If you want to hard coding the language code literal (for example, you want to set french language) in Startup.cs
, you can do it like this:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddI18nText<Startup>(options =>
{
options.GetInitialLanguageAsync = (svc, opt) => new ValueTask<string>("fr-FR");
});
...
thank you , seems to be working
i found solution on the following issue #8 but i thought it might be better solution exist