toonvanstrijp / nestjs-i18n

The i18n module for nestjs.
https://nestjs-i18n.com
Other
625 stars 102 forks source link

Use context lang as primary default for service #638

Closed mahziyar-es closed 1 month ago

mahziyar-es commented 1 month ago

When using I18nService, if the context lang is not passed to the service options, it will always fallback to the fallback language, even though the context lang is accessible automatically in I18nService.

So in order to prevent passing the lang manually to the I18nService options, I used the I18nContext.current().lang which is the lang resolved by resolvers, as the primary default for the translate method inside I18nService.

If the context current lang does not exist, it will use the fallback lang as default.

coveralls commented 1 month ago

Coverage Status

coverage: 90.869% (+0.03%) from 90.844% when pulling 169a7d9c82a7d5d71a83222665bab1d5ebcfde0d on mahziyar-es:use-context-lang-as-primary-default-for-service into ad3f68f47bfce23967b41727e4c679580d0ebb49 on toonvanstrijp:main.