Closed abllyboy closed 4 years ago
Set Abp.Localization.DefaultLanguage
setting (as constant: LocalizationSettingNames.DefaultLanguage
) to zh-Hans
. See https://docs.abp.io/en/abp/latest/Settings#setting-values-in-the-application-configuration to simply set it in the appsettings.json
I added like this way but it does not work, is it right?
Should be inside the Settings
section.
{
"Settings": {
"Abp.Localization.DefaultLanguage": "zh-Hans"
}
}
when I added the settings in AuthServer.Host and BackendAdminApp.Host ,the AuthServer.Host's default language changed,but the BackendAdminApp.Host not.Even though I added the settings in "IdentityService.Host" and "BackendAdminAppGateway.Host" it not change also.
I stills think this is an issue,even I set the "Abp.Localization.DefaultLanguage" in the table “AbpSettings” to "zh-Hans" and when I visited "http://localhost:51954/Abp/ApplicationConfigurationScript" the settings show the default language is 'zh-Hans' but the words also show as english.Please see the screenshot below:
Clear all cookies and try again. Also, be sure that the default language setting was not set for the user in the database.
The reason is your default cultrue is "zh-CN", not "zh-Hans".
I write a class library that can map these language codes.
https://github.com/maliming/Owl.Abp.CultureMap
var maps = new Dictionary<string, string>
{
{"zh", "zh-Hans"},
{"zh-CN", "zh-Hans"},
{"zh-Hant", "zh-Hans"},
{"zh-TW", "zh-Hans"}
}
Should be inside the
Settings
section.{ "Settings": { "Abp.Localization.DefaultLanguage": "zh-Hans" } }
no effect
I stills think this is an issue,even I set the "Abp.Localization.DefaultLanguage" in the table “AbpSettings” to "zh-Hans" and when I visited "http://localhost:51954/Abp/ApplicationConfigurationScript" the settings show the default language is 'zh-Hans' but the words also show as english.Please see the screenshot below:
Have you solved it?
@abllyboy do you fixed it? I can not make it works
In the "BackendAdminApp.Host" project's BackendAdminAppHostModule.cs I add the following code force to set all the DefaultCultureName to the culture I needed.But it didn't work, the culture is also "en",and I found the culture resource I added can work if the key is not the same as others. And also I tryed to add the cookie in the start page like the code below,because I found the "/Abp/Languages/Switch" do the same thing.But it did'nt work also.
Configure<AbpLocalizationOptions>(options => { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); foreach (var key in options.Resources.Keys) { options.Resources[key].DefaultCultureName = "zh-Hans"; } });
public void OnGet() { string cookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture("zh-Hans", "zh-Hans")); Response.Cookies.Append(CookieRequestCultureProvider.DefaultCookieName, cookieValue, new CookieOptions { Expires = DateTime.Now.AddYears(2) }); }
I got it. just modify in GateWay,Not in WebSite.And add app.UseAbpRequestLocalization(); into GatewayHostModule.@xyfy
Should be inside the
Settings
section.{ "Settings": { "Abp.Localization.DefaultLanguage": "zh-Hans" } }
It worked except in Identity Moudule,for example,when I create a user with duplicate UserName,the err msg is still in English.
Should be inside the
Settings
section.{ "Settings": { "Abp.Localization.DefaultLanguage": "zh-Hans" } }
It worked except in Identity Moudule,for example,when I create a user with duplicate UserName,the err msg is still in English.
In the "BackendAdminApp.Host" project's BackendAdminAppHostModule.cs I add the following code force to set all the DefaultCultureName to the culture I needed.But it didn't work, the culture is also "en",and I found the culture resource I added can work if the key is not the same as others. And also I tryed to add the cookie in the start page like the code below,because I found the "/Abp/Languages/Switch" do the same thing.But it did'nt work also.
Configure<AbpLocalizationOptions>(options => { options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); foreach (var key in options.Resources.Keys) { options.Resources[key].DefaultCultureName = "zh-Hans"; } });
public void OnGet() { string cookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture("zh-Hans", "zh-Hans")); Response.Cookies.Append(CookieRequestCultureProvider.DefaultCookieName, cookieValue, new CookieOptions { Expires = DateTime.Now.AddYears(2) }); }
I got it. just modify in GateWay,Not in WebSite.And add app.UseAbpRequestLocalization(); into GatewayHostModule.@xyfy
@journey191
@x2009again Hi,
My project type is Application(Angular),not Module.There is no GatewayHostModule in my project.
I reuqest the API /api/abp/application-configuration
and the response show that currentCulture
is already Chinese.
But the Excetion Message is still in English.For example,client request get "Identity.DuplicateUserName",not expected "用户名 '{0}' 已存在."
@x2009again Hi, My project type is Application(Angular),not Module.There is no GatewayHostModule in my project. I reuqest the API
/api/abp/application-configuration
and the response show thatcurrentCulture
is already Chinese.But the Excetion Message is still in English.For example,client request get "Identity.DuplicateUserName",not expected "用户名 '{0}' 已存在."
UI should access api through gateway,not directly access the api.
I have the same problem. Is there a solution?
In the "BackendAdminApp.Host" project's BackendAdminAppHostModule.cs I add the following code force to set all the DefaultCultureName to the culture I needed.But it didn't work, the culture is also "en",and I found the culture resource I added can work if the key is not the same as others. And also I tryed to add the cookie in the start page like the code below,because I found the "/Abp/Languages/Switch" do the same thing.But it did'nt work also.