This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"XLocalizerOptions": { | |
"ResourcesPath": "LocalizationResources", | |
"AutoAddKeys": true, | |
"AutoTranslate": true, | |
"UseExpressMemoryCache": true, | |
"TranslateFromCulture": "en", | |
"ValidationErrors": { | |
"CompareAttribute_MustMatch": "'{0}' and '{1}' do not match. They should not be different!", | |
"CreditCardAttribute_Invalid": "The {0} field is not a valid credit card number.", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddRazorPages() | |
.AddXLocalizer<...>(ops => | |
{ | |
// ... | |
ops.ValidationErrors = new ValidationErrors | |
{ | |
RequiredAttribute_ValidationError = "The {0} field is required.", | |
CompareAttribute_MustMatch = "'{0}' and '{1}' do not match.", | |
StringLengthAttribute_ValidationError = "The field {0} must be a string with a maximum length of {1}.", | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class KebabConverter | |
{ | |
public static string ToKebabCase(this string str) | |
{ | |
// find and replace all parts that starts with one capital letter | |
var str1 = Regex.Replace(str, "[A-Z][a-z]+", m => $"-{m.ToString().ToLower()}"); | |
// find and replace all parts that are all capital letters | |
var str2 = Regex.Replace(str1, "[A-Z]+", m => $"-{m.ToString().ToLower()}"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
// ... | |
public void ConfigureServices(IServiceCollection services) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InputModel | |
{ | |
[Required] | |
[EmailAddress] | |
[Display(Name = "Email")] | |
public string Email { get; set; } | |
[Required] | |
[StringLength(100, MinimumLength = 6)] | |
[DataType(DataType.Password)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page | |
@model RegisterModel | |
@{ | |
ViewData["Title"] = "Register"; | |
} | |
<h1 localize-content>@ViewData["Title"]</h1> | |
<div class="row"> | |
<div class="col-md-4"> |