Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing translation when using filebase true #145

Open
cbrevik opened this issue Jun 9, 2020 · 0 comments
Open

Missing translation when using filebase true #145

cbrevik opened this issue Jun 9, 2020 · 0 comments

Comments

@cbrevik
Copy link

cbrevik commented Jun 9, 2020

  • version: 3.3.0
  • node version: v10.16.3
  • yarn version: 1.22.4

Do you want to request a feature or report a bug?:
Bug

What is the current behavior?:
To avoid id collisions I'd like to generate ids using the filename, so I've set filebase: true in babel.config.js:

module.exports = function (api) {
  api.cache(true);

  return {
    presets: [
      'module:metro-react-native-babel-preset',
    ],
    plugins: [
      [
        'react-intl-auto',
        {
          removePrefix: 'src/',
          filebase: true,
        },
      ],
    ],
  };
};

Used like this in the TabNavigator-component:

const messages = defineMessages({
  profile: 'Profil',
});

const TabNavigator = () => {
  const {formatMessage} = useIntl();

  return (
    <Tab.Navigator>
      <Tab.Screen
        name="Profile"
        component={Profile}
        options={{
          tabBarLabel: formatMessage(messages.profile)
        }}
      />
  );
}

Running extract-messages -l=en,nb -o src/translations -d nb --flat true --overwriteDefault false 'src/**/*.{ts,tsx}' does actually generate the ids with the filename:

  "navigation.TabNavigator.profile": "Profil",

But React.Intl complains about a missing translation with the id used in formatMessage:
image
(notice the lack of filename in the id)

What is the expected behavior?:
The id used in formatMessage, FormattedMessage etc, includes the filename when filebase is set to true.

Suggested solution:
Not sure what the issue is yet, if it is some fault of mine or an actual bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant