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" , "FORBIDDEN" : "Bạn không có quyền truy cập" }
Enter fullscreen mode
Exit fullscreen mode
vi/response.json:
{ "LOGIN_SUCCESS" : "Đăng nhập thành công" , "REGISTER_SUCCESS" : "Đăng ký thành công" , "LOGOUT_SUCCESS" : "Đăng xuất thành…