sorry,
var defaultLanguage = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); var (cultureName, uiCultureName) = LocalizationSettingHelper.ParseLanguageSetting(defaultLanguage); using (CultureHelper.Use(CultureInfo.GetCultureInfo(cultureName))) { GenerateViolationReport() }
Now it work well Thanx
hi
here I want to set defaultLanguage to use it in GenerateViolationReport() method
hi
You can switch the current culture
// get defaultLanguage for this tenant var defaultLanguage = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); // here I want to set defaultLanguage to use it in GenerateViolationReport() method using (CultureHelper.Use(CultureInfo.GetCultureInfo(defaultLanguage))) { GenerateViolationReport() }
Hi bro .. I am sorry it gave me this error
System.Globalization.CultureNotFoundException: Culture is not supported. (Parameter 'name') ar;ar is an invalid culture identifier.
hi
The
LocalizationSettingNames.DefaultLanguage
is a setting so you can change via https://docs.abp.io/en/abp/latest/Settingshow I can use it to translate string
https://docs.abp.io/en/abp/latest/Localization
Hi bro ..
this is Excution method for backgrounJob Hangifire
public async Task Excute()
{
var tenants = await _tenantRepository.GetListAsync();
foreach (var tenant in tenants)
{
using (_currentTenant.Change(tenant.Id))
{
// get defaultLanguage for this tenant
var defaultLanguage = await _settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);
// here I want to set defaultLanguage to use it in GenerateViolationReport() method
//...
//...
var absenceAssignmentEmployees = await GetAbsenceAssignmentEmployees();
var toBeReported = await GenerateAbsenceReport(absenceAssignmentEmployees);
if (toBeReported.Any())
{
await _absenceRepository.InsertManyAsync(toBeReported, autoSave: true);
var absenceIds = toBeReported.Select(absence => absence.Id).ToList();
// get absences with related data
var absences = await _absenceRepository.GetAbsencesByAbsenceIdsWithDetailsAsync(absenceIds);
//TODO EntityLogs
var violations = await GenerateViolationReport(absences);
if (violations.Any())
{
await _violationRepository.InsertManyAsync(violations, autoSave: true);
//TODO EntityLogs
}
}
}
}
}
I read this documnet https://docs.abp.io/en/abp/latest/Settings and saw this way :
public class MySettingDefinitionProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
var smtpHost = context.GetOrNull("Abp.Mailing.Smtp.Host");
if (smtpHost != null)
{
smtpHost.DefaultValue = "mail.mydomain.com";
smtpHost.DisplayName =
new LocalizableString(
typeof(MyLocalizationResource),
"SmtpServer_DisplayName"
);
}
}
}
but I did not know way to set DefaultLanguage from My code
can you help me Pls ....
Thanx..
var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);
thanks ... what is the next step ..
how I can set DefaultLanguage in my code
how I can use it to translate string
I want to set the specified language for the tenant in the backgroundJob Hangfire
example: if the tenant is arabic language I want to set language arabic ...
How I can implementation that please ...
Hi,
You need to check our migration guide: https://github.com/abpframework/abp/blob/dev/docs/en/Migration-Guides/Abp-6_0.md
Use CLI:
switch-to-preview
or just change all ABP's NuGet packages version to6.0.0-rc.2
BTW, I recommend you wait for the 6.0 stable release.
Thanks.. I will wait for V6.0.0 ... but I am asking you Can I Switch from V5.0.0 to V6.0.0 stable directly Or I have to switch from V5.0.0 to V5.3.3 firstly.. then switch to V6.0.0