Skip to content

Commit

Permalink
feat(i18n): Fix ValidatorMiddleware error & Fix I18n errors (#333)
Browse files Browse the repository at this point in the history
* fix: Fix ValidatorMiddleware error

* fix: Fix I18n errors
  • Loading branch information
zhenlei520 authored Nov 15, 2022
1 parent f284bab commit b34148a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override async Task HandleAsync(TEvent @event, EventHandlerDelegate next)
@event,
failures);

var validationException = new ValidationException("Validation exception", failures);
var validationException = new ValidationException(failures);
throw new MasaValidatorException(validationException.Message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ public static IApplicationBuilder UseI18n(this IApplicationBuilder app, string?

var requestLocalization = new RequestLocalizationOptions();

var cultures = settings.SupportedCultures.Select(x => x.Culture).ToArray();
requestLocalization
.AddSupportedCultures(cultures)
.AddSupportedUICultures(cultures);
requestLocalization.SetDefaultCulture(!string.IsNullOrWhiteSpace(defaultCulture) ? defaultCulture : cultures.FirstOrDefault()!);

requestLocalization.ApplyCurrentCultureToResponseHeaders = true;
app.UseRequestLocalization(requestLocalization);
if (settings.SupportedCultures.Any())
{
var cultures = settings.SupportedCultures.Select(x => x.Culture).ToArray();
requestLocalization
.AddSupportedCultures(cultures)
.AddSupportedUICultures(cultures);
requestLocalization.SetDefaultCulture(!string.IsNullOrWhiteSpace(defaultCulture) ? defaultCulture : cultures.FirstOrDefault()!);

requestLocalization.ApplyCurrentCultureToResponseHeaders = true;
app.UseRequestLocalization(requestLocalization);
}
return app;
}
}

0 comments on commit b34148a

Please sign in to comment.