Skip to content

Commit

Permalink
Merge pull request #108 from enrique-lozano/fix/currency-names-i18n
Browse files Browse the repository at this point in the history
Currency names always in spanish
  • Loading branch information
enrique-lozano authored Jan 24, 2024
2 parents a424ce6 + 22ba66e commit cb2429f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/core/database/services/currency/currency_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:drift/drift.dart';
import 'package:monekin/core/database/app_db.dart';
import 'package:monekin/core/database/services/user-setting/user_setting_service.dart';
import 'package:monekin/core/models/currency/currency.dart';
import 'package:monekin/i18n/translations.g.dart';

class CurrencyService {
final _currencyTableName = 'currencies';
Expand All @@ -10,7 +11,7 @@ class CurrencyService {
// TODO: i18n

String get _baseQuery =>
'SELECT currency.code, currency.symbol, names.es as name FROM $_currencyTableName as currency'
'SELECT currency.code, currency.symbol, names.${LocaleSettings.currentLocale.languageCode} as name FROM $_currencyTableName as currency'
' JOIN $_currencyNamesTableName as names ON currency.code = names.currencyCode';

final AppDB db;
Expand Down Expand Up @@ -54,7 +55,7 @@ class CurrencyService {
toSearch = '%${toSearch.trim()}%';

return (db.customSelect(
'$_baseQuery WHERE currency.code LIKE ? OR names.es LIKE ?',
'$_baseQuery WHERE currency.code LIKE ? OR names.${LocaleSettings.currentLocale.languageCode} LIKE ?',
variables: [
Variable.withString(toSearch),
Variable.withString(toSearch)
Expand Down

0 comments on commit cb2429f

Please sign in to comment.