Skip to content

Reconsider where types come from #16

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

Closed
Swatinem opened this issue Feb 8, 2019 · 1 comment
Closed

Reconsider where types come from #16

Swatinem opened this issue Feb 8, 2019 · 1 comment

Comments

@Swatinem
Copy link
Contributor

Swatinem commented Feb 8, 2019

Currently, intl-codegen just collects all the used variables inside the translations to generate some type hints.

The goal here is:

  • we want developers to pass the correct variables to <Localized />
  • we also want translators to make correct use of the available variables inside the translations
  • we want to have richer and better types that ensures correct usage on both sides

The way our usage of intl-codegen has changes shows me that it might be a good idea to define some kind of schema that defines:

  • obviously the message ids that exist
  • the names and types of all the variables
Swatinem added a commit that referenced this issue Mar 27, 2019
this only has support for formatting, no type checking yet.
that should be done as part of #16.

closes #14
@Swatinem
Copy link
Contributor Author

Swatinem commented Jun 1, 2019

I implemented something that is similar to this proposal from fluent: projectfluent/fluent#140
typing for messageformat based definitions is done manually.
currently has support for string, number, datetime, monetary and element.
element is a special case, which accepts React.ReactNode as param, and switches any localization string that has a element param to return Array<React.ReactNode> instead of string.

@Swatinem Swatinem closed this as completed Jun 1, 2019
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

1 participant