eversport / intl-codegen

generate code and type definitions from translations
MIT License
15 stars 1 forks source link

Reconsider where types come from #16

Closed Swatinem closed 5 years ago

Swatinem commented 5 years ago

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

The goal here is:

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:

Swatinem commented 5 years ago

I implemented something that is similar to this proposal from fluent: https://github.com/projectfluent/fluent/issues/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.