Skip to content

Commit

Permalink
add translate for neighborhood
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Jun 27, 2024
1 parent 6553ae0 commit 287c49e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion apps/e-commerce/src/user/address/address.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { User } from '@rahino/database/models/core/user.entity';
import { ECProvince } from '@rahino/database/models/ecommerce-eav/ec-province.entity';
import { ECCity } from '@rahino/database/models/ecommerce-eav/ec-city.entity';
import { ECNeighborhood } from '@rahino/database/models/ecommerce-eav/ec-neighborhood.entity';
import { I18nTranslations } from 'apps/main/src/generated/i18n.generated';
import { I18nContext, I18nService } from 'nestjs-i18n';

@Injectable()
export class AddressService {
Expand All @@ -25,6 +27,7 @@ export class AddressService {
@InjectModel(ECNeighborhood)
private neighborhoodRepository: typeof ECNeighborhood,
@InjectMapper() private readonly mapper: Mapper,
private readonly i18n: I18nService<I18nTranslations>,
) {}

async findAll(user: User, filter: GetAddressDto) {
Expand Down Expand Up @@ -184,7 +187,11 @@ export class AddressService {

if (city.neighborhoodBase === true) {
if (!dto.neighborhoodId) {
throw new BadRequestException('neighborhood must be select it!');
throw new BadRequestException(
this.i18n.translate('ecommerce.neighborhood_must_be_select_it', {
lang: I18nContext.current().lang,
}),
);
}
const neighborhood = await this.neighborhoodRepository.findOne(
new QueryOptionsBuilder()
Expand Down
1 change: 1 addition & 0 deletions apps/main/src/generated/i18n.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type I18nTranslations = {
"address_postalcode": string;
"date_is_invalid": string;
"dont_access_to_this_vendor": string;
"neighborhood_must_be_select_it": string;
};
"validation": {
"NOT_EMPTY": string;
Expand Down
3 changes: 2 additions & 1 deletion apps/main/src/i18n/en/ecommerce.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"address_floor": "you should enter floor",
"address_postalcode": "you should enter postal code",
"date_is_invalid": "date is invalid",
"dont_access_to_this_vendor": "you don't access to this vendor"
"dont_access_to_this_vendor": "you don't access to this vendor",
"neighborhood_must_be_select_it": "neighborhood must be select it!"
}
3 changes: 2 additions & 1 deletion apps/main/src/i18n/fa/ecommerce.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"address_floor": "یک طبقه وارد بفرمایید",
"address_postalcode": "یک کد پستی وارد بفرمایید",
"date_is_invalid": "تاریخ معتبر نیست",
"dont_access_to_this_vendor": "شما به این فروشگاه دسترسی ندارید"
"dont_access_to_this_vendor": "شما به این فروشگاه دسترسی ندارید",
"neighborhood_must_be_select_it": "محله باید انتخاب شود"
}

0 comments on commit 287c49e

Please sign in to comment.