Skip to content

Commit db38174

Browse files
zhao-gangdomdomegg
authored andcommitted
Fix commons-app#2156: Add plural support for share_license_summary string (commons-app#2161)
1 parent 1d80cba commit db38174

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,14 @@ public void updateLicenses(List<String> licenses, String selectedLicense) {
252252

253253
@SuppressLint("StringFormatInvalid")
254254
@Override
255-
public void updateLicenseSummary(String selectedLicense) {
255+
public void updateLicenseSummary(String selectedLicense, int imageCount) {
256256
String licenseHyperLink = "<a href='" + Utils.licenseUrlFor(selectedLicense)+"'>" +
257257
getString(Utils.licenseNameFor(selectedLicense)) + "</a><br>";
258258
licenseSummary.setMovementMethod(LinkMovementMethod.getInstance());
259259
licenseSummary.setText(
260260
Html.fromHtml(
261-
getString(R.string.share_license_summary, licenseHyperLink)));
261+
getResources().getQuantityString(R.plurals.share_license_summary,
262+
imageCount, licenseHyperLink)));
262263
}
263264

264265
@Override

app/src/main/java/fr/free/nrw/commons/upload/UploadPresenter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void receiveDirect(Uri media, String mimeType, @Contribution.FileSource String s
112112
*/
113113
void selectLicense(String licenseName) {
114114
uploadModel.setSelectedLicense(licenseName);
115-
view.updateLicenseSummary(uploadModel.getSelectedLicense());
115+
view.updateLicenseSummary(uploadModel.getSelectedLicense(), uploadModel.getCount());
116116
}
117117

118118
//region Wizard step management
@@ -357,7 +357,7 @@ private void updateCards() {
357357
private void updateLicenses() {
358358
String selectedLicense = uploadModel.getSelectedLicense();
359359
view.updateLicenses(uploadModel.getLicenses(), selectedLicense);
360-
view.updateLicenseSummary(selectedLicense);
360+
view.updateLicenseSummary(selectedLicense, uploadModel.getCount());
361361
}
362362

363363
/**

app/src/main/java/fr/free/nrw/commons/upload/UploadView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public interface UploadView {
6060

6161
void updateLicenses(List<String> licenses, String selectedLicense);
6262

63-
void updateLicenseSummary(String selectedLicense);
63+
void updateLicenseSummary(String selectedLicense, int imageCount);
6464

6565
void updateTopCardContent();
6666

app/src/main/res/layout/activity_upload_license.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
android:layout_marginEnd="@dimen/standard_gap"
6363
android:layout_marginRight="@dimen/standard_gap"
6464
android:layout_below="@id/license_list"
65-
android:text="@string/share_license_summary" />
65+
android:text="@plurals/share_license_summary" />
6666

6767
<fr.free.nrw.commons.ui.widget.HtmlTextView
6868
android:id="@+id/media_upload_policy"

app/src/main/res/layout/fragment_single_upload.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
android:layout_marginTop="@dimen/standard_gap"
8888
android:clickable="true"
8989
android:gravity="center"
90-
android:text="@string/share_license_summary"
90+
android:text="@plurals/share_license_summary"
9191
android:textColorLink="@color/button_blue" />
9292

9393
<fr.free.nrw.commons.ui.widget.HtmlTextView

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@
101101
<string name="no_uploads_yet">You have not yet uploaded any photos.</string>
102102
<string name="menu_retry_upload">Retry</string>
103103
<string name="menu_cancel_upload">Cancel</string>
104-
<string name="share_license_summary">This image will be licensed under %1$s</string>
104+
<plurals name="share_license_summary">
105+
<item quantity="one">This image will be licensed under %1$s</item>
106+
<item quantity="other">These images will be licensed under %1$s</item>
107+
</plurals>
105108
<string name="media_upload_policy">By submitting this picture, I declare that this is my own work, that it does not contain copyrighted material or selfies, and otherwise adheres to &lt;a href=\"https://commons.wikimedia.org/wiki/Commons:Policies_and_guidelines\"&gt;Wikimedia Commons policies&lt;/a&gt;.</string>
106109
<string name="menu_download">Download</string>
107110
<string name="preference_license">Default License</string>

0 commit comments

Comments
 (0)