mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-02 15:53:55 +01:00
Plural fixes
This commit is contained in:
parent
294f086d07
commit
e883b147e3
6 changed files with 32 additions and 43 deletions
|
|
@ -416,7 +416,7 @@ public class OkHttpJsonApiClient {
|
|||
final String wikidataQuery = FileUtils.readFromResource("/queries/query_for_item.rq");
|
||||
|
||||
// Split the secondary languages string into an array to use in fallback queries
|
||||
final String[] secondaryLanguageArray = secondaryLanguages.split(",\\s*");
|
||||
final String[] secondaryLanguagesArray = secondaryLanguages.split(",\\s*");
|
||||
|
||||
// Prepare the Wikidata entity IDs (QIDs) for each place in the list
|
||||
String qids = "";
|
||||
|
|
@ -426,37 +426,37 @@ public class OkHttpJsonApiClient {
|
|||
|
||||
// Build fallback descriptions for secondary languages in case the primary language is unavailable
|
||||
StringBuilder fallBackDescription = new StringBuilder();
|
||||
for (int i = 0; i < secondaryLanguageArray.length; i++) {
|
||||
for (int i = 0; i < secondaryLanguagesArray.length; i++) {
|
||||
fallBackDescription.append("OPTIONAL {?item schema:description ?itemDescriptionPreferredLanguage_")
|
||||
.append(i + 1) // Unique identifier for each fallback
|
||||
.append(". FILTER (lang(?itemDescriptionPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(") = \"")
|
||||
.append(secondaryLanguageArray[i]) // Use the secondary language code
|
||||
.append(secondaryLanguagesArray[i]) // Use the secondary language code
|
||||
.append("\")}\n");
|
||||
}
|
||||
|
||||
// Build fallback labels for secondary languages
|
||||
StringBuilder fallbackLabel = new StringBuilder();
|
||||
for (int i = 0; i < secondaryLanguageArray.length; i++) {
|
||||
for (int i = 0; i < secondaryLanguagesArray.length; i++) {
|
||||
fallbackLabel.append("OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(". FILTER (lang(?itemLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(") = \"")
|
||||
.append(secondaryLanguageArray[i])
|
||||
.append(secondaryLanguagesArray[i])
|
||||
.append("\")}\n");
|
||||
}
|
||||
|
||||
// Build fallback class labels for secondary languages
|
||||
StringBuilder fallbackClassLabel = new StringBuilder();
|
||||
for (int i = 0; i < secondaryLanguageArray.length; i++) {
|
||||
for (int i = 0; i < secondaryLanguagesArray.length; i++) {
|
||||
fallbackClassLabel.append("OPTIONAL {?class rdfs:label ?classLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(". FILTER (lang(?classLabelPreferredLanguage_")
|
||||
.append(i + 1)
|
||||
.append(") = \"")
|
||||
.append(secondaryLanguageArray[i])
|
||||
.append(secondaryLanguagesArray[i])
|
||||
.append("\")}\n");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public class Prefs {
|
|||
public static final String UPLOADS_SHOWING = "uploadsshowing";
|
||||
public static final String MANAGED_EXIF_TAGS = "managed_exif_tags";
|
||||
public static final String DESCRIPTION_LANGUAGE = "languageDescription";
|
||||
public static final String SECONDARY_LANGUAGE = "languageSecondary";
|
||||
public static final String SECONDARY_LANGUAGES = "languageSecondary";
|
||||
|
||||
public static final String APP_UI_LANGUAGE = "appUiLanguage";
|
||||
public static final String KEY_THEME_VALUE = "appThemePref";
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import android.widget.EditText;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ArrayAdapter;
|
||||
import androidx.activity.result.ActivityResultCallback;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
|
|
@ -84,7 +83,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
|
||||
private ListPreference themeListPreference;
|
||||
private Preference descriptionLanguageListPreference;
|
||||
private Preference descriptionSecondaryLanguageListPreference;
|
||||
private Preference descriptionSecondaryLanguagesListPreference;
|
||||
private Preference appUiLanguageListPreference;
|
||||
private String keyLanguageListPreference;
|
||||
private TextView recentLanguagesTextView;
|
||||
|
|
@ -185,17 +184,17 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
});
|
||||
|
||||
|
||||
descriptionSecondaryLanguageListPreference = findPreference("descriptionSecondaryLanguagePref");
|
||||
assert descriptionSecondaryLanguageListPreference != null;
|
||||
keyLanguageListPreference = descriptionSecondaryLanguageListPreference.getKey();
|
||||
descriptionSecondaryLanguagesListPreference = findPreference("descriptionSecondaryLanguagesPref");
|
||||
assert descriptionSecondaryLanguagesListPreference != null;
|
||||
keyLanguageListPreference = descriptionSecondaryLanguagesListPreference.getKey();
|
||||
languageCode = getCurrentLanguageCode(keyLanguageListPreference);
|
||||
assert languageCode != null;
|
||||
descriptionSecondaryLanguageListPreference.setSummary("List additional languages.");
|
||||
descriptionSecondaryLanguagesListPreference.setSummary("List additional languages.");
|
||||
|
||||
descriptionSecondaryLanguageListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
descriptionSecondaryLanguagesListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
prepareSecondaryLanguageDialog();
|
||||
prepareSecondaryLanguagesDialog();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
@ -227,7 +226,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
findPreference("useAuthorName").setEnabled(false);
|
||||
findPreference("displayNearbyCardView").setEnabled(false);
|
||||
findPreference("descriptionDefaultLanguagePref").setEnabled(false);
|
||||
findPreference("descriptionSecondaryLanguagePref").setEnabled(false);
|
||||
findPreference("descriptionSecondaryLanguagesPref").setEnabled(false);
|
||||
findPreference("displayLocationPermissionForCardView").setEnabled(false);
|
||||
findPreference(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE).setEnabled(false);
|
||||
findPreference("managed_exif_tags").setEnabled(false);
|
||||
|
|
@ -331,8 +330,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
* Disable default/already selected language from dialog box
|
||||
* Saves values chosen by user to shared preferences as a serialised string.
|
||||
*/
|
||||
private void prepareSecondaryLanguageDialog() {
|
||||
final String languageCode = getCurrentLanguageCode("descriptionSecondaryLanguagePref");
|
||||
private void prepareSecondaryLanguagesDialog() {
|
||||
final String languageCode = getCurrentLanguageCode("descriptionSecondaryLanguagesPref");
|
||||
HashMap<Integer, String> selectedLanguages = new HashMap<>();
|
||||
assert languageCode != null;
|
||||
selectedLanguages.put(0, Locale.getDefault().getLanguage());
|
||||
|
|
@ -383,8 +382,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
if (!updatedLanguageCodes.isEmpty()) {
|
||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||
}
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
||||
// descriptionSecondaryLanguageListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagePref"));
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagesPref");
|
||||
// descriptionSecondaryLanguagesListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagesPref"));
|
||||
});
|
||||
|
||||
// Set up the adapter for new languages using the selectedLanguages map
|
||||
|
|
@ -413,7 +412,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
String selectedLanguageCode = languagesAdapter.getLanguageCode(i);
|
||||
String selectedLanguageName = languagesAdapter.getLanguageName(i);
|
||||
|
||||
if (deSerialise(getCurrentLanguageCode("descriptionSecondaryLanguagePref")).contains(selectedLanguageCode)) {
|
||||
if (deSerialise(getCurrentLanguageCode("descriptionSecondaryLanguagesPref")).contains(selectedLanguageCode)) {
|
||||
Toast.makeText(getActivity(), "Language already selected", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
|
@ -431,9 +430,9 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||
}
|
||||
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagesPref");
|
||||
|
||||
// descriptionSecondaryLanguageListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagePref"));
|
||||
// descriptionSecondaryLanguagesListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagesPref"));
|
||||
});
|
||||
|
||||
dialog.setOnDismissListener(dialogInterface -> {
|
||||
|
|
@ -446,7 +445,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
if (!updatedLanguageCodes.isEmpty()) {
|
||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||
}
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagesPref");
|
||||
|
||||
});
|
||||
}
|
||||
|
|
@ -488,7 +487,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
} else {
|
||||
selectedLanguages.put(0, languageCode);
|
||||
}
|
||||
} else if (keyListPreference.equals("descriptionSecondaryLanguagePref")) {
|
||||
} else if (keyListPreference.equals("descriptionSecondaryLanguagesPref")) {
|
||||
|
||||
assert languageCode != null;
|
||||
if (languageCode.equals("")) {
|
||||
|
|
@ -692,8 +691,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
defaultKvStore.putString(Prefs.APP_UI_LANGUAGE, userSelectedValue);
|
||||
} else if (preferenceKey.equals("descriptionDefaultLanguagePref")) {
|
||||
defaultKvStore.putString(Prefs.DESCRIPTION_LANGUAGE, userSelectedValue);
|
||||
} else if (preferenceKey.equals("descriptionSecondaryLanguagePref")) {
|
||||
defaultKvStore.putString(Prefs.SECONDARY_LANGUAGE, userSelectedValue);
|
||||
} else if (preferenceKey.equals("descriptionSecondaryLanguagesPref")) {
|
||||
defaultKvStore.putString(Prefs.SECONDARY_LANGUAGES, userSelectedValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -709,8 +708,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
if (preferenceKey.equals("descriptionDefaultLanguagePref")) {
|
||||
return defaultKvStore.getString(Prefs.DESCRIPTION_LANGUAGE, "");
|
||||
}
|
||||
if (preferenceKey.equals("descriptionSecondaryLanguagePref")) {
|
||||
return defaultKvStore.getString(Prefs.SECONDARY_LANGUAGE, "");
|
||||
if (preferenceKey.equals("descriptionSecondaryLanguagesPref")) {
|
||||
return defaultKvStore.getString(Prefs.SECONDARY_LANGUAGES, "");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,16 +26,6 @@
|
|||
<item>@string/exif_tag_name_software</item>
|
||||
</array>
|
||||
|
||||
<array name="default_languages">
|
||||
<item>@string/exif_tag_name_author</item>
|
||||
<item>@string/exif_tag_name_copyright</item>
|
||||
<item>@string/exif_tag_name_location</item>
|
||||
<item>@string/exif_tag_name_cameraModel</item>
|
||||
<item>@string/exif_tag_name_lensModel</item>
|
||||
<item>@string/exif_tag_name_serialNumbers</item>
|
||||
<item>@string/exif_tag_name_software</item>
|
||||
</array>
|
||||
|
||||
<array name="pref_exifTag_values">
|
||||
<item>@string/exif_tag_author</item>
|
||||
<item>@string/exif_tag_copyright</item>
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ Upload your first media by tapping on the add button.</string>
|
|||
<string name="dialog_box_text_nomination">Why should %1$s be deleted?</string>
|
||||
<string name="review_is_uploaded_by">%1$s is uploaded by: %2$s</string>
|
||||
<string name="default_description_language">Default description language</string>
|
||||
<string name="secondary_description_language">Secondary Description Language</string>
|
||||
<string name="secondary_description_languages">Secondary Description Language</string>
|
||||
<string name="delete_helper_show_deletion_title">Nominating for deletion</string>
|
||||
<string name="delete_helper_show_deletion_title_success">Success</string>
|
||||
<string name="delete_helper_show_deletion_message_if">Nominated %1$s for deletion.</string>
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
|
||||
<!-- New Secondary Language Picker -->
|
||||
<Preference
|
||||
android:key="descriptionSecondaryLanguagePref"
|
||||
android:key="descriptionSecondaryLanguagesPref"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
app:singleLineTitle="false"
|
||||
android:title="@string/secondary_description_language" />
|
||||
android:title="@string/secondary_description_languages" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue