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");
|
final String wikidataQuery = FileUtils.readFromResource("/queries/query_for_item.rq");
|
||||||
|
|
||||||
// Split the secondary languages string into an array to use in fallback queries
|
// 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
|
// Prepare the Wikidata entity IDs (QIDs) for each place in the list
|
||||||
String qids = "";
|
String qids = "";
|
||||||
|
|
@ -426,37 +426,37 @@ public class OkHttpJsonApiClient {
|
||||||
|
|
||||||
// Build fallback descriptions for secondary languages in case the primary language is unavailable
|
// Build fallback descriptions for secondary languages in case the primary language is unavailable
|
||||||
StringBuilder fallBackDescription = new StringBuilder();
|
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_")
|
fallBackDescription.append("OPTIONAL {?item schema:description ?itemDescriptionPreferredLanguage_")
|
||||||
.append(i + 1) // Unique identifier for each fallback
|
.append(i + 1) // Unique identifier for each fallback
|
||||||
.append(". FILTER (lang(?itemDescriptionPreferredLanguage_")
|
.append(". FILTER (lang(?itemDescriptionPreferredLanguage_")
|
||||||
.append(i + 1)
|
.append(i + 1)
|
||||||
.append(") = \"")
|
.append(") = \"")
|
||||||
.append(secondaryLanguageArray[i]) // Use the secondary language code
|
.append(secondaryLanguagesArray[i]) // Use the secondary language code
|
||||||
.append("\")}\n");
|
.append("\")}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build fallback labels for secondary languages
|
// Build fallback labels for secondary languages
|
||||||
StringBuilder fallbackLabel = new StringBuilder();
|
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_")
|
fallbackLabel.append("OPTIONAL {?item rdfs:label ?itemLabelPreferredLanguage_")
|
||||||
.append(i + 1)
|
.append(i + 1)
|
||||||
.append(". FILTER (lang(?itemLabelPreferredLanguage_")
|
.append(". FILTER (lang(?itemLabelPreferredLanguage_")
|
||||||
.append(i + 1)
|
.append(i + 1)
|
||||||
.append(") = \"")
|
.append(") = \"")
|
||||||
.append(secondaryLanguageArray[i])
|
.append(secondaryLanguagesArray[i])
|
||||||
.append("\")}\n");
|
.append("\")}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build fallback class labels for secondary languages
|
// Build fallback class labels for secondary languages
|
||||||
StringBuilder fallbackClassLabel = new StringBuilder();
|
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_")
|
fallbackClassLabel.append("OPTIONAL {?class rdfs:label ?classLabelPreferredLanguage_")
|
||||||
.append(i + 1)
|
.append(i + 1)
|
||||||
.append(". FILTER (lang(?classLabelPreferredLanguage_")
|
.append(". FILTER (lang(?classLabelPreferredLanguage_")
|
||||||
.append(i + 1)
|
.append(i + 1)
|
||||||
.append(") = \"")
|
.append(") = \"")
|
||||||
.append(secondaryLanguageArray[i])
|
.append(secondaryLanguagesArray[i])
|
||||||
.append("\")}\n");
|
.append("\")}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ public class Prefs {
|
||||||
public static final String UPLOADS_SHOWING = "uploadsshowing";
|
public static final String UPLOADS_SHOWING = "uploadsshowing";
|
||||||
public static final String MANAGED_EXIF_TAGS = "managed_exif_tags";
|
public static final String MANAGED_EXIF_TAGS = "managed_exif_tags";
|
||||||
public static final String DESCRIPTION_LANGUAGE = "languageDescription";
|
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 APP_UI_LANGUAGE = "appUiLanguage";
|
||||||
public static final String KEY_THEME_VALUE = "appThemePref";
|
public static final String KEY_THEME_VALUE = "appThemePref";
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import androidx.activity.result.ActivityResultCallback;
|
import androidx.activity.result.ActivityResultCallback;
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
|
@ -84,7 +83,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
private ListPreference themeListPreference;
|
private ListPreference themeListPreference;
|
||||||
private Preference descriptionLanguageListPreference;
|
private Preference descriptionLanguageListPreference;
|
||||||
private Preference descriptionSecondaryLanguageListPreference;
|
private Preference descriptionSecondaryLanguagesListPreference;
|
||||||
private Preference appUiLanguageListPreference;
|
private Preference appUiLanguageListPreference;
|
||||||
private String keyLanguageListPreference;
|
private String keyLanguageListPreference;
|
||||||
private TextView recentLanguagesTextView;
|
private TextView recentLanguagesTextView;
|
||||||
|
|
@ -185,17 +184,17 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
descriptionSecondaryLanguageListPreference = findPreference("descriptionSecondaryLanguagePref");
|
descriptionSecondaryLanguagesListPreference = findPreference("descriptionSecondaryLanguagesPref");
|
||||||
assert descriptionSecondaryLanguageListPreference != null;
|
assert descriptionSecondaryLanguagesListPreference != null;
|
||||||
keyLanguageListPreference = descriptionSecondaryLanguageListPreference.getKey();
|
keyLanguageListPreference = descriptionSecondaryLanguagesListPreference.getKey();
|
||||||
languageCode = getCurrentLanguageCode(keyLanguageListPreference);
|
languageCode = getCurrentLanguageCode(keyLanguageListPreference);
|
||||||
assert languageCode != null;
|
assert languageCode != null;
|
||||||
descriptionSecondaryLanguageListPreference.setSummary("List additional languages.");
|
descriptionSecondaryLanguagesListPreference.setSummary("List additional languages.");
|
||||||
|
|
||||||
descriptionSecondaryLanguageListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
descriptionSecondaryLanguagesListPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
prepareSecondaryLanguageDialog();
|
prepareSecondaryLanguagesDialog();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -227,7 +226,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
findPreference("useAuthorName").setEnabled(false);
|
findPreference("useAuthorName").setEnabled(false);
|
||||||
findPreference("displayNearbyCardView").setEnabled(false);
|
findPreference("displayNearbyCardView").setEnabled(false);
|
||||||
findPreference("descriptionDefaultLanguagePref").setEnabled(false);
|
findPreference("descriptionDefaultLanguagePref").setEnabled(false);
|
||||||
findPreference("descriptionSecondaryLanguagePref").setEnabled(false);
|
findPreference("descriptionSecondaryLanguagesPref").setEnabled(false);
|
||||||
findPreference("displayLocationPermissionForCardView").setEnabled(false);
|
findPreference("displayLocationPermissionForCardView").setEnabled(false);
|
||||||
findPreference(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE).setEnabled(false);
|
findPreference(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE).setEnabled(false);
|
||||||
findPreference("managed_exif_tags").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
|
* Disable default/already selected language from dialog box
|
||||||
* Saves values chosen by user to shared preferences as a serialised string.
|
* Saves values chosen by user to shared preferences as a serialised string.
|
||||||
*/
|
*/
|
||||||
private void prepareSecondaryLanguageDialog() {
|
private void prepareSecondaryLanguagesDialog() {
|
||||||
final String languageCode = getCurrentLanguageCode("descriptionSecondaryLanguagePref");
|
final String languageCode = getCurrentLanguageCode("descriptionSecondaryLanguagesPref");
|
||||||
HashMap<Integer, String> selectedLanguages = new HashMap<>();
|
HashMap<Integer, String> selectedLanguages = new HashMap<>();
|
||||||
assert languageCode != null;
|
assert languageCode != null;
|
||||||
selectedLanguages.put(0, Locale.getDefault().getLanguage());
|
selectedLanguages.put(0, Locale.getDefault().getLanguage());
|
||||||
|
|
@ -383,8 +382,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
if (!updatedLanguageCodes.isEmpty()) {
|
if (!updatedLanguageCodes.isEmpty()) {
|
||||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||||
}
|
}
|
||||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagesPref");
|
||||||
// descriptionSecondaryLanguageListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagePref"));
|
// descriptionSecondaryLanguagesListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagesPref"));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set up the adapter for new languages using the selectedLanguages map
|
// 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 selectedLanguageCode = languagesAdapter.getLanguageCode(i);
|
||||||
String selectedLanguageName = languagesAdapter.getLanguageName(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();
|
Toast.makeText(getActivity(), "Language already selected", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -431,9 +430,9 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagesPref");
|
||||||
|
|
||||||
// descriptionSecondaryLanguageListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagePref"));
|
// descriptionSecondaryLanguagesListPreference.setSummary(getCurrentLanguageCode("descriptionSecondaryLanguagesPref"));
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.setOnDismissListener(dialogInterface -> {
|
dialog.setOnDismissListener(dialogInterface -> {
|
||||||
|
|
@ -446,7 +445,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
if (!updatedLanguageCodes.isEmpty()) {
|
if (!updatedLanguageCodes.isEmpty()) {
|
||||||
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
updatedLanguageCodes = updatedLanguageCodes.substring(0, updatedLanguageCodes.length() - 2);
|
||||||
}
|
}
|
||||||
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagePref");
|
saveLanguageValue(updatedLanguageCodes, "descriptionSecondaryLanguagesPref");
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -488,7 +487,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
} else {
|
} else {
|
||||||
selectedLanguages.put(0, languageCode);
|
selectedLanguages.put(0, languageCode);
|
||||||
}
|
}
|
||||||
} else if (keyListPreference.equals("descriptionSecondaryLanguagePref")) {
|
} else if (keyListPreference.equals("descriptionSecondaryLanguagesPref")) {
|
||||||
|
|
||||||
assert languageCode != null;
|
assert languageCode != null;
|
||||||
if (languageCode.equals("")) {
|
if (languageCode.equals("")) {
|
||||||
|
|
@ -692,8 +691,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
defaultKvStore.putString(Prefs.APP_UI_LANGUAGE, userSelectedValue);
|
defaultKvStore.putString(Prefs.APP_UI_LANGUAGE, userSelectedValue);
|
||||||
} else if (preferenceKey.equals("descriptionDefaultLanguagePref")) {
|
} else if (preferenceKey.equals("descriptionDefaultLanguagePref")) {
|
||||||
defaultKvStore.putString(Prefs.DESCRIPTION_LANGUAGE, userSelectedValue);
|
defaultKvStore.putString(Prefs.DESCRIPTION_LANGUAGE, userSelectedValue);
|
||||||
} else if (preferenceKey.equals("descriptionSecondaryLanguagePref")) {
|
} else if (preferenceKey.equals("descriptionSecondaryLanguagesPref")) {
|
||||||
defaultKvStore.putString(Prefs.SECONDARY_LANGUAGE, userSelectedValue);
|
defaultKvStore.putString(Prefs.SECONDARY_LANGUAGES, userSelectedValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -709,8 +708,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
||||||
if (preferenceKey.equals("descriptionDefaultLanguagePref")) {
|
if (preferenceKey.equals("descriptionDefaultLanguagePref")) {
|
||||||
return defaultKvStore.getString(Prefs.DESCRIPTION_LANGUAGE, "");
|
return defaultKvStore.getString(Prefs.DESCRIPTION_LANGUAGE, "");
|
||||||
}
|
}
|
||||||
if (preferenceKey.equals("descriptionSecondaryLanguagePref")) {
|
if (preferenceKey.equals("descriptionSecondaryLanguagesPref")) {
|
||||||
return defaultKvStore.getString(Prefs.SECONDARY_LANGUAGE, "");
|
return defaultKvStore.getString(Prefs.SECONDARY_LANGUAGES, "");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,6 @@
|
||||||
<item>@string/exif_tag_name_software</item>
|
<item>@string/exif_tag_name_software</item>
|
||||||
</array>
|
</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">
|
<array name="pref_exifTag_values">
|
||||||
<item>@string/exif_tag_author</item>
|
<item>@string/exif_tag_author</item>
|
||||||
<item>@string/exif_tag_copyright</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="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="review_is_uploaded_by">%1$s is uploaded by: %2$s</string>
|
||||||
<string name="default_description_language">Default description language</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">Nominating for deletion</string>
|
||||||
<string name="delete_helper_show_deletion_title_success">Success</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>
|
<string name="delete_helper_show_deletion_message_if">Nominated %1$s for deletion.</string>
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,10 @@
|
||||||
|
|
||||||
<!-- New Secondary Language Picker -->
|
<!-- New Secondary Language Picker -->
|
||||||
<Preference
|
<Preference
|
||||||
android:key="descriptionSecondaryLanguagePref"
|
android:key="descriptionSecondaryLanguagesPref"
|
||||||
app:useSimpleSummaryProvider="true"
|
app:useSimpleSummaryProvider="true"
|
||||||
app:singleLineTitle="false"
|
app:singleLineTitle="false"
|
||||||
android:title="@string/secondary_description_language" />
|
android:title="@string/secondary_description_languages" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue