Why, in case of an error in the url, local translations are not loaded?
See original GitHub issueWhy, in case of an error in the url, local translations are not loaded?
My settings:
import i18n from 'i18next'
import ChainedBackend from 'i18next-chained-backend'
import Backend from 'i18next-http-backend'
import resourcesToBackend from 'i18next-resources-to-backend'
import { initReactI18next } from 'react-i18next'
import { currentLocale } from 'src/utils/helpers'
import resources from './src/translations/resources'
const options = {
backends: [Backend, resourcesToBackend(resources)],
backendOptions: [
{
loadPath: 'https://translation.rightwayhealthcare.com/{{lng}}.json',
crossDomain: true,
},
],
}
const customI18nextReactNative = () => ({
init: Function.prototype,
async: true,
type: 'languageDetector',
cacheUserLanguage: Function.prototype,
detect: () => {
if (currentLocale.match(/^en(.)*/)) {
return 'en'
}
if (currentLocale.match(/es(.)*/)) {
return 'es'
}
if (currentLocale.match(/ru(.)*/)) {
return 'ru'
}
return 'en'
},
})
i18n
.use(ChainedBackend)
.use(customI18nextReactNative())
.use(initReactI18next)
.init({
getAsync: true,
supportedLngs: ['en', 'es'],
nonExplicitSupportedLngs: true,
react: {
useSuspense: false,
},
// debug: true,
lng: currentLocale,
backend: options,
keySeparator: '.',
fallbackLng: 'en',
interpolation: {
escapeValue: false,
},
})
export default i18n
example broken url:
loadPath: 'https://tran1slation.rightwayhealthcare.com/{{lng}}.json',
As I do in this case, the local translation should be connected, but it doesn’t.
Where am I going wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
React i18next fails to load translation after in build
I'm using the react build folder inside Django project. It works fine on localhost:3000 only which is crazy but once i try to...
Read more >Common Errors with Exporting and Importing Translation Files
This error message only applies to data translation files. Data translation isn't enabled or was disabled after the data translation file was exported....
Read more >Translations (Symfony Docs)
A catalog (e.g. big collection) of translated messages is loaded from translation resources defined for the locale (e.g. fr_FR ). Messages from the...
Read more >Rails Internationalization (I18n) API - Ruby on Rails Guides
The translations load path (I18n.load_path) is just a Ruby Array of paths to your ... An URL like http://localhost:3001/nl will not work automatically, ......
Read more >Translating React Apps with i18next | by Daniel Duan | Medium
In the case that a translation is not available in a certain language or the additional bundles do not load for whatever reason,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes
If I understood correctly this will never happen in a “productive” environment. It’s just a debug/dev issue. Can’t this be fixed at the root of the causing issue? react-native debugger?