Reputation: 1147
I am using i18 with NestJS and the localization package is nestjs-i18n
. I need to check whether the language is RTL or LTR. Is there a method in the given package? My use case is sending localized emails (from backend).
I found that i18next.dir(lang)
is available in i18next
but not in nestjs-i18n
.
My current implementation is,
Class EmailService () {
...
...
async sendWelcome (receiver: string) {
const body = this.i18n.t('email.welcome.body', { lang });
isRtl = this.isRtl(lang);
const html = this.render(Templates.WELCOME, body, isRtl);
this.send(receiver, html);
}
isRtl(lang: string){
switch (lang) {
case ('ar'):
return true;
default:
return false;
}
...
...
Upvotes: 0
Views: 35