i18next / i18next-http-backend

i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
MIT License
452 stars 70 forks source link

Possibility to add timeout to the setup #123

Closed simonbergstrom closed 8 months ago

simonbergstrom commented 1 year ago

🚀 Feature Proposal

Add the possibility to add timeout for fetching i18n resource like the axios config timeout. (See example here for timeout: https://axios-http.com/docs/req_config and search for timeout)

Motivation

When fetching i18n resource it would be really good to specify for how long a request is acceptable to wait for before fallbacking to fetching i18n resources from somewhere else.

Example

https://axios-http.com/docs/req_config and search for timeout

...i18n config
 backend: {
          backends: [HttpBackend, resourcesToBackend(config.resources)],
          backendOptions: [
            {
              loadPath: <URL_TO_FETCH>,
              crossDomain: true,
              timeout: 2000, // Will fallback to fetch i18n resources from file if request take more than 2 sec
            },
          ],
        },
adrai commented 1 year ago

You can already do so by specifying your own fetch/request function: https://github.com/i18next/i18next-http-backend#backend-options

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.