-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Compile to FormatJS compiled format with formatphp compile CLI command
We already have the compilation capability built-in to FormatPHP, for validation purposes. We should expose this to users through a formatphp compile command that works similarly to the formatjs compile command.
This will enable sharing the same translation files across front-end and back-end code.
Background/problem
FormatJS has a special compilation step that helps improve performance and efficiency internally, since it's a type of AST for translation strings. You can read more about the compile command here:
- https://formatjs.io/docs/getting-started/message-distribution
- https://formatjs.io/docs/tooling/cli#compilation
FormatPHP already implements the same AST compilation process in order to validate messages. We need to expose this as a compile command to output the AST and save to a file. With this functionality, users could merge their translation files to usethe same ones for front-end and back-end.
Proposal/solution
Add a compile command to the FormatPHP CLI tool that mirrors the functionality of the FormatJS command of the same name: https://formatjs.io/docs/tooling/cli#compilation