Skip to content

Commit

Permalink
Add Catalan language and update Spanish language (#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
deividgp committed Jan 17, 2023
1 parent aee69fe commit 7c1cf12
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/FluentValidation.Tests/LocalisedMessagesTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Dispose()
try {
var validator = new TestValidator(v => v.RuleFor(x => x.Surname).NotEmpty());

foreach (var culture in new[] { "en", "de", "fr", "es", "de", "it", "nl", "pl", "pt", "ru", "sv", "ar" }) {
foreach (var culture in new[] { "en", "de", "fr", "es", "ca", "de", "it", "nl", "pl", "pt", "ru", "sv", "ar" }) {
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
var message = ValidatorOptions.Global.LanguageManager.GetString("NotEmptyValidator");
var errorMessage = new MessageFormatter().AppendPropertyName("Surname").BuildMessage(message);
Expand Down
1 change: 1 addition & 0 deletions src/FluentValidation/Resources/LanguageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class LanguageManager : ILanguageManager {
WelshLanguage.Culture => WelshLanguage.GetTranslation(key),
UzbekLatinLanguage.Culture => UzbekLatinLanguage.GetTranslation(key),
UzbekCyrillicLanguage.Culture => UzbekCyrillicLanguage.GetTranslation(key),
CatalanLanguage.Culture => CatalanLanguage.GetTranslation(key),
_ => null,
};
}
Expand Down
60 changes: 60 additions & 0 deletions src/FluentValidation/Resources/Languages/CatalanLanguage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#region License

// Copyright (c) .NET Foundation and contributors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// The latest version of this file can be found at https://github.com/FluentValidation/FluentValidation

#endregion

#pragma warning disable 618

namespace FluentValidation.Resources;

internal class CatalanLanguage {
public const string Culture = "ca";

public static string GetTranslation(string key) => key switch {
"EmailValidator" => "'{PropertyName}' no és una adreça de correu electrònic vàlida.",
"GreaterThanOrEqualValidator" => "'{PropertyName}' ha de ser més gran o igual que '{ComparisonValue}'.",
"GreaterThanValidator" => "'{PropertyName}' ha de ser més gran que '{ComparisonValue}'.",
"LengthValidator" => "'{PropertyName}' ha de tenir entre {MinLength} i {MaxLength} caràcters. Actualment té {TotalLength} caràcters.",
"MinimumLengthValidator" => "'{PropertyName}' ha de ser més gran o igual que {MinLength} caràcters. Ha inserit {TotalLength} caràcters.",
"MaximumLengthValidator" => "'{PropertyName}' ha de ser menor o igual que {MaxLength} caràcters. Ha inserit {TotalLength} caràcters.",
"LessThanOrEqualValidator" => "'{PropertyName}' ha de ser menor o igual que '{ComparisonValue}'.",
"LessThanValidator" => "'{PropertyName}' ha de ser menor que '{ComparisonValue}'.",
"NotEmptyValidator" => "'{PropertyName}' no hauria d'estar buit.",
"NotEqualValidator" => "'{PropertyName}' no hauria de ser igual a '{ComparisonValue}'.",
"NotNullValidator" => "'{PropertyName}' no ha d'estar buit.",
"PredicateValidator" => "'{PropertyName}' no compleix amb la condició especificada.",
"AsyncPredicateValidator" => "'{PropertyName}' no compleix amb la condició especificada.",
"RegularExpressionValidator" => "'{PropertyName}' no té el format correcte.",
"EqualValidator" => "'{PropertyName}' hauria de ser igual a '{ComparisonValue}'.",
"ExactLengthValidator" => "'{PropertyName}' ha de tenir una llargada de {MaxLength} caràcters. Actualment té {TotalLength} caràcters.",
"ExclusiveBetweenValidator" => "'{PropertyName}' ha d'estar entre {From} i {To} (exclusiu). Actualment té un valor de {PropertyValue}.",
"InclusiveBetweenValidator" => "'{PropertyName}' ha d'estar entre {From} i {To}. Actualment té un valor de {PropertyValue}.",
"CreditCardValidator" => "'{PropertyName}' no és un número de targeta de crèdit vàlid.",
"ScalePrecisionValidator" => "'{PropertyName}' no ha de tenir més de {ExpectedPrecision} dígits en total, amb marge per {ExpectedScale} decimals. S'han trobat {Digits} i {ActualScale} decimals.",
"EmptyValidator" => "'{PropertyName}' ha d'estar buit.",
"NullValidator" => "'{PropertyName}' ha d'estar buit.",
"EnumValidator" => "'{PropertyName}' té un rang de valors que no inclou '{PropertyValue}'.",
// Additional fallback messages used by clientside validation integration.
"Length_Simple" => "'{PropertyName}' ha de tenir entre {MinLength} i {MaxLength} caràcters.",
"MinimumLength_Simple" => "'{PropertyName}' ha de ser més gran o igual que {MinLength} caràcters.",
"MaximumLength_Simple" => "'{PropertyName}' ha de ser menor o igual que {MaxLength} caràcters.",
"ExactLength_Simple" => "'{PropertyName}' ha de tenir una longitud de {MaxLength} caràcters.",
"InclusiveBetween_Simple" => "'{PropertyName}' ha d'estar entre {From} i {To}.",
_ => null,
};
}
16 changes: 8 additions & 8 deletions src/FluentValidation/Resources/Languages/SpanishLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ internal class SpanishLanguage {
"EmailValidator" => "'{PropertyName}' no es una dirección de correo electrónico válida.",
"GreaterThanOrEqualValidator" => "'{PropertyName}' debe ser mayor o igual que '{ComparisonValue}'.",
"GreaterThanValidator" => "'{PropertyName}' debe ser mayor que '{ComparisonValue}'.",
"LengthValidator" => "'{PropertyName}' debe tener entre {MinLength} y {MaxLength} caracter(es). Actualmente tiene {TotalLength} caracter(es).",
"MinimumLengthValidator" => "'{PropertyName}' debe ser mayor o igual que {MinLength} caracteres. Ingresó {TotalLength} caracter(es).",
"MaximumLengthValidator" => "'{PropertyName}' debe ser menor o igual que {MaxLength} caracteres. Ingresó {TotalLength} caracter(es).",
"LengthValidator" => "'{PropertyName}' debe tener entre {MinLength} y {MaxLength} carácteres. Actualmente tiene {TotalLength} carácteres.",
"MinimumLengthValidator" => "'{PropertyName}' debe ser mayor o igual que {MinLength} carácteres. Ingresó {TotalLength} carácteres.",
"MaximumLengthValidator" => "'{PropertyName}' debe ser menor o igual que {MaxLength} carácteres. Ingresó {TotalLength} carácteres.",
"LessThanOrEqualValidator" => "'{PropertyName}' debe ser menor o igual que '{ComparisonValue}'.",
"LessThanValidator" => "'{PropertyName}' debe ser menor que '{ComparisonValue}'.",
"NotEmptyValidator" => "'{PropertyName}' no debería estar vacío.",
Expand All @@ -41,7 +41,7 @@ internal class SpanishLanguage {
"AsyncPredicateValidator" => "'{PropertyName}' no cumple con la condición especificada.",
"RegularExpressionValidator" => "'{PropertyName}' no tiene el formato correcto.",
"EqualValidator" => "'{PropertyName}' debería ser igual a '{ComparisonValue}'.",
"ExactLengthValidator" => "'{PropertyName}' debe tener un largo de {MaxLength} caracteres. Actualmente tiene {TotalLength} caracter(es).",
"ExactLengthValidator" => "'{PropertyName}' debe tener una longitud de {MaxLength} carácteres. Actualmente tiene {TotalLength} carácteres.",
"ExclusiveBetweenValidator" => "'{PropertyName}' debe estar entre {From} y {To} (exclusivo). Actualmente tiene un valor de {PropertyValue}.",
"InclusiveBetweenValidator" => "'{PropertyName}' debe estar entre {From} y {To}. Actualmente tiene un valor de {PropertyValue}.",
"CreditCardValidator" => "'{PropertyName}' no es un número de tarjeta de crédito válido.",
Expand All @@ -50,10 +50,10 @@ internal class SpanishLanguage {
"NullValidator" => "'{PropertyName}' debe estar vacío.",
"EnumValidator" => "'{PropertyName}' tiene un rango de valores que no incluye '{PropertyValue}'.",
// Additional fallback messages used by clientside validation integration.
"Length_Simple" => "'{PropertyName}' debe tener entre {MinLength} y {MaxLength} caracter(es).",
"MinimumLength_Simple" => "'{PropertyName}' debe ser mayor o igual que {MinLength} caracteres.",
"MaximumLength_Simple" => "'{PropertyName}' debe ser menor o igual que {MaxLength} caracteres.",
"ExactLength_Simple" => "'{PropertyName}' debe tener un largo de {MaxLength} caracteres.",
"Length_Simple" => "'{PropertyName}' debe tener entre {MinLength} y {MaxLength} carácteres.",
"MinimumLength_Simple" => "'{PropertyName}' debe ser mayor o igual que {MinLength} carácteres.",
"MaximumLength_Simple" => "'{PropertyName}' debe ser menor o igual que {MaxLength} carácteres.",
"ExactLength_Simple" => "'{PropertyName}' debe tener una longitud de {MaxLength} carácteres.",
"InclusiveBetween_Simple" => "'{PropertyName}' debe estar entre {From} y {To}.",
_ => null,
};
Expand Down

0 comments on commit 7c1cf12

Please sign in to comment.