]> git.ktnx.net Git - mobile-ledger.git/commitdiff
translatable text for template element value from the pattern
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 13 Feb 2021 16:24:04 +0000 (18:24 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 07:19:43 +0000 (07:19 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java
app/src/main/res/values-bg/strings.xml
app/src/main/res/values/strings.xml

index e472049b1e5762f0a5f1ab75968d16b5b282842e..1f371f35766b833e73965abe6833a7a72e06c891 100644 (file)
@@ -334,6 +334,10 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             TemplateDetailsItem.Header header = item.asHeaderItem();
             Logger.debug(D_TEMPLATE_UI, "Binding to header " + header);
 
+            String groupNoText = b.getRoot()
+                                  .getResources()
+                                  .getString(R.string.template_item_match_group_source);
+
             b.templateName.setText(header.getName());
             b.pattern.setText(header.getPattern());
             b.testText.setText(header.getTestText());
@@ -348,12 +352,13 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             else {
                 b.templateDetailsDateYearLayout.setVisibility(View.GONE);
                 b.templateDetailsYearSource.setText(
-                        String.format(Locale.US, "Group %d (%s)", header.getDateYearMatchGroup(),
+                        String.format(Locale.US, groupNoText, header.getDateYearMatchGroup(),
                                 getMatchGroupText(header.getDateYearMatchGroup())));
             }
-            b.templateDetailsYearSourceLabel.setOnClickListener(v -> selectHeaderDetailSource(v, HeaderDetail.DATE_YEAR));
-            b.templateDetailsYearSource.setOnClickListener(v -> selectHeaderDetailSource(v,
-                    HeaderDetail.DATE_YEAR));
+            b.templateDetailsYearSourceLabel.setOnClickListener(
+                    v -> selectHeaderDetailSource(v, HeaderDetail.DATE_YEAR));
+            b.templateDetailsYearSource.setOnClickListener(
+                    v -> selectHeaderDetailSource(v, HeaderDetail.DATE_YEAR));
 
             if (header.hasLiteralDateMonth()) {
                 b.templateDetailsMonthSource.setText(R.string.template_details_source_literal);
@@ -365,7 +370,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             else {
                 b.templateDetailsDateMonthLayout.setVisibility(View.GONE);
                 b.templateDetailsMonthSource.setText(
-                        String.format(Locale.US, "Group %d (%s)", header.getDateMonthMatchGroup(),
+                        String.format(Locale.US, groupNoText, header.getDateMonthMatchGroup(),
                                 getMatchGroupText(header.getDateMonthMatchGroup())));
             }
             b.templateDetailsMonthSourceLabel.setOnClickListener(v -> selectHeaderDetailSource(v,
@@ -382,7 +387,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             else {
                 b.templateDetailsDateDayLayout.setVisibility(View.GONE);
                 b.templateDetailsDaySource.setText(
-                        String.format(Locale.US, "Group %d (%s)", header.getDateDayMatchGroup(),
+                        String.format(Locale.US, groupNoText, header.getDateDayMatchGroup(),
                                 getMatchGroupText(header.getDateDayMatchGroup())));
             }
             b.templateDetailsDaySourceLabel.setOnClickListener(v -> selectHeaderDetailSource(v, HeaderDetail.DATE_DAY));
@@ -395,9 +400,9 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             }
             else {
                 b.transactionDescriptionLayout.setVisibility(View.GONE);
-                b.templateTransactionDescriptionSource.setText(
-                        String.format(Locale.US, "Group %d (%s)",
-                                header.getTransactionDescriptionMatchGroup(), getMatchGroupText(header.getTransactionDescriptionMatchGroup())));
+                b.templateTransactionDescriptionSource.setText(String.format(Locale.US, groupNoText,
+                        header.getTransactionDescriptionMatchGroup(),
+                        getMatchGroupText(header.getTransactionDescriptionMatchGroup())));
 
             }
             b.templateTransactionDescriptionSourceLabel.setOnClickListener(v -> selectHeaderDetailSource(v, HeaderDetail.DESCRIPTION));
@@ -410,7 +415,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             }
             else {
                 b.transactionCommentLayout.setVisibility(View.GONE);
-                b.templateTransactionCommentSource.setText(String.format(Locale.US, "Group %d (%s)",
+                b.templateTransactionCommentSource.setText(String.format(Locale.US, groupNoText,
                         header.getTransactionCommentMatchGroup(),
                         getMatchGroupText(header.getTransactionCommentMatchGroup())));
 
@@ -542,6 +547,10 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
         }
         @Override
         void bind(TemplateDetailsItem item) {
+            String groupNoText = b.getRoot()
+                                  .getResources()
+                                  .getString(R.string.template_item_match_group_source);
+
             TemplateDetailsItem.AccountRow accRow = item.asAccountRowItem();
             if (accRow.hasLiteralAccountName()) {
                 b.templateDetailsAccountNameLayout.setVisibility(View.VISIBLE);
@@ -552,7 +561,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             else {
                 b.templateDetailsAccountNameLayout.setVisibility(View.GONE);
                 b.templateDetailsAccountNameSource.setText(
-                        String.format(Locale.US, "Group %d (%s)", accRow.getAccountNameMatchGroup(),
+                        String.format(Locale.US, groupNoText, accRow.getAccountNameMatchGroup(),
                                 getMatchGroupText(accRow.getAccountNameMatchGroup())));
             }
 
@@ -565,8 +574,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             else {
                 b.templateDetailsAccountCommentLayout.setVisibility(View.GONE);
                 b.templateDetailsAccountCommentSource.setText(
-                        String.format(Locale.US, "Group %d (%s)",
-                                accRow.getAccountCommentMatchGroup(),
+                        String.format(Locale.US, groupNoText, accRow.getAccountCommentMatchGroup(),
                                 getMatchGroupText(accRow.getAccountCommentMatchGroup())));
             }
 
@@ -581,7 +589,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             }
             else {
                 b.templateDetailsAccountAmountSource.setText(
-                        String.format(Locale.US, "Group %d (%s)", accRow.getAmountMatchGroup(),
+                        String.format(Locale.US, groupNoText, accRow.getAmountMatchGroup(),
                                 getMatchGroupText(accRow.getAmountMatchGroup())));
                 b.templateDetailsAccountAmountLayout.setVisibility(View.GONE);
                 b.negateAmountSwitch.setVisibility(View.VISIBLE);
index 48faa15b36d28bad48ba23bd6a48277bd7aeb611..c2df39b439dfc3f33a181d43fde59eb7604a87af 100644 (file)
     <string name="template_xxx_deleted">Макетът „%1$s“ е изтрит</string>
     <string name="action_undo">Връщане</string>
     <string name="pattern_match_result">Резултат от прилагането на шаблона</string>
+    <string name="template_item_match_group_source">Група %1$d (%2$s)</string>
 </resources>
index 6c812855a8ce7e4b5b40b853b0c5812b642eb271..9536e3bcdca0fb48d7db3cb04463b757f749bc45 100644 (file)
     <string name="template_xxx_deleted">Template \'%1$s\' deleted</string>
     <string name="action_undo">Undo</string>
     <string name="pattern_match_result">Pattern match result</string>
+    <string name="template_item_match_group_source">Group %1$d (%2$s)</string>
 </resources>