Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Special thanks to [@PawiX25](https://github.com/PawiX25) for the new widget!
### New features

* Added summary home screen widget showing monthly income and expenses by [@PawiX25](https://github.com/PawiX25)
* Now we support plurals in the localization, [#707](https://github.com/flow-mn/flow/pull/707) by [@PawiX25](https://github.com/PawiX25)

### Fixes

* [Android] Two Entry Last now shows the correct buttons, fixed by [@PawiX25](https://github.com/PawiX25)
* Other UX/QoL fixes by [@PawiX25](https://github.com/PawiX25)

## 0.20.0

Expand Down
12 changes: 11 additions & 1 deletion assets/l10n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,11 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "نسخ احتياطي موثوق ومجاني لبياناتك",
"tabs.home.totalBalance": "الرصيد الإجمالي",
"tabs.home.transactionsCount": "{count} معاملة",
"tabs.home.transactionsCount.zero": "{count} معاملات",
"tabs.home.transactionsCount.one": "{count} معاملة",
"tabs.home.transactionsCount.two": "{count} معاملتين",
"tabs.home.transactionsCount.few": "{count} معاملات",
"tabs.home.transactionsCount.many": "{count} معاملة",
"tabs.profile": "الملف الشخصي",
"tabs.profile.backup": "النسخ الاحتياطي",
"tabs.profile.community": "المجتمع",
Expand Down Expand Up @@ -734,6 +739,11 @@
"transactions.batch.importN": "استيراد {n} من المعاملات",
"transactions.batch.review": "يرجى مراجعة المعاملات",
"transactions.count": "{} معاملة",
"transactions.count.zero": "{} معاملات",
"transactions.count.one": "{} معاملة",
"transactions.count.two": "{} معاملتين",
"transactions.count.few": "{} معاملات",
"transactions.count.many": "{} معاملة",
"transactions.pending": "المعاملات المعلقة",
"transactions.query.clearAll": "مسح الفلاتر",
"transactions.query.clearSelection": "مسح الاختيارات",
Expand Down Expand Up @@ -768,4 +778,4 @@
"transactions.query.noResult": "لا توجد معاملات للعرض",
"transactions.query.noResult.description": "حاول تحديث الفلاتر",
"visitGitHubRepo": "زيارة المستودع على جيثب"
}
}
8 changes: 7 additions & 1 deletion assets/l10n/be_BY.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Надзейна і бясплатна захоўвайце свае даныя",
"tabs.home.totalBalance": "Агульны баланс",
"tabs.home.transactionsCount": "{count} транзакцый",
"tabs.home.transactionsCount.one": "{count} транзакцыя",
"tabs.home.transactionsCount.few": "{count} транзакцыі",
"tabs.home.transactionsCount.many": "{count} транзакцый",
"tabs.profile": "Профіль",
"tabs.profile.backup": "Рэзервовая копія",
"tabs.profile.community": "Супольнасць",
Expand Down Expand Up @@ -734,6 +737,9 @@
"transactions.batch.importN": "Імпартаваць {n} транзакцый",
"transactions.batch.review": "Калі ласка, праверце транзакцыі",
"transactions.count": "{} транзакцый",
"transactions.count.one": "{} транзакцыя",
"transactions.count.few": "{} транзакцыі",
"transactions.count.many": "{} транзакцый",
"transactions.pending": "Транзакцыі ў чаканні",
"transactions.query.clearAll": "Ачысціць фільтры",
"transactions.query.clearSelection": "Ачысціць выбар",
Expand Down Expand Up @@ -768,4 +774,4 @@
"transactions.query.noResult": "Няма транзакцый для паказу",
"transactions.query.noResult.description": "Паспрабуйце абнавіць фільтры",
"visitGitHubRepo": "Наведаць рэпазіторый на GitHub"
}
}
6 changes: 5 additions & 1 deletion assets/l10n/cs_CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,8 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Spolehlivě a zdarma zálohujte svá data.",
"tabs.home.totalBalance": "Celkový zůstatek",
"tabs.home.transactionsCount": "{count} transakcí",
"tabs.home.transactionsCount.one": "{count} transakce",
"tabs.home.transactionsCount.few": "{count} transakce",
"tabs.profile": "Profil",
"tabs.profile.backup": "Zálohování a synchronizace",
"tabs.profile.community": "Komunita",
Expand Down Expand Up @@ -734,6 +736,8 @@
"transactions.batch.importN": "Importovat {n} transakcí",
"transactions.batch.review": "Prosím zkontrolujte transakce",
"transactions.count": "{count} transakcí",
"transactions.count.one": "{} transakce",
"transactions.count.few": "{} transakce",
"transactions.pending": "Čekající transakce",
"transactions.query.clearAll": "Vymazat filtry",
"transactions.query.clearSelection": "Zrušit výběr",
Expand Down Expand Up @@ -768,4 +772,4 @@
"transactions.query.noResult": "Nebyly nalezeny žádné transakce.",
"transactions.query.noResult.description": "Zkuste upravit filtry.",
"visitGitHubRepo": "Navštivte repozitář na GitHubu"
}
}
4 changes: 3 additions & 1 deletion assets/l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Zuverlässige, kostenlose Datensicherung",
"tabs.home.totalBalance": "Gesamt-Kontostand",
"tabs.home.transactionsCount": "{count} Buchungen",
"tabs.home.transactionsCount.one": "{count} Buchung",
"tabs.profile": "Profil",
"tabs.profile.backup": "Sicherung",
"tabs.profile.community": "Community",
Expand Down Expand Up @@ -734,6 +735,7 @@
"transactions.batch.importN": "{n} Transaktionen importieren",
"transactions.batch.review": "Bitte überprüfen Sie die Transaktionen",
"transactions.count": "{} Buchungen",
"transactions.count.one": "{} Buchung",
"transactions.pending": "Ausstehende Buchungen",
"transactions.query.clearAll": "Filter löschen",
"transactions.query.clearSelection": "Auswahl löschen",
Expand Down Expand Up @@ -768,4 +770,4 @@
"transactions.query.noResult": "Keine Buchungen zum Anzeigen.",
"transactions.query.noResult.description": "Versuche, die Filter anzupassen.",
"visitGitHubRepo": "Repo auf GitHub besuchen"
}
}
4 changes: 3 additions & 1 deletion assets/l10n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Reliably back up your data for free",
"tabs.home.totalBalance": "Total balance",
"tabs.home.transactionsCount": "{count} transactions",
"tabs.home.transactionsCount.one": "{count} transaction",
"tabs.profile": "Profile",
"tabs.profile.backup": "Backup",
"tabs.profile.community": "Community",
Expand Down Expand Up @@ -734,6 +735,7 @@
"transactions.batch.importN": "Import {n} transactions",
"transactions.batch.review": "Please review the transactions",
"transactions.count": "{} transactions",
"transactions.count.one": "{} transaction",
"transactions.pending": "Pending transactions",
"transactions.query.clearAll": "Clear filters",
"transactions.query.clearSelection": "Clear selections",
Expand Down Expand Up @@ -768,4 +770,4 @@
"transactions.query.noResult": "No transactions to show",
"transactions.query.noResult.description": "Try updating the filters",
"visitGitHubRepo": "Visit repo on GitHub"
}
}
4 changes: 3 additions & 1 deletion assets/l10n/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Realiza copias de seguridad de tus datos de forma fiable y gratis",
"tabs.home.totalBalance": "Saldo total",
"tabs.home.transactionsCount": "{count} transacciones",
"tabs.home.transactionsCount.one": "{count} transacción",
"tabs.profile": "Perfil",
"tabs.profile.backup": "Copia de seguridad",
"tabs.profile.community": "Comunidad",
Expand Down Expand Up @@ -734,6 +735,7 @@
"transactions.batch.importN": "Importar {n} transacciones",
"transactions.batch.review": "Por favor, revise las transacciones",
"transactions.count": "{} transacciones",
"transactions.count.one": "{} transacción",
"transactions.pending": "Transacciones pendientes",
"transactions.query.clearAll": "Borrar filtros",
"transactions.query.clearSelection": "Borrar selecciones",
Expand Down Expand Up @@ -768,4 +770,4 @@
"transactions.query.noResult": "No hay transacciones para mostrar",
"transactions.query.noResult.description": "Intenta actualizar los filtros",
"visitGitHubRepo": "Visitar repositorio en GitHub"
}
}
4 changes: 3 additions & 1 deletion assets/l10n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Sauvegardez vos données en toute fiabilité, gratuitement",
"tabs.home.totalBalance": "Solde total",
"tabs.home.transactionsCount": "{count} transactions",
"tabs.home.transactionsCount.one": "{count} transaction",
"tabs.profile": "Profil",
"tabs.profile.backup": "Sauvegarde",
"tabs.profile.community": "Communauté",
Expand Down Expand Up @@ -734,6 +735,7 @@
"transactions.batch.importN": "Importer {n} transactions",
"transactions.batch.review": "Veuillez vérifier les transactions",
"transactions.count": "{} transactions",
"transactions.count.one": "{} transaction",
"transactions.pending": "Transactions en attente",
"transactions.query.clearAll": "Effacer les filtres",
"transactions.query.clearSelection": "Effacer les sélections",
Expand Down Expand Up @@ -768,4 +770,4 @@
"transactions.query.noResult": "Aucune transaction à afficher",
"transactions.query.noResult.description": "Essayez de mettre à jour les filtres",
"visitGitHubRepo": "Visitez le dépôt sur GitHub"
}
}
4 changes: 3 additions & 1 deletion assets/l10n/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Esegui il backup dei tuoi dati in modo affidabile e gratuitamente",
"tabs.home.totalBalance": "Saldo totale",
"tabs.home.transactionsCount": "{count} transazioni",
"tabs.home.transactionsCount.one": "{count} transazione",
"tabs.profile": "Profilo",
"tabs.profile.backup": "Backup",
"tabs.profile.community": "Comunità",
Expand Down Expand Up @@ -734,6 +735,7 @@
"transactions.batch.importN": "Importa {n} transazioni",
"transactions.batch.review": "Rivedi le transazioni",
"transactions.count": "{count} transazioni",
"transactions.count.one": "{} transazione",
"transactions.pending": "Transazioni in sospeso",
"transactions.query.clearAll": "Cancella filtri",
"transactions.query.clearSelection": "Cancella selezioni",
Expand Down Expand Up @@ -768,4 +770,4 @@
"transactions.query.noResult": "Nessuna transazione da mostrare",
"transactions.query.noResult.description": "Prova ad aggiornare i filtri",
"visitGitHubRepo": "Visita la repo su GitHub"
}
}
8 changes: 7 additions & 1 deletion assets/l10n/pl_PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Niezawodnie twórz darmowe kopie zapasowe danych",
"tabs.home.totalBalance": "Łączne saldo",
"tabs.home.transactionsCount": "{count} transakcji",
"tabs.home.transactionsCount.one": "{count} transakcja",
"tabs.home.transactionsCount.few": "{count} transakcje",
"tabs.home.transactionsCount.many": "{count} transakcji",
"tabs.profile": "Profil",
"tabs.profile.backup": "Kopie zapasowe",
"tabs.profile.community": "Społeczność",
Expand Down Expand Up @@ -734,6 +737,9 @@
"transactions.batch.importN": "Importuj {n} transakcji",
"transactions.batch.review": "Przejrzyj swoje transakcje przed zapisaniem",
"transactions.count": "{} transakcji",
"transactions.count.one": "{} transakcja",
"transactions.count.few": "{} transakcje",
"transactions.count.many": "{} transakcji",
"transactions.pending": "Oczekujące transakcje",
"transactions.query.clearAll": "Wyczyść filtry",
"transactions.query.clearSelection": "Odznacz wszystko",
Expand Down Expand Up @@ -768,4 +774,4 @@
"transactions.query.noResult": "Brak transakcji do wyświetlenia",
"transactions.query.noResult.description": "Spróbuj zaktualizować filtry",
"visitGitHubRepo": "Odwiedź repozytorium GitHub"
}
}
8 changes: 7 additions & 1 deletion assets/l10n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Надежное бесплатное резервное копирование данных",
"tabs.home.totalBalance": "Общий баланс",
"tabs.home.transactionsCount": "{count} транзакций",
"tabs.home.transactionsCount.one": "{count} транзакция",
"tabs.home.transactionsCount.few": "{count} транзакции",
"tabs.home.transactionsCount.many": "{count} транзакций",
"tabs.profile": "Профиль",
"tabs.profile.backup": "Резервное копирование",
"tabs.profile.community": "Сообщество",
Expand Down Expand Up @@ -734,6 +737,9 @@
"transactions.batch.importN": "Импортировать {n} транзакций",
"transactions.batch.review": "Пожалуйста, проверьте транзакции",
"transactions.count": "{} транзакций",
"transactions.count.one": "{} транзакция",
"transactions.count.few": "{} транзакции",
"transactions.count.many": "{} транзакций",
"transactions.pending": "Ожидающие транзакции",
"transactions.query.clearAll": "Очистить фильтры",
"transactions.query.clearSelection": "Очистить выделение",
Expand Down Expand Up @@ -768,4 +774,4 @@
"transactions.query.noResult": "Нет транзакций для отображения",
"transactions.query.noResult.description": "Попробуйте обновить фильтры",
"visitGitHubRepo": "Посетить репозиторий на GitHub"
}
}
8 changes: 7 additions & 1 deletion assets/l10n/uk_UA.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@
"tabs.home.reminders.turnOnICloudSync.subtitle": "Надійно й безкоштовно створюйте резервні копії своїх даних",
"tabs.home.totalBalance": "Загальний баланс",
"tabs.home.transactionsCount": "{count} транзакцій",
"tabs.home.transactionsCount.one": "{count} транзакція",
"tabs.home.transactionsCount.few": "{count} транзакції",
"tabs.home.transactionsCount.many": "{count} транзакцій",
"tabs.profile": "Профіль",
"tabs.profile.backup": "Резервне копіювання",
"tabs.profile.community": "Спільнота",
Expand Down Expand Up @@ -734,6 +737,9 @@
"transactions.batch.importN": "Імпортувати {n} транзакцій",
"transactions.batch.review": "Будь ласка, перегляньте транзакції",
"transactions.count": "{} транзакцій",
"transactions.count.one": "{} транзакція",
"transactions.count.few": "{} транзакції",
"transactions.count.many": "{} транзакцій",
"transactions.pending": "Очікувані транзакції",
"transactions.query.clearAll": "Очистити фільтри",
"transactions.query.clearSelection": "Очистити виділення",
Expand Down Expand Up @@ -768,4 +774,4 @@
"transactions.query.noResult": "Немає транзакцій для відображення",
"transactions.query.noResult.description": "Спробуйте оновити фільтри",
"visitGitHubRepo": "Відвідати репозиторій на GitHub"
}
}
60 changes: 56 additions & 4 deletions lib/l10n/flow_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class FlowLocalizations {
final Locale locale;
static Map<String, String> _localizedValues = {};
static Map<String, String> _enUS = {};
static Locale? _currentLocale;

FlowLocalizations(this.locale);

Expand All @@ -29,6 +30,7 @@ class FlowLocalizations {

Future<void> load() async {
_localizedValues = await _loadLocale(locale);
_currentLocale = locale;

if (_enUS.isEmpty) {
if (locale.code == "en") {
Expand All @@ -52,6 +54,47 @@ class FlowLocalizations {
return text;
}

/// Returns the CLDR plural category for [n] in the given [langCode].
///
/// See: https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
static String _pluralCategory(num n, String langCode) {
final int i = n.toInt();
switch (langCode) {
case "pl":
if (i == 1) return "one";
if (i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 12 || i % 100 > 14)) {
return "few";
}
return "many";
case "ru":
case "uk":
case "be":
if (i % 10 == 1 && i % 100 != 11) return "one";
if (i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 12 || i % 100 > 14)) {
return "few";
}
return "many";
case "cs":
if (i == 1) return "one";
if (i >= 2 && i <= 4) return "few";
return "other";
case "ar":
if (i == 0) return "zero";
if (i == 1) return "one";
if (i == 2) return "two";
if (i % 100 >= 3 && i % 100 <= 10) return "few";
if (i % 100 >= 11) return "many";
return "other";
case "fr":
case "fa":
if (i == 0 || i == 1) return "one";
return "other";
default:
// en, de, it, tr, es, mn and others: one (n=1), other
return i == 1 ? "one" : "other";
}
}

static String getTransalation(String? key, {dynamic replace}) {
if (key == null) return "";
if (_localizedValues.isEmpty) return "";
Expand All @@ -64,10 +107,19 @@ class FlowLocalizations {
RegExp(r"{[^}]*}"),
singleValue,
),
num singleValue => translatedText.replaceAll(
RegExp(r"{[^}]*}"),
singleValue.toString(),
),
num singleValue => () {
String text = translatedText;
final String? langCode = _currentLocale?.languageCode;
if (langCode != null) {
final String category = _pluralCategory(singleValue, langCode);
final String? pluralText =
_localizedValues["$key.$category"] ?? _enUS["$key.$category"];
if (pluralText != null) {
text = pluralText;
}
}
return text.replaceAll(RegExp(r"{[^}]*}"), singleValue.toString());
}(),
Map lookupTable => _fillFromTable(lookupTable, translatedText),
_ => translatedText,
};
Expand Down
Loading
Loading