From 27b81cd68ac0e33b049ed49684ad6c08c76da7fa Mon Sep 17 00:00:00 2001 From: shrdnar Date: Tue, 5 Sep 2023 15:19:39 -0400 Subject: [PATCH] Allow _resolvePlural to search _fallbackTranslation values when trying to resolve a plural key (#559) * resolve plural should not force fallback value to false * revert just for sanity check * _resolvePlural _resolve fallback value should consider if _fallbackTranslations is null or not * update intl version for compatibility * - revert intl versions in pubspec.yaml - update test case for plural with fallback priority --------- Co-authored-by: Kyle Cummings --- lib/src/localization.dart | 2 +- test/easy_localization_test.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/localization.dart b/lib/src/localization.dart index 97fe73ac..f89f2324 100644 --- a/lib/src/localization.dart +++ b/lib/src/localization.dart @@ -178,7 +178,7 @@ class Localization { if (subKey == 'other') return _resolve('$key.other'); final tag = '$key.$subKey'; - var resource = _resolve(tag, logging: false, fallback: false); + var resource = _resolve(tag, logging: false, fallback: _fallbackTranslations != null); if (resource == tag) { resource = _resolve('$key.other'); } diff --git a/test/easy_localization_test.dart b/test/easy_localization_test.dart index bfb01c6b..d5177d5b 100644 --- a/test/easy_localization_test.dart +++ b/test/easy_localization_test.dart @@ -469,12 +469,12 @@ void main() { expect(Localization.instance.plural('hat_other', 1), 'other hats'); }); - test('other as fallback and fallback translations priority', + test('two as fallback and fallback translations priority', overridePrint(() { printLog = []; expect( Localization.instance.plural('test_fallback_plurals', 2), - '2 seconds', // isNot('fallback two'), + 'fallback two', ); expect(printLog, isEmpty); }));