Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nestjs-i18n

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-i18n - npm Package Compare versions

Comparing version 5.0.1 to 5.1.0

bin/lib/resolvers/accept-language.resolver.js

1

bin/lib/index.js

@@ -16,3 +16,4 @@ "use strict";

__export(require("./resolvers/header.resolver"));
__export(require("./resolvers/accept-language.resolver"));
__export(require("./resolvers/query.resolver"));
__export(require("./resolvers/cookie.resolver"));

2

bin/lib/middleware/i18n-language-middleware.js

@@ -29,2 +29,3 @@ "use strict";

let language = null;
req.i18nService = this.i18nService;
for (const r of this.i18nResolvers) {

@@ -38,3 +39,2 @@ const resolver = await this.getResolver(r);

req.i18nLang = language || this.i18nOptions.fallbackLanguage;
req.i18nService = this.i18nService;
next();

@@ -41,0 +41,0 @@ }

@@ -18,3 +18,3 @@ "use strict";

let HeaderResolver = class HeaderResolver {
constructor(keys = ['accept-language']) {
constructor(keys = []) {
this.keys = keys;

@@ -25,2 +25,5 @@ }

for (const key of this.keys) {
if (key === 'accept-language') {
console.warn('HeaderResolver does not support RFC4647 Accept-Language header. Please use AcceptLanguageResolver instead.');
}
if (req.headers[key] !== undefined) {

@@ -27,0 +30,0 @@ lang = req.headers[key];

@@ -1,1 +0,1 @@

export declare const I18nLanguages: () => (target: Object, key: string | symbol, index?: number) => void;
export declare const I18nLanguages: () => (target: object, key: string | symbol, index?: number) => void;

@@ -13,3 +13,4 @@ export * from './i18n.module';

export * from './resolvers/header.resolver';
export * from './resolvers/accept-language.resolver';
export * from './resolvers/query.resolver';
export * from './resolvers/cookie.resolver';

@@ -16,4 +16,5 @@ "use strict";

__export(require("./resolvers/header.resolver"));
__export(require("./resolvers/accept-language.resolver"));
__export(require("./resolvers/query.resolver"));
__export(require("./resolvers/cookie.resolver"));
//# sourceMappingURL=index.js.map

@@ -29,2 +29,3 @@ "use strict";

let language = null;
req.i18nService = this.i18nService;
for (const r of this.i18nResolvers) {

@@ -38,3 +39,2 @@ const resolver = await this.getResolver(r);

req.i18nLang = language || this.i18nOptions.fallbackLanguage;
req.i18nService = this.i18nService;
next();

@@ -41,0 +41,0 @@ }

@@ -18,3 +18,3 @@ "use strict";

let HeaderResolver = class HeaderResolver {
constructor(keys = ['accept-language']) {
constructor(keys = []) {
this.keys = keys;

@@ -25,2 +25,5 @@ }

for (const key of this.keys) {
if (key === 'accept-language') {
console.warn('HeaderResolver does not support RFC4647 Accept-Language header. Please use AcceptLanguageResolver instead.');
}
if (req.headers[key] !== undefined) {

@@ -27,0 +30,0 @@ lang = req.headers[key];

{
"name": "nestjs-i18n",
"version": "5.0.1",
"version": "5.1.0",
"description": "",

@@ -30,33 +30,33 @@ "author": "Toon van Strijp",

"devDependencies": {
"@nestjs/common": "^6.10.13",
"@nestjs/core": "^6.10.13",
"@nestjs/graphql": "^6.5.3",
"@nestjs/platform-express": "^6.10.13",
"@nestjs/platform-fastify": "^6.10.13",
"@nestjs/testing": "^6.10.13",
"@nestjs/common": "^6.11.6",
"@nestjs/core": "^6.11.6",
"@nestjs/graphql": "^6.5.4",
"@nestjs/platform-express": "^6.11.6",
"@nestjs/platform-fastify": "^6.11.6",
"@nestjs/testing": "^6.11.6",
"@types/commander": "^2.12.2",
"@types/cookie": "^0.3.3",
"@types/flat": "0.0.28",
"@types/jest": "^24.0.25",
"@types/flat": "5.0.0",
"@types/jest": "^25.1.2",
"@types/lodash": "^4.14.149",
"@types/node": "^13.1.0",
"@types/node": "^13.7.0",
"@types/string-format": "^2.0.0",
"apollo-server-express": "^2.9.15",
"apollo-server-express": "^2.10.0",
"coveralls": "^3.0.9",
"fastify": "^2.11.0",
"graphql": "^14.5.8",
"fastify": "^2.12.0",
"graphql": "^14.6.0",
"graphql-tools": "^4.0.6",
"husky": "3.1.0",
"jest": "^24.9.0",
"lint-staged": "9.5.0",
"husky": "4.2.2",
"jest": "^25.1.0",
"lint-staged": "10.0.8",
"prettier": "1.19.1",
"reflect-metadata": "^0.1.13",
"supertest": "^4.0.2",
"ts-jest": "^24.2.0",
"typescript": "3.6.3"
"ts-jest": "^25.2.0",
"typescript": "3.7.5"
},
"dependencies": {
"accept-language-negotiator": "^1.2.0",
"accept-language-parser": "^1.5.0",
"chalk": "^3.0.0",
"commander": "^4.0.1",
"commander": "^4.1.1",
"cookie": "^0.4.0",

@@ -63,0 +63,0 @@ "flat": "^5.0.0",

@@ -106,3 +106,4 @@ [![Build Status](https://travis-ci.org/ToonvanStrijp/nestjs-i18n.svg?branch=master)](https://travis-ci.org/ToonvanStrijp/nestjs-i18n) [![Greenkeeper badge](https://badges.greenkeeper.io/ToonvanStrijp/nestjs-i18n.svg)](https://greenkeeper.io/)

{ use: QueryResolver, options: ['lang', 'locale', 'l'] },
HeaderResolver,
new HeaderResolver(['x-custom-lang']),
AcceptLanguageResolver,
new CookieResolver(['lang', 'locale', 'l']),

@@ -117,9 +118,10 @@ ],

Currently, there are two built-in resolvers
Currently, there are four built-in resolvers
| Resolver | Default value |
| ---------------- | ----------------- |
| `QueryResolver` | `none` |
| `HeaderResolver` | `accept-language` |
| `CookieResolver` | `lang` |
| Resolver | Default value |
| ------------------------ | ----------------- |
| `QueryResolver` | `none` |
| `HeaderResolver` | `none` |
| `AcceptLanguageResolver` | `N/A` |
| `CookieResolver` | `lang` |

@@ -126,0 +128,0 @@ To implement your own resolver (or custom logic) use the `I18nResolver` interface. The resolvers are provided via the nestjs dependency injection, this way you can inject your own services if needed.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc