mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 16:40:32 +00:00
Merge pull request #4554 from mitosagi/translate-numbers
Translates shortened notation of numbers
This commit is contained in:
commit
5214bfe8cb
@ -5,13 +5,15 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import androidx.preference.PreferenceManager;
|
import android.icu.text.CompactDecimalFormat;
|
||||||
|
import android.os.Build;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.PluralsRes;
|
import androidx.annotation.PluralsRes;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.ocpsoft.prettytime.PrettyTime;
|
import org.ocpsoft.prettytime.PrettyTime;
|
||||||
import org.ocpsoft.prettytime.units.Decade;
|
import org.ocpsoft.prettytime.units.Decade;
|
||||||
@ -184,6 +186,11 @@ public final class Localization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String shortCount(final Context context, final long count) {
|
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;
|
final double value = (double) count;
|
||||||
if (count >= 1000000000) {
|
if (count >= 1000000000) {
|
||||||
return localizeNumber(context, round(value / 1000000000, 1))
|
return localizeNumber(context, round(value / 1000000000, 1))
|
||||||
|
Loading…
Reference in New Issue
Block a user