@dumanargeyazilim/i18n-library
TypeScript icon, indicating that this package has built-in type declarations

1.3.17 • Public • Published

Xenon-Smart Xiot Backend Applications

Description

This library localize the custom error messages and validation error messages that thrown from application.

Installation and Setup

$ npm install @dumanargeyazilim/i18n-library

Additionally, ensure you have the following peer dependencies installed in your project:

$ npm install @nestjs/common class-validator  class-transformer

Usage

Getting Started

This custom i18n library makes localization for custom error messages defined in Xiot Project and makes localization for validation errors that thrown by class-validator.

How it works?

It takes language as parameter from the header for every request made and returns the translated errors in that language. It supports 3 languages :

  • tr
  • en
  • fr

4 languages will be added in future: arabic, chineese, italian and espanol

## Using I18nValidationPipe for Validation Errors

Step 1: Import the I18nErrorHandlingModule

  • Import 'I18nErrorHandlingModule' to your root module. (AppModule)

Step 2: Use the I18nValidationPipe Globally

  • Use the I18nValidationPipe globally via APP_PIPE as provider in root module.

Step 3: Define DTOs with Custom Messages

  • Must use the message property in decorators for localization support for validation errors:

  • Static Translation Key (e.g., 'validation.isEmail') @IsEmail({}, { message: 'validation.isEmail' })

  • Dynamic Constraint Values (e.g., 'validation.length{3,15}') @Length(3, 8, { message: 'validation.length{3,8}' })

## Using Custom Error Messages for Application Add CustomErrorMessageService from the library to your service as readonly. You can call the defined error methods for spesific error and it returns localizaed error message with it's status code.

  • this.i18nErrorService.getWrongPasswordOrEmailMessage();

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.3.170latest

Version History

VersionDownloads (Last 7 Days)Published
1.3.170
1.3.160
1.3.150
1.3.140
1.3.130
1.3.120
1.3.110
1.3.100
1.3.90
1.3.80
1.3.70
1.3.60
1.3.50
1.3.40
1.3.30
1.3.20
1.3.10
1.2.340
1.2.330
1.2.320
1.2.310
1.2.300
1.2.210
1.2.200
1.2.190
1.2.1860
1.2.1745
1.2.1610
1.2.155
1.2.144
1.2.134
1.2.126
1.2.104
1.2.95
1.2.84
1.2.64
1.2.54
1.2.44
1.2.34
1.2.25
1.2.14
1.2.04
1.1.206
1.1.196
1.1.184
1.1.174
1.1.167
1.1.154
1.1.144
1.1.134
1.1.124
1.1.114
1.1.106
1.1.94
1.1.84
1.1.74
1.1.64
1.1.55
1.1.44
1.1.35
1.1.23
1.1.13
1.0.1233
1.0.1223
1.0.1213
1.0.1203
1.0.1194
1.0.1183
1.0.1173
1.0.1163
1.0.1153
1.0.1143
1.0.1133
1.0.1123
1.0.1113
1.0.1103
1.0.1093
1.0.1083
1.0.1073
1.0.1063
1.0.1053
1.0.1043
1.0.1033
1.0.1023
1.0.1013
1.0.1003
1.0.994
1.0.983
1.0.973
1.0.963
1.0.953
1.0.943
1.0.933
1.0.923
1.0.913
1.0.903
1.0.893
1.0.883
1.0.873
1.0.853
1.0.843
1.0.833
1.0.823
1.0.813
1.0.803
1.0.793
1.0.783
1.0.773
1.0.763
1.0.753
1.0.743
1.0.733
1.0.723
1.0.713
1.0.703
1.0.693
1.0.683
1.0.673
1.0.663
1.0.653
1.0.643
1.0.633
1.0.624
1.0.613
1.0.603
1.0.593
1.0.583
1.0.573
1.0.563
1.0.553
1.0.543
1.0.533
1.0.523
1.0.514
1.0.503
1.0.493
1.0.483
1.0.473
1.0.463
1.0.453
1.0.443
1.0.433
1.0.423
1.0.413
1.0.403
1.0.383
1.0.373
1.0.363
1.0.353
1.0.343
1.0.333
1.0.323
1.0.313
1.0.303
1.0.293
1.0.283
1.0.273
1.0.263
1.0.253
1.0.243
1.0.233
1.0.223
1.0.213
1.0.203
1.0.193
1.0.173
1.0.163
1.0.153
1.0.143
1.0.123
1.0.113
1.0.103
1.0.93
1.0.84
1.0.73
1.0.63
1.0.53
1.0.23
1.0.13
1.0.03

Package Sidebar

Install

npm i @dumanargeyazilim/i18n-library

Weekly Downloads

624

Version

1.3.17

License

ISC

Unpacked Size

219 kB

Total Files

81

Last publish

Collaborators

  • zeynep-goksoy
  • meryem_gul
  • dumanargebilisim