Back to KB
Difficulty
Intermediate
Read Time
3 min

How to Set Up i18n in NestJS — with Vietnamese Translations

By Codcompass Team··3 min read

Most i18n tutorials stop at English and Spanish. If you're building for Vietnamese users, you need proper tone marks, natural phrasing, and a setup that doesn't fight you.

Here's how I built a NestJS i18n system that auto-detects Accept-Language and returns error messages in Vietnamese or English.

1. Install nestjs-i18n

npm install nestjs-i18n

Enter fullscreen mode Exit fullscreen mode

2. Create translation files

src/i18n/
├── vi/
│   ├── validation.json
│   └── response.json
└── en/
    ├── validation.json
    └── response.json

Enter fullscreen mode Exit fullscreen mode

vi/validation.json:

{
  "EMAIL_INVALID": "Email không hợp lệ",
  "PASSWORD_MIN_LENGTH": "Mật khẩu phải có ít nhất 6 ký tự",
  "USER_NOT_FOUND": "Không tìm thấy người dùng",
  "EMAIL_EXISTS": "Email đã tồn tại",
  "FORBID

🎉 Mid-Year Sale — Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register — Start Free Trial

7-day free trial · Cancel anytime · 30-day money-back