I am struggling to find a question which specifically asks this, so I apologise if I have duplicated.
What I want is to format integers to strings whilst appending localised strings for time durations. I would like to know if there is any way in which to do this in Android without having to translate everything myself.
Something like this:
format(locale = Locale.UK, formatStyle = FormatStyle.SHORT, hours = 2, minutes = 35) -> Output expected 2hrs 35mins
format(locale = Locale.UK, formatStyle = FormatStyle.NORMAL, hours = 2, minutes = 35) -> Output expected 2hours 35minutes
format(locale = Locale.FRA, formatStyle = FormatStyle.SHORT, hours = 2, minutes = 35) -> Output expected 2h 35m
format(locale = Locale.FRA, formatStyle = FormatStyle.NORMAL, hours = 2, minutes = 35) -> Output expected 2heures 35minutes
I would like localisation of the string "hours" and "minutes" to be done for me, much like how RelativeDateTimeFormatter does "x hours ago" when you pass in some Locale, but I cannot find this.
Note, I know how to do the "maths" of it so using Duration or something to deal with numbers isn't what I need. Also, I do not want to use my own translations so just using R.string.hours and defining that across my supported locales isn't the solution I'm looking for.
Achieving this goal along with flexibility of pluralisation would also be amazing but isn't a deal breaker.
e.g. hour/hours, hr/hrs, h