Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: formatted string for better translation #2025

Merged
merged 1 commit into from
Dec 28, 2024
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
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
Loading