You can do this by making dimens file for different languages/locales and defining the custom name for your dimensions, with different values for different locales/languages.
Like I have created 3 files with name dimens in values folder of resources directory, but each one is defined for different locales.
.
You can create this file by right clicking on res -> New -> Android resource File
.
And fill the details like this.
Do this to create different files for different local/languages.
And for different language I have different values. like-
For English language I have these values and
for hindi I have these values.
as you can see the name of dimen key are same in all both files but values are different.
Now you can get the values in your code by:-
val lineHeight = context.resources.getDimension(R.dimen.H6_lineHeight)
Now this will not give the value you have mentioned in your filem rather this will give values in pixel.
Now you can use this function to get values in sp. You can use your converter function in place of this to convert the value into your desired unit.
fun pixelsToSp(context: Context): Float {
val scaledDensity = context.resources.displayMetrics.scaledDensity
return this / scaledDensity
}
Now the android will handle and pick values from corresponding files based on locale/language of working device.