Currently (2019-02-20) Luxon does not support relative time formatting:
Luxon is fully usable and I plan to support it indefinitely. It's also largely complete. It will certainly add relative time formatting (and an English-only fallback) when that becomes possible. Luxon will also eventually strip out its fallbacks for missing platform features. But overall I expect the core functionality to stay basically as it is, adding mostly minor tweaks and bugfixes.
I managed to implement it like this:
import { DateTime } from 'luxon'
export function translate(a: string) {
return a
.replace(/(?:in )?(\d+) second ago/, '$1秒前')
.replace(/(?:in )?(\d+) seconds ago/, '$1秒前')
.replace(/(?:in )?(\d+) minute ago/, '$1分前')
.replace(/(?:in )?(\d+) minutes ago/, '$1分前')
.replace(/(?:in )?(\d+) hour ago/, '$1時間前')
.replace(/(?:in )?(\d+) hours ago/, '$1時間前')
.replace(/(?:in )?(\d+) day ago/, '$1日前')
.replace(/(?:in )?(\d+) days ago/, '$1日前')
.replace(/(?:in )?(\d+) month ago/, '$1月前')
.replace(/(?:in )?(\d+) months ago/, '$1月前')
.replace(/(?:in )?(\d+) year ago/, '$1年前')
.replace(/(?:in )?(\d+) years ago/, '$1年前')
}
// usage
const date = DateTime.local().plus({ days: 1 }).toRelative() // => "in 1 day"
console.log(translate(date)) // => "1日前"
Yes ugly.