Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Convert i18n-scanner command into a webpack plugin - Closes #831 #949

Merged
merged 5 commits into from
Nov 6, 2017

Conversation

slaweet
Copy link
Contributor

@slaweet slaweet commented Nov 3, 2017

What was the problem?

We had to generate i18n source file manually by npm run i18n-scanner, so we often forgot to do it and had missing sources.

How did I fix it?

By creating a webpack plugin that runs when the react app is built.

How to test it?

  • Run npm run dev
  • change some string in props.t(...)
  • check that src/locales/en/common.json was updated

Review checklist

const content = fs.readFileSync(file, 'utf-8');
parser.parseFuncFromString(content, { list: translationFunctionNames }, customHandler);
});
class HelloWorldPlugin {
Copy link
Contributor

@reyraa reyraa Nov 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello world plugin? please rename to a more relevant name.

reyraa
reyraa previously approved these changes Nov 6, 2017
Copy link
Contributor

@reyraa reyraa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @slaweet, This a neat piece of code!

@slaweet slaweet merged commit fd0ebf3 into 1.3.0 Nov 6, 2017
@slaweet slaweet deleted the 831-i18n-scanner-in-webpack branch November 6, 2017 16:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants