Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ToonvanStrijp/nestjs-i18n
The i18n module for nestjs.
https://github.com/ToonvanStrijp/nestjs-i18n
i18n nestjs nodejs typescript
Last synced: about 1 month ago
JSON representation
The i18n module for nestjs.
- Host: GitHub
- URL: https://github.com/ToonvanStrijp/nestjs-i18n
- Owner: toonvanstrijp
- License: other
- Created: 2019-03-24T15:33:10.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-25T04:51:38.000Z (about 2 months ago)
- Last Synced: 2024-10-29T15:11:30.503Z (about 1 month ago)
- Topics: i18n, nestjs, nodejs, typescript
- Language: TypeScript
- Homepage: https://nestjs-i18n.com
- Size: 13.2 MB
- Stars: 652
- Watchers: 4
- Forks: 112
- Open Issues: 42
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-nestjs - Nest i18n - 在您的服务器上轻松添加 i18n 支持,内置丰富的格式化 api 。 (资源 / 组件和库)
README
The i18n library for nestjs. It makes working with languages in your nestjs project easy. Everything is made to be highly configurable. You can write and plug-in your own language resolvers or loaders.
## Features
**nestjs-i18n** comes with a bunch of tools to help add multiple language support to your project.
- **Type safety** 🎉 ([instructions](https://nestjs-i18n.com/guides/type-safety))
- **Variable formatting** ([instructions](https://nestjs-i18n.com/guides/formatting))
- **Fallback** languages ([instructions](https://nestjs-i18n.com/guides/fallback-languages))
- **Live** reloading 🎉
- **Plurals** support ([instructions](https://nestjs-i18n.com/guides/plurals))
- **GraphQL** support ([instructions](https://nestjs-i18n.com/guides/graphql))
- **gRPC** support ([instructions](https://nestjs-i18n.com/guides/grpc))
- **DTO** validation ([instructions](https://nestjs-i18n.com/guides/dto_validation/global-validation))
- View engine support ([**hbs**](https://nestjs-i18n.com/guides/view_engines/handlebars) or [**pug**](https://nestjs-i18n.com/guides/view_engines/pug) or [**ejs**](https://nestjs-i18n.com/guides/view_engines/ejs))
- Custom resolvers
- Custom loaders
- Custom formatters## Getting started
To get started follow the [**quickstart**](https://nestjs-i18n.com/quick-start), or take a look at the [**docs**](https://nestjs-i18n.com/).
## License
`nestjs-i18n` is MIT licensed.
## Breaking changes:
- from V10.0.0 on we removed the `I18nRequestScopeService`. This because we now have `async_hooks` support. This allows you to get the current `I18nContext` by doing `I18nContext.current()`.- from V9.0.0 on we renamed the `parser` property to `loader`. The `translate` function no longer returns a promise 🎉. A lot of new features and new docs, see [nestjs-i18n.com](https://nestjs-i18n.com/).
- from V8.0.0 on we changed the internal `I18n-middleware` for an `interceptor` this way we can provide the `ExecutionContext` so that `nestjs-i18n` works on different protocols as well, such as gRPC and WebSockets. This contains one breaking change. It only applies to your code if you've made a custom `resolver`. To resolve this breaking change take a look at this [example](https://nestjs-i18n.com/concepts/resolver). Instead of providing the `req` in the `resolve` method, change this to take the `ExecutionContext` as argument.
- from V6.0.0 on we implemented the `I18nParser`, by using this we can easily support different formats other than JSON. To migrate to this change look at the [quickstart](https://nestjs-i18n.com/quick-start). There are some changes in the declaration of the `I18nModule`. Note: the `translate` function returns a `Promise`. So you need to call it using `await i18n.translate('HELLO')`;
- from V4.0.0 on we changed the signature of the `translate` function, the `language` is now optional, if no `language` is given it'll fallback to the `fallbackLanguage`.
- from V3.0.0 on we load translations based on their directory name instead of file name. Change your translations files to the structure found in the [quickstart](https://nestjs-i18n.com/quick-start#setup-translation-files).