From 8347d8700ae73893b0303b3550bd47ee16fe4ee0 Mon Sep 17 00:00:00 2001 From: mitosagi <54105954+mitosagi@users.noreply.github.com> Date: Sun, 18 Oct 2020 11:00:32 +0900 Subject: [PATCH] Translate the numeric notation --- .../main/java/org/schabi/newpipe/util/Localization.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 838e4e986..700d7b63d 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -5,13 +5,15 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; import android.content.res.Resources; -import androidx.preference.PreferenceManager; +import android.icu.text.CompactDecimalFormat; +import android.os.Build; import android.text.TextUtils; import android.util.DisplayMetrics; import androidx.annotation.NonNull; import androidx.annotation.PluralsRes; import androidx.annotation.StringRes; +import androidx.preference.PreferenceManager; import org.ocpsoft.prettytime.PrettyTime; import org.ocpsoft.prettytime.units.Decade; @@ -184,6 +186,11 @@ public final class Localization { } public static String shortCount(final Context context, final long count) { + if (Build.VERSION.SDK_INT >= 24) { + return CompactDecimalFormat.getInstance(getAppLocale(context), + CompactDecimalFormat.CompactStyle.SHORT).format(count); + } + final double value = (double) count; if (count >= 1000000000) { return localizeNumber(context, round(value / 1000000000, 1))