react-admin: translation is broken ?

What you were expecting: native ra-language need to show translation not the keys.

What happened instead: All keys “ra.****” are not traducted

// in App.js
const messages = {
    fr: frenchMessages,
    en: englishMessages,
    de: germanMessages,
    it: italianMessages,
};
const i18nProvider = locale => messages[locale];

if (!localStorage.getItem('locale')){
    localStorage.setItem('locale', resolveBrowserLocale());
}

[...]

render() {
        return (
            <Admin
                locale={localStorage.getItem('locale')}
                appLayout={CustomLayout}
                i18nProvider={i18nProvider}
                customReducers={{ theme: themeReducer }}
                dashboard={Dashboard}
                menu={Menu}
                customRoutes={customRoutes}
                authProvider={authProvider}
                dataProvider={dataProvider}
            >



// in i18n/fr.js

// import frenchMessages from 'ra-language-french'; // don't work
import frenchDashboardMessages from './fr/DashboardMessages' // ok all is translated
import frenchGlobalMessages from './fr/GlobalMessages' // ok all is translated
import frenchMenuMessages from './fr/MenuMessages' // ok all is translated
import frenchConfigurationViewMessages from './fr/ConfigurationViewMessages' // ok all is translated
import frenchMessages from './fr/RaMessages' // don't work copy of ra-language-french

export default {
    ...frenchMessages,
    ...frenchDashboardMessages,
    ...frenchGlobalMessages,
    ...frenchMenuMessages,
    ...frenchConfigurationViewMessages,
    resources: {
        [...]
    }
}

Other information: linked to #3000

got the same problem.

clear navigator cache -> no effect rm -rf node_modules -> no effect. npm cache rm -> no effect rm -rf ~/.npm/* -> no effect rm -rf ~/.cache/* -> no effect rm -rf ~/.yarn/* -> no effect

sudo npm install -g npm -> updated but no effect sudo npm install -g yarn -> updated but no effect

try to lunch with npm start or yarn start and nothing seemes to work…

Environment

  • React-admin version: 2.8.1
  • Last version that did not exhibit the issue (if applicable): 2.7.1
  • React version: 16.8.2
  • Browser: all
  • Stack trace (in case of a JS error): no js error

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (8 by maintainers)

Most upvoted comments

I can confirm this happened to me after updating to 2.8.5 and was fixed by removing package-lock.json, node_modules and running npm install.

@saysmaster maybe you upgraded only react-admin and not other ra- packages (like ra-language-english or ra-data-jsonserver), which results in duplicated translation calls, and only one would have the translation.

Updating to 2.8.3 fixed this issue.

well… today i redo a yarn start and everything seems to be ok…

damn… that is strange… can’t explain except a npm/yarn cache conflict maybe ? i can’t reproduce it on codesandbox.

so… it’s ok for me, i will reopen for the next update if i have the same problem.

thx guys