Merge branch 'B0pol-localisation' into dev
This commit is contained in:
commit
b1dd6cbb6e
|
@ -1,3 +1,3 @@
|
|||
.gitignore
|
||||
/build
|
||||
app.iml
|
||||
*.iml
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
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;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.preference.ListPreference;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
|
@ -21,6 +22,24 @@ 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
|
||||
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;
|
||||
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);
|
||||
|
||||
listener = (sharedPreferences, s) -> {
|
||||
|
||||
// on M and above, if user chooses to minimise to popup player on exit and the app doesn't have
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
@ -83,14 +83,20 @@ 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));
|
||||
.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);
|
||||
}
|
||||
|
||||
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));
|
||||
.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);
|
||||
}
|
||||
|
||||
|
@ -98,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) {
|
||||
|
@ -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,10 +233,10 @@ 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")) {
|
||||
if (lang.equals(context.getString(R.string.default_localization_key))) {
|
||||
loc = Locale.getDefault();
|
||||
} else if (lang.matches(".*-.*")) {
|
||||
//to differentiate different versions of the language
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -537,9 +537,13 @@
|
|||
<string name="clear_download_history">Forviŝi la historion de elŝutoj</string>
|
||||
<string name="delete_downloaded_files">Forviŝi elŝutitajn dosierojn</string>
|
||||
<string name="deleted_downloads">%1$s elŝutoj forviŝitaj</string>
|
||||
<string name="videos_string">Filmetoj</string>
|
||||
<string name="permission_display_over_apps">Doni la permeson por afiŝiĝi supre aliaj apoj</string>
|
||||
<string name="app_language_title">Lingvo de la apo</string>
|
||||
<string name="systems_language">Sistemnormo</string>
|
||||
<string name="subtitle_activity_recaptcha">Premu « Finita » kiam solvita</string>
|
||||
<string name="recaptcha_done_button">Finita</string>
|
||||
<plurals name="dynamic_seek_duration_description">
|
||||
<item quantity="other">%s sekundoj</item>
|
||||
</plurals>
|
||||
</resources>
|
|
@ -201,13 +201,13 @@
|
|||
<plurals name="subscribers">
|
||||
<item quantity="one">%s подписчик</item>
|
||||
<item quantity="few">%s подписчика</item>
|
||||
<item quantity="other">%s подписчиков</item>
|
||||
<item quantity="many">%s подписчиков</item>
|
||||
</plurals>
|
||||
<string name="no_views">Нет просмотров</string>
|
||||
<plurals name="views">
|
||||
<item quantity="one">%s просмотр</item>
|
||||
<item quantity="few">%s просмотра</item>
|
||||
<item quantity="other">%s просмотров</item>
|
||||
<item quantity="many">%s просмотров</item>
|
||||
</plurals>
|
||||
<string name="no_videos">Нет видео</string>
|
||||
<plurals name="videos">
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
<string name="seek_duration_key" translatable="false">seek_duration</string>
|
||||
<string name="seek_duration_default_value" translatable="false">10000</string>
|
||||
<string-array name="seek_duration_description" translatable="false">
|
||||
<!-- They are overridden in VideoAudioSettingsFragment.java if the translation
|
||||
(dynamic_seek_duration_description) exist. Otherwise this array is picked-->
|
||||
<item>5 seconds</item>
|
||||
<item>10 seconds</item>
|
||||
<item>15 seconds</item>
|
||||
|
@ -161,8 +163,6 @@
|
|||
<string name="show_comments_key" translatable="false">show_comments</string>
|
||||
<string name="stream_info_selected_tab_key" translatable="false">stream_info_selected_tab</string>
|
||||
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
|
||||
<string name="default_language_value">en</string>
|
||||
<string name="default_country_value">GB</string>
|
||||
<string name="content_language_key" translatable="false">content_language</string>
|
||||
<string name="peertube_instance_setup_key" translatable="false">peertube_instance_setup</string>
|
||||
<string name="peertube_selected_instance_key" translatable="false">peertube_selected_instance</string>
|
||||
|
@ -265,8 +265,11 @@
|
|||
<string name="update_app_key" translatable="false">update_app_key</string>
|
||||
<string name="update_pref_screen_key" translatable="false">update_pref_screen_key</string>
|
||||
|
||||
<!-- Localizations -->
|
||||
<string name="default_localization_key" translatable="false">system</string>
|
||||
<!-- alternatively, load these from some local android data store -->
|
||||
<string-array name="language_codes" translatable="false">
|
||||
<item>@string/default_localization_key</item>
|
||||
<item>af</item>
|
||||
<item>az</item>
|
||||
<item>id</item>
|
||||
|
@ -346,6 +349,7 @@
|
|||
<item>ko</item>
|
||||
</string-array>
|
||||
<string-array name="language_names" translatable="false">
|
||||
<item>@string/systems_language</item>
|
||||
<item>Afrikaans</item>
|
||||
<item>Azərbaycan</item>
|
||||
<item>Bahasa Indonesia</item>
|
||||
|
@ -427,6 +431,7 @@
|
|||
|
||||
|
||||
<string-array name="country_names" translatable="false">
|
||||
<item>@string/systems_language</item>
|
||||
<item>Afghanistan</item>
|
||||
<item>Aland Islands</item>
|
||||
<item>Albania</item>
|
||||
|
@ -677,6 +682,7 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="country_codes" translatable="false">
|
||||
<item>@string/default_localization_key</item>
|
||||
<item>AF</item>
|
||||
<item>AX</item>
|
||||
<item>AL</item>
|
||||
|
@ -928,7 +934,7 @@
|
|||
|
||||
<!--The next two arrays are set to change the app language-->
|
||||
<string-array name="app_language_code" translatable="false">
|
||||
<item>system</item>
|
||||
<item>@string/default_localization_key</item>
|
||||
<item>ar</item>
|
||||
<item>az</item>
|
||||
<item>ast</item>
|
||||
|
|
|
@ -138,9 +138,8 @@
|
|||
<string name="play_btn_text">Play</string>
|
||||
<string name="content">Content</string>
|
||||
<string name="show_age_restricted_content_title">Age restricted content</string>
|
||||
<string name="video_is_age_restricted">Show age restricted video. Future changes are possible from the settings.</string>
|
||||
<string name="duration_live">Live</string>
|
||||
<string name="duration_live_button" translatable="false">Live</string>
|
||||
<string name="video_is_age_restricted">Show age restricted video. Future changes are possible from the settings.</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="downloads_title">Downloads</string>
|
||||
<string name="error_report_title">Error report</string>
|
||||
|
@ -149,8 +148,7 @@
|
|||
<string name="channels">Channels</string>
|
||||
<string name="playlist">Playlist</string>
|
||||
<string name="playlists">Playlists</string>
|
||||
<string name="videos">Videos</string>
|
||||
<string name="comments">Comments</string>
|
||||
<string name="videos_string">Videos</string>
|
||||
<string name="tracks">Tracks</string>
|
||||
<string name="users">Users</string>
|
||||
<string name="events">Events</string>
|
||||
|
@ -594,4 +592,8 @@
|
|||
<string name="choose_instance_prompt">Choose an instance</string>
|
||||
<string name="app_language_title">App language</string>
|
||||
<string name="systems_language">System default</string>
|
||||
<string name="dynamic_seek_duration_description">%s seconds</string>
|
||||
<plurals name="dynamic_seek_duration_description">
|
||||
<item quantity="other">%s seconds</item>
|
||||
</plurals>
|
||||
</resources>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<ListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="system"
|
||||
android:defaultValue="@string/default_localization_key"
|
||||
android:entries="@array/app_language_name"
|
||||
android:entryValues="@array/app_language_code"
|
||||
android:key="@string/app_language_key"
|
||||
|
@ -15,7 +15,7 @@
|
|||
|
||||
<ListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="@string/default_language_value"
|
||||
android:defaultValue="@string/default_localization_key"
|
||||
android:entries="@array/language_names"
|
||||
android:entryValues="@array/language_codes"
|
||||
android:key="@string/content_language_key"
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
<ListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="@string/default_country_value"
|
||||
android:defaultValue="@string/default_localization_key"
|
||||
android:entries="@array/country_names"
|
||||
android:entryValues="@array/country_codes"
|
||||
android:key="@string/content_country_key"
|
||||
|
|
Loading…
Reference in New Issue