Skip to content

Commit

Permalink
Fixed plural rules fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Sartori authored and aissat committed Jul 3, 2021
1 parent c51dd44 commit 5a57f96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/src/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ class Localization {
}

String _resolvePlural(String key, String subKey) {
var resource = _resolve('$key.$subKey');
final tag = '$key.$subKey';
var resource = _resolve(tag);
if (resource == tag && subKey != 'other')
resource = _resolve('$key.other');
return resource;
}

Expand All @@ -120,6 +123,7 @@ class Localization {
EasyLocalization.logger.warning('Localization key [$key] not found');
}
if (_fallbackTranslations == null) {

return key;
} else {
resource = _fallbackTranslations?.get(key);
Expand Down
2 changes: 1 addition & 1 deletion test/easy_localization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void main() {
});

test('other as fallback', () {
expect(Localization.instance.plural('hat_other', -1), 'other hats');
expect(Localization.instance.plural('hat_other', 1), 'other hats');
});

test('with number format', () {
Expand Down

0 comments on commit 5a57f96

Please sign in to comment.