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

Support react-i18next "defaults" prop #82

Closed
beheh opened this issue Jun 6, 2018 · 1 comment
Closed

Support react-i18next "defaults" prop #82

beheh opened this issue Jun 6, 2018 · 1 comment

Comments

@beheh
Copy link
Contributor

beheh commented Jun 6, 2018

Version

  • i18next: 11.2.2
  • i18next-scanner: 2.4.6
  • react-i18next: 7.7.0

Configuration

options: {
	// use strings as keys
	nsSeparator: false,
	keySeparator: false,
	// settings
	defaultNs: "frontend",
	lngs: ["en"],
	resource: {
		loadPath: "{{lng}}/{{ns}}.json",
		savePath: "{{lng}}/{{ns}}.json",
	},
	func: false,
	trans: false,
	defaultValue: (language, namespace, key) => key,
},

react-i18n v7.7.0 introduced the defaults prop (see i18next/react-i18next#439). I expect the following code:

<Trans
  defaults="Hello <0>{val}</0>!"
  tOptions={{val: "World"}}
  components=[<strong>foo</strong>]
/>

to lead to the following output:

{
  "Hello <0>{val}</0>!": "Hello <0>{val}</0>!"
}
@beheh
Copy link
Contributor Author

beheh commented Jun 6, 2018

It looks like this needs at least 3 things:

  • add support for the defaults attribute (probably overridable like the i18nKey prop)
  • add support for self-closing Trans components
  • add support for <\d>s inside attributes

Especially the latter two probably mean rewriting the regular expression a bit.

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