Hi, first of all thanks for this. Is super helpful and looks super complete!
I was reading the issues and search in all repo but I didn't see any references to localization. Is there something related with the translation of the units?
Could be a translations folder. And people could initialize like formatter
import enLocale from 'qt/translations/en.json'
import esLocale from 'qt/translations/es.json'
const LOCALES = {
en: enLocale,
es: esLocale
}
function init (locale: string) {
Qty.translations = LOCALES[locale] || LOCALES.en
}
Then you can pass the type of format. We could have long/short format. And also take into account plurals. 1 meter vs 2 meters
I would introduce a new method to
new Qty(1, 'm').localizedFormat({ format: 'long' })
// 1 meter
// Change to Spanish
Qty.translations = LOCALES.es
new Qty(2, 'm').localizedFormat({ format: 'long' }) // you can omit "targetUnit" if you want the same
// 2 metros
new Qty(2, 'm').localizedFormat({ targetUnit: 'cm', format: 'long' })
// 200 centímetros
// Short version by default
new Qty(2, 'm').localizedFormat({ targetUnit: 'cm' })
// 200 cm
I realize maybe what I want is doable by myself with Qty.formatter but I think could be nice to have these translations in the repo shared and maintained by the community.
Hi, first of all thanks for this. Is super helpful and looks super complete!
I was reading the issues and search in all repo but I didn't see any references to localization. Is there something related with the translation of the units?
Could be a
translations
folder. And people could initialize like formatterThen you can pass the type of format. We could have long/short format. And also take into account plurals.
1 meter vs 2 meters
I would introduce a new method to
I realize maybe what I want is doable by myself with
Qty.formatter
but I think could be nice to have these translations in the repo shared and maintained by the community.What do you think? : )