Skip to content

Commit

Permalink
Merge pull request #2025 from wolfsolver/lang-improvement
Browse files Browse the repository at this point in the history
i18n: formatted string for better transation
  • Loading branch information
guanlisheng authored Dec 28, 2024
2 parents e39fc31 + f96802c commit dc44df0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import androidx.cursoradapter.widget.CursorAdapter;
import info.javaperformance.money.Money;
import info.javaperformance.money.MoneyFactory;
import timber.log.Timber;

/**
* Adapter for all_data query. The list of transactions (account/recurring).
Expand Down Expand Up @@ -392,8 +393,10 @@ private void displayBalanceAmountOrDaysLeft(AllDataViewHolder holder, Cursor cur
if (daysLeft == 0) {
holder.txtBalance.setText(R.string.due_today);
} else {
holder.txtBalance.setText(Math.abs(daysLeft) + " " +
context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue));
boolean hasNumber = context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue).indexOf("%d") >= 0;
holder.txtBalance.setText(
String.format((hasNumber ? context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue) : "%d " + context.getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue)),
Math.abs(daysLeft)));
}
holder.txtBalance.setVisibility(View.VISIBLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ private View showTableLayoutUpComingTransactions(Cursor cursor) {
int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT));
long currencyId = cursor.getLong(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID));
String daysLeftText = "";
daysLeftText = Math.abs(daysLeft) + " " + getString(daysLeft >= 0 ? R.string.days_remaining : R.string.days_overdue);
boolean hasNumber = getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue).indexOf("%d") >= 0;
daysLeftText = String.format( (hasNumber ? getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue) : "%d " + getString(daysLeft > 0 ? R.string.days_remaining : R.string.days_overdue) ),
Math.abs(daysLeft));

TableRow row = createTableRow(new String[]{"<small>" + payee + "</small>",
"<small>" + currencyService.getCurrencyFormatted(currencyId, MoneyFactory.fromDouble(total)) + "</small>",
"<small>" + daysLeftText + "</small>"}, new Float[]{1f, null, 1f},
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@
<string name="repeating_empty_transaction">Non sono state trovate transazioni pianificate. Per crearne una, toccare il pulsante verde più.</string>
<string name="inactive">Inattivo</string>
<string name="activates">Attiva</string>
<string name="days_overdue">giorni scaduti!</string>
<string name="days_remaining">giorni rimanenti</string>
<string name="days_overdue">Scaduta da %d giorni!</string>
<string name="days_remaining">%d giorni rimanenti</string>
<string name="new_edit_repeating_transaction">Aggiungi/Modifica Transazione Pianificata</string>
<string name="due_date">Scadenza</string>
<string name="next_occurrence">Prossima Scadenza</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@
<string name="repeating_empty_transaction">No scheduled transactions have been found. To create one, tap the green plus button.</string>
<string name="inactive">Inactive</string>
<string name="activates">Activates</string>
<string name="days_overdue">days overdue!</string>
<string name="days_remaining">days remaining</string>
<string name="days_overdue">%d days overdue!</string>
<string name="days_remaining">%d days remaining</string>
<string name="new_edit_repeating_transaction">New/Edit Scheduled Transaction</string>
<string name="due_date">Due Date</string>
<string name="next_occurrence">Next Occurrence</string>
Expand Down

0 comments on commit dc44df0

Please sign in to comment.