From 1ca2630311599630a055a3749957277220ce0242 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Thu, 13 Jun 2024 12:52:58 +0200 Subject: [PATCH] Tagline: support for countries only locales: (eg `_FR`) --- .../lib/data_models/news_feed/newsfeed_json.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/smooth_app/lib/data_models/news_feed/newsfeed_json.dart b/packages/smooth_app/lib/data_models/news_feed/newsfeed_json.dart index 9ddd6e2a7ab..e10b4be3901 100644 --- a/packages/smooth_app/lib/data_models/news_feed/newsfeed_json.dart +++ b/packages/smooth_app/lib/data_models/news_feed/newsfeed_json.dart @@ -96,9 +96,13 @@ class _TagLineItemNewsItem { if (_translations.containsKey(locale)) { translation = _translations[locale]; } else if (locale.contains('_')) { - final String languageCode = locale.split('_').first; + final List splittedLocale = locale.split('_'); + final String languageCode = splittedLocale.first; + final String countryCode = '_${splittedLocale.last}'; if (_translations.containsKey(languageCode)) { translation = _translations[languageCode]; + } else if (_translations.containsKey(countryCode)) { + translation = _translations[countryCode]; } } @@ -335,9 +339,13 @@ class _TaglineJSONFeed { // Try by language if (locale.contains('_')) { - final String languageCode = locale.split('_').first; + final List splittedLocale = locale.split('_'); + final String languageCode = splittedLocale.first; + final String countryCode = '_${splittedLocale.last}'; if (_news.containsKey(languageCode)) { return _news[languageCode]!; + } else if (_news.containsKey(countryCode)) { + return _news[countryCode]!; } }