From f089cd027ebe1dc6088e3d7427e9d1c78352a815 Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 14 Feb 2020 18:19:35 +0100 Subject: [PATCH 1/8] Multiple localization fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the extractor PR, fixes title & description shown in the wrong language. Fixed views / spectators counts possibly in the wrong language Fixed live spectators not showing full count on detail page Fixed LIVE shown on players, it shows translated instead Fixed Videos string in search / three dots not available in Weblate (because it was videos, but there already was a plural string named videos, in Weblate) Subscriber count is always giving the short count. We can't get exact number since this YouTube update: https://support.google.com/youtube/thread/6543166 But only short count (B, M, k), so showing full number, eg for 1.9M: 1,900,000, is wrong because the number could be 1,923,490 or 1,897,789… Added a « sytem default » option to content language and country language selector. It's the one selected by default (not en-GB anymore then), and correspond to the language of the system / country of the system By system I mean phone, tablet, TV… Fixed russian showing - before time ago (eg 19hrs ago) This is a workaround fix, I opened an issue on prettytime library repo. Fixed russian plurals: other was used instead of many for videos and subscribers Fixed seek_duration english only --- app/build.gradle | 2 +- .../fragments/detail/VideoDetailFragment.java | 2 +- .../list/channel/ChannelFragment.java | 2 +- .../holder/StreamInfoItemHolder.java | 2 +- .../settings/VideoAudioSettingsFragment.java | 12 +++++++- .../org/schabi/newpipe/util/Localization.java | 29 ++++++++++++------- .../schabi/newpipe/util/ServiceHelper.java | 2 +- .../activity_player_queue_control.xml | 3 +- .../activity_main_player.xml | 3 +- .../main/res/layout/activity_main_player.xml | 3 +- .../layout/activity_player_queue_control.xml | 3 +- app/src/main/res/layout/player_popup.xml | 3 +- app/src/main/res/values-eo/strings.xml | 2 ++ app/src/main/res/values-ru/strings.xml | 4 +-- app/src/main/res/values/settings_keys.xml | 22 ++++++++------ app/src/main/res/values/strings.xml | 7 ++--- 16 files changed, 59 insertions(+), 42 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 5da8c9ff0..10afbef31 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ dependencies { exclude module: 'support-annotations' }) - implementation 'com.github.TeamNewPipe:NewPipeExtractor:9112a10' + implementation 'com.github.B0pol:NewPipeExtractor:a9c6beec1434f4edd4197fb655e5327bae94cc92' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.23.0' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 3c594bdfa..7dd98003a 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1074,7 +1074,7 @@ public class VideoDetailFragment if (info.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) { videoCountView.setText(Localization.listeningCount(activity, info.getViewCount())); } else if (info.getStreamType().equals(StreamType.LIVE_STREAM)) { - videoCountView.setText(Localization.watchingCount(activity, info.getViewCount())); + videoCountView.setText(Localization.localizeWatchingCount(activity, info.getViewCount())); } else { videoCountView.setText(Localization.localizeViewCount(activity, info.getViewCount())); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index c20ff0fc2..7b7a08a48 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -370,7 +370,7 @@ public class ChannelFragment extends BaseListInfoFragment { headerSubscribersTextView.setVisibility(View.VISIBLE); if (result.getSubscriberCount() >= 0) { - headerSubscribersTextView.setText(Localization.localizeSubscribersCount(activity, result.getSubscriberCount())); + headerSubscribersTextView.setText(Localization.shortSubscriberCount(activity, result.getSubscriberCount())); } else { headerSubscribersTextView.setText(R.string.subscribers_count_not_available); } diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java index c48934d10..1dfbbca3f 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/StreamInfoItemHolder.java @@ -60,7 +60,7 @@ public class StreamInfoItemHolder extends StreamMiniInfoItemHolder { if (infoItem.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) { viewsAndDate = Localization.listeningCount(itemBuilder.getContext(), infoItem.getViewCount()); } else if (infoItem.getStreamType().equals(StreamType.LIVE_STREAM)) { - viewsAndDate = Localization.watchingCount(itemBuilder.getContext(), infoItem.getViewCount()); + viewsAndDate = Localization.shortWatchingCount(itemBuilder.getContext(), infoItem.getViewCount()); } else { viewsAndDate = Localization.shortViewCount(itemBuilder.getContext(), infoItem.getViewCount()); } diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java index 7bb931309..21560ee55 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java @@ -4,9 +4,9 @@ import android.content.SharedPreferences; import android.os.Build; import android.os.Bundle; import android.provider.Settings; -import android.view.View; import androidx.annotation.Nullable; +import androidx.preference.ListPreference; import com.google.android.material.snackbar.Snackbar; @@ -21,6 +21,16 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + String[] durationsDescriptions = getResources().getStringArray(R.array.seek_duration_description); + String[] durationsValues = getResources().getStringArray(R.array.seek_duration_value); + int currentDurationValue; + for (int i = 0; i < durationsDescriptions.length; i++) { + currentDurationValue = Integer.parseInt(durationsValues[i]) / 1000; + durationsDescriptions[i] = String.format(durationsDescriptions[i], currentDurationValue); + } + ListPreference durations = (ListPreference) findPreference(getString(R.string.seek_duration_key)); + durations.setEntries(durationsDescriptions); + listener = (sharedPreferences, s) -> { // on M and above, if user chooses to minimise to popup player on exit and the app doesn't have diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index 6149118cc..b24298f4e 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -48,8 +48,8 @@ import java.util.Locale; public class Localization { - private static PrettyTime prettyTime; private static final String DOT_SEPARATOR = " • "; + private static PrettyTime prettyTime; private Localization() { } @@ -84,6 +84,9 @@ public class Localization { final String contentLanguage = PreferenceManager .getDefaultSharedPreferences(context) .getString(context.getString(R.string.content_language_key), context.getString(R.string.default_language_value)); + if (contentLanguage.equals("system")) { + return org.schabi.newpipe.extractor.localization.Localization.fromLocale(Locale.getDefault()); + } return org.schabi.newpipe.extractor.localization.Localization.fromLocalizationCode(contentLanguage); } @@ -91,6 +94,9 @@ public class Localization { final String contentCountry = PreferenceManager .getDefaultSharedPreferences(context) .getString(context.getString(R.string.content_country_key), context.getString(R.string.default_country_value)); + if (contentCountry.equals("system")) { + return new ContentCountry(Locale.getDefault().getCountry()); + } return new ContentCountry(contentCountry); } @@ -114,8 +120,7 @@ public class Localization { } public static String localizeNumber(Context context, long number) { - Locale locale = getPreferredLocale(context); - NumberFormat nf = NumberFormat.getInstance(locale); + NumberFormat nf = NumberFormat.getInstance(getAppLocale(context)); return nf.format(number); } @@ -132,14 +137,14 @@ public class Localization { return getQuantity(context, R.plurals.views, R.string.no_views, viewCount, localizeNumber(context, viewCount)); } - public static String localizeSubscribersCount(Context context, long subscriberCount) { - return getQuantity(context, R.plurals.subscribers, R.string.no_subscribers, subscriberCount, localizeNumber(context, subscriberCount)); - } - public static String localizeStreamCount(Context context, long streamCount) { return getQuantity(context, R.plurals.videos, R.string.no_videos, streamCount, localizeNumber(context, streamCount)); } + public static String localizeWatchingCount(Context context, long watchingCount) { + return getQuantity(context, R.plurals.watching, R.string.no_one_watching, watchingCount, localizeNumber(context, watchingCount)); + } + public static String shortCount(Context context, long count) { if (count >= 1000000000) { return Long.toString(count / 1000000000) + context.getString(R.string.short_billion); @@ -156,7 +161,7 @@ public class Localization { return getQuantity(context, R.plurals.listening, R.string.no_one_listening, listeningCount, shortCount(context, listeningCount)); } - public static String watchingCount(Context context, long watchingCount) { + public static String shortWatchingCount(Context context, long watchingCount) { return getQuantity(context, R.plurals.watching, R.string.no_one_watching, watchingCount, shortCount(context, watchingCount)); } @@ -215,7 +220,9 @@ public class Localization { } public static String relativeTime(Calendar calendarTime) { - return getPrettyTime().formatUnrounded(calendarTime); + String time = getPrettyTime().formatUnrounded(calendarTime); + return time.startsWith("-") ? time.substring(1) : time; + //workaround fix for russian showing -1 day ago, -19hrs ago… } private static void changeAppLanguage(Locale loc, Resources res) { @@ -226,8 +233,8 @@ public class Localization { } public static Locale getAppLocale(Context context) { - SharedPreferences prefs = androidx.preference.PreferenceManager.getDefaultSharedPreferences(context); - String lang = prefs.getString("app_language_key", "en"); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + String lang = prefs.getString(context.getString(R.string.app_language_key), "en"); Locale loc; if (lang.equals("system")) { loc = Locale.getDefault(); diff --git a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java index 8929cc654..6726e4cfc 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java @@ -44,7 +44,7 @@ public class ServiceHelper { public static String getTranslatedFilterString(String filter, Context c) { switch (filter) { case "all": return c.getString(R.string.all); - case "videos": return c.getString(R.string.videos); + case "videos": return c.getString(R.string.videos_string); case "channels": return c.getString(R.string.channels); case "playlists": return c.getString(R.string.playlists); case "tracks": return c.getString(R.string.tracks); diff --git a/app/src/main/res/layout-land/activity_player_queue_control.xml b/app/src/main/res/layout-land/activity_player_queue_control.xml index 7467a79cf..6468c6784 100644 --- a/app/src/main/res/layout-land/activity_player_queue_control.xml +++ b/app/src/main/res/layout-land/activity_player_queue_control.xml @@ -304,10 +304,9 @@ android:paddingLeft="4dp" android:paddingRight="4dp" android:gravity="center" - android:text="@string/duration_live_button" + android:text="@string/duration_live" android:textAllCaps="true" android:textColor="?attr/colorAccent" - android:maxLength="4" android:background="?attr/selectableItemBackground" android:visibility="gone"/> diff --git a/app/src/main/res/layout-large-land/activity_main_player.xml b/app/src/main/res/layout-large-land/activity_main_player.xml index 98017b132..8e11b99f3 100644 --- a/app/src/main/res/layout-large-land/activity_main_player.xml +++ b/app/src/main/res/layout-large-land/activity_main_player.xml @@ -442,10 +442,9 @@ android:paddingLeft="4dp" android:paddingRight="4dp" android:gravity="center" - android:text="@string/duration_live_button" + android:text="@string/duration_live" android:textAllCaps="true" android:textColor="@android:color/white" - android:maxLength="4" android:visibility="gone" android:background="?attr/selectableItemBackground" tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" /> diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml index ab9eb8a61..804434456 100644 --- a/app/src/main/res/layout/activity_main_player.xml +++ b/app/src/main/res/layout/activity_main_player.xml @@ -440,10 +440,9 @@ android:paddingLeft="4dp" android:paddingRight="4dp" android:gravity="center" - android:text="@string/duration_live_button" + android:text="@string/duration_live" android:textAllCaps="true" android:textColor="@android:color/white" - android:maxLength="4" android:visibility="gone" android:background="?attr/selectableItemBackground" tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" /> diff --git a/app/src/main/res/layout/activity_player_queue_control.xml b/app/src/main/res/layout/activity_player_queue_control.xml index e113075af..d17a7007a 100644 --- a/app/src/main/res/layout/activity_player_queue_control.xml +++ b/app/src/main/res/layout/activity_player_queue_control.xml @@ -154,10 +154,9 @@ android:paddingLeft="4dp" android:paddingRight="4dp" android:gravity="center" - android:text="@string/duration_live_button" + android:text="@string/duration_live" android:textAllCaps="true" android:textColor="?attr/colorAccent" - android:maxLength="4" android:background="?attr/selectableItemBackground" android:visibility="gone"/> diff --git a/app/src/main/res/layout/player_popup.xml b/app/src/main/res/layout/player_popup.xml index 9fbc22145..28c730913 100644 --- a/app/src/main/res/layout/player_popup.xml +++ b/app/src/main/res/layout/player_popup.xml @@ -208,10 +208,9 @@ android:paddingLeft="4dp" android:paddingRight="4dp" android:gravity="center_vertical" - android:text="@string/duration_live_button" + android:text="@string/duration_live" android:textAllCaps="true" android:textColor="@android:color/white" - android:maxLength="4" android:visibility="gone" android:background="?attr/selectableItemBackground" tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" /> diff --git a/app/src/main/res/values-eo/strings.xml b/app/src/main/res/values-eo/strings.xml index 6370c5e0e..469fb9e21 100644 --- a/app/src/main/res/values-eo/strings.xml +++ b/app/src/main/res/values-eo/strings.xml @@ -537,4 +537,6 @@ Forviŝi la historion de elŝutoj Forviŝi elŝutitajn dosierojn %1$s elŝutoj forviŝitaj + Filmetoj + %s sekundoj \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 807351a52..940d2ef2f 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -201,13 +201,13 @@ %s подписчик %s подписчика - %s подписчиков + %s подписчиков Нет просмотров %s просмотр %s просмотра - %s просмотров + %s просмотров Нет видео diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 1a7d61dae..3a4e7c493 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -31,12 +31,12 @@ seek_duration 10000 - 5 seconds - 10 seconds - 15 seconds - 20 seconds - 25 seconds - 30 seconds + @string/dynamic_seek_duration_description + @string/dynamic_seek_duration_description + @string/dynamic_seek_duration_description + @string/dynamic_seek_duration_description + @string/dynamic_seek_duration_description + @string/dynamic_seek_duration_description 5000 @@ -161,8 +161,8 @@ show_comments stream_info_selected_tab show_hold_to_append - en - GB + system + system content_language peertube_instance_setup peertube_selected_instance @@ -267,6 +267,7 @@ + system af az id @@ -346,6 +347,7 @@ ko + @string/system_default Afrikaans Azərbaycan Bahasa Indonesia @@ -427,6 +429,7 @@ + @string/system_default Afghanistan Aland Islands Albania @@ -677,6 +680,7 @@ + system AF AX AL @@ -993,7 +997,7 @@ zh-tw - @string/systems_language + @string/system_default العربية Azərbaycan dili Asturianu diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dab9bde10..622b43bfd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -140,7 +140,6 @@ Age restricted content Show age restricted video. Allowing such material is possible from Settings. LIVE - LIVE Downloads Downloads Error report @@ -149,8 +148,7 @@ Channels Playlist Playlists - Videos - Comments + Videos Tracks Users Events @@ -593,5 +591,6 @@ The Storage Access Framework allows downloads to an external SD card.\nNote: some devices are not compatible Choose an instance App language - System default + System default + %s seconds From 5b541cc9fb4b784ffd7a99e583356d70c8966c9c Mon Sep 17 00:00:00 2001 From: bopol Date: Sat, 15 Feb 2020 14:53:05 +0100 Subject: [PATCH 2/8] resolve merge conflicts --- app/src/main/res/values/settings_keys.xml | 6 +++--- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index e652f24ae..05a7416f0 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -347,7 +347,7 @@ ko - @string/system_default + @string/systems_language Afrikaans Azərbaycan Bahasa Indonesia @@ -429,7 +429,7 @@ - @string/system_default + @string/systems_language Afghanistan Aland Islands Albania @@ -997,7 +997,7 @@ zh-tw - @string/system_default + @string/systems_language العربية Azərbaycan dili Asturianu diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 622b43bfd..a5f1cb345 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -591,6 +591,6 @@ The Storage Access Framework allows downloads to an external SD card.\nNote: some devices are not compatible Choose an instance App language - System default + System default %s seconds From e62e34fd5cef0a265946b99bbb3e020ea6dbf39a Mon Sep 17 00:00:00 2001 From: bopol Date: Sat, 15 Feb 2020 16:29:46 +0100 Subject: [PATCH 3/8] created default_localization_key --- app/build.gradle | 2 +- .../fragments/list/search/SearchFragment.java | 2 +- .../newpipe/settings/VideoAudioSettingsFragment.java | 1 + .../java/org/schabi/newpipe/util/Localization.java | 12 ++++++------ app/src/main/res/values/settings_keys.xml | 10 +++++----- app/src/main/res/xml/content_settings.xml | 6 +++--- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9f23bffcf..77b27f50a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ dependencies { exclude module: 'support-annotations' }) - implementation 'com.github.B0pol:NewPipeExtractor:a9c6beec1434f4edd4197fb655e5327bae94cc92' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:fc9f031' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.23.0' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index f2e8aa244..fcb3eafa7 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -190,7 +190,7 @@ public class SearchFragment SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); isSuggestionsEnabled = preferences.getBoolean(getString(R.string.show_search_suggestions_key), true); - contentCountry = preferences.getString(getString(R.string.content_country_key), getString(R.string.default_country_value)); + contentCountry = preferences.getString(getString(R.string.content_country_key), getString(R.string.default_localization_key)); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java index 21560ee55..e5f49e2e8 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java @@ -21,6 +21,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment { public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //initializing R.array.seek_duration_description to display the translation of seconds String[] durationsDescriptions = getResources().getStringArray(R.array.seek_duration_description); String[] durationsValues = getResources().getStringArray(R.array.seek_duration_value); int currentDurationValue; diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index b24298f4e..cd66ec3c2 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -83,8 +83,8 @@ public class Localization { public static org.schabi.newpipe.extractor.localization.Localization getPreferredLocalization(final Context context) { final String contentLanguage = PreferenceManager .getDefaultSharedPreferences(context) - .getString(context.getString(R.string.content_language_key), context.getString(R.string.default_language_value)); - if (contentLanguage.equals("system")) { + .getString(context.getString(R.string.content_language_key), context.getString(R.string.default_localization_key)); + if (contentLanguage.equals(context.getString(R.string.default_localization_key))) { return org.schabi.newpipe.extractor.localization.Localization.fromLocale(Locale.getDefault()); } return org.schabi.newpipe.extractor.localization.Localization.fromLocalizationCode(contentLanguage); @@ -93,8 +93,8 @@ public class Localization { public static ContentCountry getPreferredContentCountry(final Context context) { final String contentCountry = PreferenceManager .getDefaultSharedPreferences(context) - .getString(context.getString(R.string.content_country_key), context.getString(R.string.default_country_value)); - if (contentCountry.equals("system")) { + .getString(context.getString(R.string.content_country_key), context.getString(R.string.default_localization_key)); + if (contentCountry.equals(context.getString(R.string.default_localization_key))) { return new ContentCountry(Locale.getDefault().getCountry()); } return new ContentCountry(contentCountry); @@ -104,7 +104,7 @@ public class Localization { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); String languageCode = sp.getString(context.getString(R.string.content_language_key), - context.getString(R.string.default_language_value)); + context.getString(R.string.default_localization_key)); try { if (languageCode.length() == 2) { @@ -236,7 +236,7 @@ public class Localization { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String lang = prefs.getString(context.getString(R.string.app_language_key), "en"); Locale loc; - if (lang.equals("system")) { + if (lang.equals(context.getString(R.string.default_localization_key))) { loc = Locale.getDefault(); } else if (lang.matches(".*-.*")) { //to differentiate different versions of the language diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 05a7416f0..fba5546c1 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -161,8 +161,6 @@ show_comments stream_info_selected_tab show_hold_to_append - system - system content_language peertube_instance_setup peertube_selected_instance @@ -265,9 +263,11 @@ update_app_key update_pref_screen_key + + system - system + @string/default_localization_key af az id @@ -680,7 +680,7 @@ - system + @string/default_localization_key AF AX AL @@ -932,7 +932,7 @@ - system + @string/default_localization_key ar az ast diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 197c14487..8fe8a66af 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -6,7 +6,7 @@ Date: Mon, 17 Feb 2020 10:10:15 +0100 Subject: [PATCH 4/8] use plural string for dynamic_seek_duration_description --- .../settings/VideoAudioSettingsFragment.java | 14 +++++++++++--- app/src/main/res/values-eo/strings.xml | 4 +++- app/src/main/res/values/settings_keys.xml | 14 ++++++++------ app/src/main/res/values/strings.xml | 5 +++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java index e5f49e2e8..d5f46fb22 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.settings; import android.content.SharedPreferences; +import android.content.res.Resources; import android.os.Build; import android.os.Bundle; import android.provider.Settings; @@ -22,12 +23,19 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment { super.onCreate(savedInstanceState); //initializing R.array.seek_duration_description to display the translation of seconds - String[] durationsDescriptions = getResources().getStringArray(R.array.seek_duration_description); - String[] durationsValues = getResources().getStringArray(R.array.seek_duration_value); + Resources res = getResources(); + String[] durationsValues = res.getStringArray(R.array.seek_duration_value); + String[] durationsDescriptions = res.getStringArray(R.array.seek_duration_description); int currentDurationValue; for (int i = 0; i < durationsDescriptions.length; i++) { currentDurationValue = Integer.parseInt(durationsValues[i]) / 1000; - durationsDescriptions[i] = String.format(durationsDescriptions[i], currentDurationValue); + try { + durationsDescriptions[i] = String.format( + res.getQuantityString(R.plurals.dynamic_seek_duration_description, currentDurationValue), + currentDurationValue); + } catch (Resources.NotFoundException ignored) { + //if this happens, the translation is missing, and the english string will be displayed instead + } } ListPreference durations = (ListPreference) findPreference(getString(R.string.seek_duration_key)); durations.setEntries(durationsDescriptions); diff --git a/app/src/main/res/values-eo/strings.xml b/app/src/main/res/values-eo/strings.xml index 8238b13bc..aa34644d1 100644 --- a/app/src/main/res/values-eo/strings.xml +++ b/app/src/main/res/values-eo/strings.xml @@ -538,10 +538,12 @@ Forviŝi elŝutitajn dosierojn %1$s elŝutoj forviŝitaj Filmetoj - %s sekundoj Doni la permeson por afiŝiĝi supre aliaj apoj Lingvo de la apo Sistemnormo Premu « Finita » kiam solvita Finita + + %s sekundoj + \ No newline at end of file diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index fba5546c1..b5bf738fb 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -31,12 +31,14 @@ seek_duration 10000 - @string/dynamic_seek_duration_description - @string/dynamic_seek_duration_description - @string/dynamic_seek_duration_description - @string/dynamic_seek_duration_description - @string/dynamic_seek_duration_description - @string/dynamic_seek_duration_description + + 5 seconds + 10 seconds + 15 seconds + 20 seconds + 25 seconds + 30 seconds 5000 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 712916449..39b2907ce 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -593,4 +593,9 @@ App language System default %s seconds + + %s seconds + %s seconds + %s seconds + From 55d17b556a4bc88c6c0e5e4a8f8d1c0f7a4a05f1 Mon Sep 17 00:00:00 2001 From: bopol Date: Mon, 17 Feb 2020 10:18:20 +0100 Subject: [PATCH 5/8] added all the .iml files in gitignore, not only app.iml if somehow your module name isn't app, it will create a module-name.iml file, and isn't needed --- app/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/app/.gitignore b/app/.gitignore index d9a86a57c..74862ab9f 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,3 +1,4 @@ .gitignore /build app.iml +*.iml From 9912ee8199e188bf0660fda1f6f67ea9a67936db Mon Sep 17 00:00:00 2001 From: bopol Date: Tue, 18 Feb 2020 18:35:13 +0100 Subject: [PATCH 6/8] give info if content language is system on crash --- .../main/java/org/schabi/newpipe/report/ErrorActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index c90aff1c9..b78751496 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -43,6 +43,7 @@ import java.io.StringWriter; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import java.util.Locale; import java.util.TimeZone; import java.util.Vector; @@ -377,8 +378,12 @@ public class ErrorActivity extends AppCompatActivity { } private String getContentLangString() { - return PreferenceManager.getDefaultSharedPreferences(this) + String contentLanguage = PreferenceManager.getDefaultSharedPreferences(this) .getString(this.getString(R.string.content_country_key), "none"); + if (contentLanguage.equals(getString(R.string.default_localization_key))) { + contentLanguage = Locale.getDefault().toString(); + } + return contentLanguage; } private String getOsString() { From 316871714ac5ff548465884f68e944ed663b410e Mon Sep 17 00:00:00 2001 From: B0pol Date: Wed, 19 Feb 2020 17:40:03 +0100 Subject: [PATCH 7/8] Update app/.gitignore Co-Authored-By: Stypox --- app/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/app/.gitignore b/app/.gitignore index 74862ab9f..53edac5e4 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1,4 +1,3 @@ .gitignore /build -app.iml *.iml From 9f9b53c067f65859d2b9519a37e99420ad04b296 Mon Sep 17 00:00:00 2001 From: bopol Date: Thu, 20 Feb 2020 18:55:22 +0100 Subject: [PATCH 8/8] =?UTF-8?q?remove=20unecessary=20=C2=ABfew=C2=BB=20and?= =?UTF-8?q?=20=C2=ABmany=C2=BB=20for=20plural=20string=20in=20english?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/strings.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 39b2907ce..148a339a9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -594,8 +594,6 @@ System default %s seconds - %s seconds - %s seconds %s seconds