Skip to content

Commit 85f3ab6

Browse files
authored
Merge pull request #63 from DomFiume/fix/dfi/french_translation
fix/dfi/french_translation
2 parents 1344c60 + 9b71ba2 commit 85f3ab6

File tree

5 files changed

+55
-28
lines changed

5 files changed

+55
-28
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.3.1 - August 19 2025
2+
- Fix French translation accent display issue
3+
- Correct French country name translations (Biélorussie, Koweït, Grenade, etc.)
4+
- Preserve accents in displayed names while maintaining search functionality
5+
- Update search logic to handle both accented and non-accented input
6+
17
## 3.3.0 - March 26 2025
28
- Fix localization, typo, and flag issue #51 thanks to @MrRoy121
39

lib/src/country_code.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:collection/collection.dart' show IterableExtension;
2-
import 'package:diacritic/diacritic.dart';
32
import 'package:flutter/cupertino.dart';
43
import 'package:flutter/foundation.dart' show kDebugMode;
54

@@ -45,7 +44,9 @@ class CountryCode {
4544
try {
4645
return CountryCode.fromCountryCode(countryCode);
4746
} catch (e) {
48-
if (kDebugMode) print('Failed to recognize country from countryCode: $countryCode');
47+
if (kDebugMode) {
48+
print('Failed to recognize country from countryCode: $countryCode');
49+
}
4950
return null;
5051
}
5152
}
@@ -61,20 +62,21 @@ class CountryCode {
6162
try {
6263
return CountryCode.fromDialCode(dialCode);
6364
} catch (e) {
64-
if (kDebugMode) print('Failed to recognize country from dialCode: $dialCode');
65+
if (kDebugMode) {
66+
print('Failed to recognize country from dialCode: $dialCode');
67+
}
6568
return null;
6669
}
6770
}
6871

6972
CountryCode localize(BuildContext context) {
7073
final nam = CountryLocalizations.of(context)?.translate(code) ?? name;
71-
return this
72-
..name = nam == null? name : removeDiacritics(nam);
74+
return this..name = nam ?? name;
7375
}
7476

7577
factory CountryCode.fromJson(Map<String, dynamic> json) {
7678
return CountryCode(
77-
name: removeDiacritics(json['name']),
79+
name: json['name'],
7880
code: json['code'],
7981
dialCode: json['dial_code'],
8082
flagUri: 'flags/${json['code'].toLowerCase()}.png',

lib/src/i18n/fr.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"BH": "Bahrein",
1919
"BD": "Bangladesh",
2020
"BB": "Barbade",
21-
"BY": "Bielorussie",
21+
"BY": "Biélorussie",
2222
"BE": "Belgique",
2323
"BZ": "Belize",
2424
"BJ": "Bénin",
@@ -38,7 +38,7 @@
3838
"CM": "Cameroun",
3939
"CA": "Canada",
4040
"CV": "Cap-Vert",
41-
"KY": "Caïmanes",
41+
"KY": "Îles Caïmans",
4242
"CF": "Centrafricaine, République",
4343
"TD": "Tchad",
4444
"CL": "Chili",
@@ -83,7 +83,7 @@
8383
"GI": "Gibraltar",
8484
"GR": "Grèce",
8585
"GL": "Groenland",
86-
"GD": "Grenada",
86+
"GD": "Grenade",
8787
"GP": "Guadeloupe",
8888
"GU": "Guam",
8989
"GT": "Guatemala",
@@ -110,9 +110,9 @@
110110
"KZ": "Kazakhstan",
111111
"KE": "Kenya",
112112
"KI": "Kiribati",
113-
"KP": "Corée du Nord, République populaire démocratique",
114-
"KR": "Corée du Sud, République",
115-
"KW": "Koweit",
113+
"KP": "Corée du Nord",
114+
"KR": "Corée du Sud",
115+
"KW": "Koweït",
116116
"KG": "Kirghistan",
117117
"LA": "Laos",
118118
"LV": "Lettonie",
@@ -179,7 +179,7 @@
179179
"SH": "Sainte-Hélène",
180180
"KN": "Saint-Christophe-et-Niévès",
181181
"LC": "Sainte-Lucie",
182-
"PM": "Saint Pierre and Miquelon",
182+
"PM": "Saint-Pierre-et-Miquelon",
183183
"VC": "Saint-Vincent et les Grenadines",
184184
"WS": "Samoa",
185185
"SM": "Saint-Marin",
@@ -200,15 +200,15 @@
200200
"SD": "Soudan",
201201
"SR": "Suriname",
202202
"SJ": "Svalbard et Île Jan Mayen",
203-
"SZ": "Ngwane, Royaume d'Eswatini",
203+
"SZ": "Eswatini",
204204
"SE": "Suède",
205205
"CH": "Suisse",
206206
"SY": "Syrie",
207207
"TW": "Taïwan",
208208
"TJ": "Tadjikistan",
209-
"TZ": "Tanzanie, République unie",
209+
"TZ": "Tanzanie",
210210
"TH": "Thaïlande",
211-
"TL": "Timor Leste",
211+
"TL": "Timor-Leste",
212212
"TG": "Togo",
213213
"TK": "Tokelau",
214214
"TO": "Tonga",

lib/src/selection_dialog.dart

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:diacritic/diacritic.dart';
23

34
import 'country_code.dart';
45
import 'country_localizations.dart';
@@ -50,7 +51,7 @@ class SelectionDialog extends StatefulWidget {
5051
InputDecoration searchDecoration = const InputDecoration(),
5152
this.searchStyle,
5253
this.textStyle,
53-
required this.topBarPadding,
54+
required this.topBarPadding,
5455
this.headerText,
5556
this.boxDecoration,
5657
this.showFlag,
@@ -62,9 +63,12 @@ class SelectionDialog extends StatefulWidget {
6263
this.hideSearch = false,
6364
this.hideCloseIcon = false,
6465
this.closeIcon,
65-
this.dialogItemPadding = const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
66+
this.dialogItemPadding =
67+
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
6668
this.searchPadding = const EdgeInsets.symmetric(horizontal: 24),
67-
}) : searchDecoration = searchDecoration.prefixIcon == null ? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search)) : searchDecoration,
69+
}) : searchDecoration = searchDecoration.prefixIcon == null
70+
? searchDecoration.copyWith(prefixIcon: const Icon(Icons.search))
71+
: searchDecoration,
6872
super(key: key);
6973

