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

Warning on missing Interpolation prop #157

Closed
aray12 opened this issue Jul 7, 2016 · 1 comment
Closed

Warning on missing Interpolation prop #157

aray12 opened this issue Jul 7, 2016 · 1 comment

Comments

@aray12
Copy link
Contributor

aray12 commented Jul 7, 2016

Is there a way to log a warning if an Interpolation value contains parsed values with no corresponding prop passed. It would be especially awesome if this could tie in with the i18n instance's debug setting. Basically I want to easily discover missing props

e.g.

{
  "interpolateSample": "you can interpolate {{value}} or {{component}} via interpolate component!"
}
import React from 'react';
import { translate, Interpolate } from 'react-i18next';

function TranslatableView(props) {
  const { t } = props;

  let interpolateComponent = <strong>a interpolated component</strong>;

  return (
    <div>
      <Interpolate i18nKey='ns:interpolateSample' stupid='"some string"' dumpTypo={interpolateComponent} />
    </div>
  )
}

Any thoughts on this?

@jamuhl
Copy link
Member

jamuhl commented Jul 8, 2016

on the interpolation component there is the i18n instance added https://github.com/i18next/react-i18next/blob/master/src/interpolate.js#L7

so using the i18n.services.logger.log (warn or error) is easy. If you like you might provide a PR...else i will look into this for future release...just not got the time right now.

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

No branches or pull requests

2 participants