Skip to content

Commit

Permalink
Allow _resolvePlural to search _fallbackTranslation values when tryin…
Browse files Browse the repository at this point in the history
…g 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 <kyle.cummings@thinkingbox.com>
  • Loading branch information
shrdnar and kyle-tbx authored Sep 5, 2023
1 parent 390081f commit 27b81cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/src/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions test/easy_localization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
Expand Down

0 comments on commit 27b81cd

Please sign in to comment.