7074
@override
@@ -81,7 +85,8 @@ class _SelectionDialogState extends State<SelectionDialog> {
8185
child: Container(
8286
clipBehavior: Clip.hardEdge,
8387
width: widget.size?.width ?? MediaQuery.of(context).size.width,
84-
height: widget.size?.height ?? MediaQuery.of(context).size.height * 0.85,
88+
height:
89+
widget.size?.height ?? MediaQuery.of(context).size.height * 0.85,
8590
decoration: widget.boxDecoration ??
8691
BoxDecoration(
8792
color: widget.backgroundColor ?? Colors.white,
@@ -100,7 +105,9 @@ class _SelectionDialogState extends State<SelectionDialog> {
100105
crossAxisAlignment: CrossAxisAlignment.end,
101106
children: [
102107
Padding(
103-
padding:!widget.hideHeaderText? widget.topBarPadding: EdgeInsets.zero,
108+
padding: !widget.hideHeaderText
109+
? widget.topBarPadding
110+
: EdgeInsets.zero,
104111
child: Row(
105112
mainAxisAlignment: widget.headerAlignment,
106113
children: [
@@ -177,11 +184,14 @@ class _SelectionDialogState extends State<SelectionDialog> {
177184
if (widget.showFlag!)
178185
Flexible(
179186
child: Container(
180-
margin: Directionality.of(context) == TextDirection.ltr // Here Adding padding depending on the locale language direction
187+
margin: Directionality.of(context) ==
188+
TextDirection
189+
.ltr // Here Adding padding depending on the locale language direction
181190
? const EdgeInsets.only(right: 16.0)
182191
: const EdgeInsets.only(left: 16.0),
183192
decoration: widget.flagDecoration,
184-
clipBehavior: widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
193+
clipBehavior:
194+
widget.flagDecoration == null ? Clip.none : Clip.hardEdge,
185195
child: Image.asset(
186196
e.flagUri!,
187197
package: 'country_code_picker',
@@ -192,7 +202,9 @@ class _SelectionDialogState extends State<SelectionDialog> {
192202
Expanded(
193203
flex: 4,
194204
child: Text(
195-
widget.showCountryOnly! ? e.toCountryStringOnly() : e.toLongString(),
205+
widget.showCountryOnly!
206+
? e.toCountryStringOnly()
207+
: e.toLongString(),
196208
overflow: TextOverflow.fade,
197209
style: widget.textStyle,
198210
),
@@ -208,7 +220,8 @@ class _SelectionDialogState extends State<SelectionDialog> {
208220
}
209221

210222
return Center(
211-
child: Text(CountryLocalizations.of(context)?.translate('no_country') ?? 'No country found'),
223+
child: Text(CountryLocalizations.of(context)?.translate('no_country') ??
224+
'No country found'),
212225
);
213226
}
214227

@@ -219,9 +232,15 @@ class _SelectionDialogState extends State<SelectionDialog> {
219232
}
220233

221234
void _filterElements(String s) {
222-
s = s.toUpperCase();
235+
final normalizedSearch = removeDiacritics(s.toUpperCase());
223236
setState(() {
224-
filteredElements = widget.elements.where((e) => e.code!.contains(s) || e.dialCode!.contains(s) || e.name!.toUpperCase().contains(s)).toList();
237+
filteredElements = widget.elements
238+
.where((e) =>
239+
e.code!.contains(normalizedSearch) ||
240+
e.dialCode!.contains(normalizedSearch) ||
241+
removeDiacritics(e.name!.toUpperCase())
242+
.contains(normalizedSearch))
243+
.toList();
225244
});
226245
}
227246

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: country_code_picker
22
description: A flutter package for showing a country code selector. In addition it gives the possibility to select a list of favorites countries, as well as to search using a simple searchbox
3-
version: 3.3.0
3+
version: 3.3.1
44
homepage: https://github.com/chandrabezzo/CountryCodePicker
55
repository: https://github.com/chandrabezzo/CountryCodePicker
66
issue_tracker: https://github.com/imtoori/CountryCodePicker/issues

0 commit comments

Comments
 (0)