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

Scrape all missing keys and send them to Locize backend #315

Closed
rwieruch opened this issue Feb 4, 2020 · 7 comments
Closed

Scrape all missing keys and send them to Locize backend #315

rwieruch opened this issue Feb 4, 2020 · 7 comments

Comments

@rwieruch
Copy link

rwieruch commented Feb 4, 2020

Thanks for this project!

As far as I understand, if I am using the following config for my i18next, I get all the missing keys send to the Locize backend once they are rendered (in React).

saveMissing: true,
saveMissingTo: 'all',

It's easy to not spot a missing key this way, because it may be hidden in some closed Dialog component. Is there a way to scrape all the missing keys for the entire application across all languages and namespaces and send them to the Locize backend?

Or is this something Locize CLI is doing? I couldn't find anything about it.

@rwieruch rwieruch changed the title Scrape all missing keys and send them to Locize backend. Scrape all missing keys and send them to Locize backend Feb 4, 2020
@adrai
Copy link
Contributor

adrai commented Feb 4, 2020

You may have a look at:
https://github.com/i18next/i18next-parser or https://github.com/i18next/i18next-scanner
=> locize/i18next-node-locize-backend#2 (comment)

@rwieruch
Copy link
Author

rwieruch commented Feb 5, 2020

Any plans to make this a feature of Locize sometime in the future? Would want to run my own extraction script on the side.

@adrai
Copy link
Contributor

adrai commented Feb 5, 2020

May I ask how you imagine this to be a feature of locize? What do you expect to be different to i18next-parser oder i18next-scanner?
I'm curious to know your ideas.

@rwieruch
Copy link
Author

rwieruch commented Feb 5, 2020

May I ask how you imagine this to be a feature of locize? What do you expect to be different to i18next-parser oder i18next-scanner?
I'm curious to know your ideas.

Maybe just another npm script / i18n plugin which uses i18next-parser under the hood and sends all missing keys at once to the Locize backend. Otherwise I cannot be always sure to have all missing keys in Locize, can I?

@adrai
Copy link
Contributor

adrai commented Feb 5, 2020

Will discuss this topic in the next weeks...

@adrai
Copy link
Contributor

adrai commented Feb 17, 2020

Seems you can just create an npm script which will do something like this:

i.e. having an i18next-parser.config.js file like this:

module.exports = {
  defaultNamespace: 'translation',
  // Default namespace used in your i18next config

  defaultValue: 'missing value',
  // Default value to give to empty keys

  locales: ['en', 'de'],
  // An array of the locales in your applications

  namespaceSeparator: ':',
  // Namespace separator used in your translation keys
  // If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.

  output: 'locales/$LOCALE/$NAMESPACE.json',
  // Supports $LOCALE and $NAMESPACE injection
  // Supports JSON (.json) and YAML (.yml) file formats
  // Where to write the locale files relative to process.cwd()
}
i18next '/path/to/file/or/dir' && locize save-missing --format json --path ./locales

Is this ok?

@rwieruch
Copy link
Author

rwieruch commented Feb 17, 2020

Didn't know about the save-missing. This helps, yeah! Thank you 👍

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

2 participants