Skip to content

Commit

Permalink
Merge pull request #6 from monisnap-julien/feature/french_language
Browse files Browse the repository at this point in the history
🌐 Adding french language
  • Loading branch information
themisir authored Aug 10, 2020
2 parents 5552dbe + 0f2987f commit 1951989
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/src/i18n/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import '../form_validator_locale.dart';

import 'az.dart';
import 'en.dart';
import 'fr.dart';
import 'tr.dart';

FormValidatorLocale createLocale(String locale) {
switch (locale) {
case 'az':
return LocaleAz();

case 'fr':
return LocaleFr();

case 'tr':
return LocaleTr();

Expand Down
32 changes: 32 additions & 0 deletions lib/src/i18n/fr.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import '../form_validator_locale.dart';

class LocaleFr extends FormValidatorLocale {
@override
String name() => 'fr';

@override
String minLength(String v, int n) =>
"Le champ doit contenir au moins $n caractère${n > 1 ? 's' : ''}";

@override
String maxLength(String v, int n) =>
"Le champ ne peut pas contenir plus de $n caractère${n > 1 ? 's' : ''}";

@override
String email(String v) => "Adresse email invalide";

@override
String phoneNumber(String v) => "Numéro de téléphone invalide";

@override
String required() => "Le champ est requis";

@override
String ip(String v) => "Le champ n'est pas une adresse IP valide";

@override
String ipv6(String v) => "Le champ n'est pas une adresse IPv6 valide";

@override
String url(String v) => "Le champ n'est pas une URL valide";
}
4 changes: 3 additions & 1 deletion test/localization_test.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import 'package:form_validator/form_validator.dart';
import 'package:form_validator/src/i18n/az.dart';
import 'package:form_validator/src/i18n/tr.dart';
import 'package:form_validator/src/i18n/en.dart';
import 'package:form_validator/src/i18n/fr.dart';
import 'package:form_validator/src/i18n/tr.dart';
import 'package:test/test.dart';

final availableLocales = <String, FormValidatorLocale>{
'az': LocaleAz(),
'en': LocaleEn(),
'tr': LocaleTr(),
'fr': LocaleFr(),
};

void validateLocale(ValidationBuilder builder, FormValidatorLocale locale) {
Expand Down

0 comments on commit 1951989

Please sign in to comment.