Skip to content

Commit

Permalink
Merge pull request #5 from sncf-connect-tech/fix-languages-with-count…
Browse files Browse the repository at this point in the history
…rycode

Fix SVG retrieval for languages with country code
  • Loading branch information
jyardin authored Mar 16, 2023
2 parents 926ba86 + 4de36f0 commit 1247852
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.9

* Fixed SVG retrieval for languages with country code that don't have a match in SVG assets

## 0.0.8

* Fixed SVG in all supported locales
Expand Down
6 changes: 5 additions & 1 deletion lib/utils/locale_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ extension LocaleExtensions on Locale {
bool _existsInAssets() => validAssetLocaleSet.contains(this);

Locale _getFallbackLocale() {
final primaryLocale = Locale(languageCode);
if (primaryLocale._existsInAssets()) {
return primaryLocale;
}
switch (languageCode) {
case 'fr':
return const Locale('fr', 'FR');
case 'en':
return const Locale('en', 'GB');
return const Locale('en', 'US');
case 'es':
return const Locale('es', 'ES');
case 'zh':
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_google_wallet
description: A Flutter Google Wallet Plugin
version: 0.0.8
version: 0.0.9
homepage: https://github.com/voyages-sncf-technologies/flutter_google_wallet

environment:
Expand Down
4 changes: 3 additions & 1 deletion test/locale_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
test('GIVEN locale THEN toAssetPrefix() returns asset prefix', () async {
expect(const Locale('fr').toAssetPrefix(), 'frFR');
expect(const Locale('fr', 'CA').toAssetPrefix(), 'frCA');
expect(const Locale('de').toAssetPrefix(), 'de');
expect(const Locale('en').toAssetPrefix(), 'enGB');
expect(const Locale('de', 'DE').toAssetPrefix(), 'de');
expect(const Locale('en').toAssetPrefix(), 'enUS');
expect(const Locale('it').toAssetPrefix(), 'it');
expect(const Locale('nl').toAssetPrefix(), 'nl');
});
Expand Down

0 comments on commit 1247852

Please sign in to comment.