i18next / i18next/i18next-http-middleware

fallbackLng does not support object type at i18next-http-middleware version 3.8.1 any more

Open
#92 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
170
Forks
30
Avg merge
14m
Merged PRs (30d)
2

Description

## 🐛 Bug Report

fallbackLng does not support object type at i18next-http-middleware version 3.8.1 any more

## To Reproduce

1. We always set the fallbackLng with object as below(i18next-http-middleware version 3.8.0 ), it works.

```js
fallbackLng: {
default: ['en'],
},
```
2. But after we upgrade i18next-http-middleware version 3.8.1, it has errors as below:

TypeError: _this.fallbacks.map is not a function
at /i18next-http-middleware@3.8.1/node_modules/i18next-http-middleware/esm/LanguageDetector.js:93:70
at Array.forEach ()
at LanguageDetector.detect (i18next-http-middleware@3.8.1/node_modules/i18next-http-middleware/esm/LanguageDetector.js:77:22)
at i18nextMiddleware (i18next-http-middleware@3.8.1/node_modules/i18next-http-middleware/esm/index.js:79:47)
at Layer.handle [as handle_request] (/express@4.21.2/node_modules/express/lib/router/layer.js:95:5)

if we change below , it works

```js
fallbackLng: ['en'],
```

## Expected behavior

fallbackLng support the object type

Contributor guide

Open the contributing guide

Research direction

Start at esm/LanguageDetector.js around line 93 and trace how LanguageDetector.detect processes fallbackLng. Reproduce the failure with the object form shown in the issue, then verify that fallbackLng supports both the object form and the existing array form without the map error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.