-
-
Notifications
You must be signed in to change notification settings - Fork 860
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
Add the path as argument to the custom formatter #489
Conversation
…ions Replace Number and Date format options with standard TS `Intl` types, while also adding guiding TS autocomplete to them. This change exterminates the confusion of which types to follow, while preserving backwards-compatibility for types and adding optional autocomplete.
It's useful to check static variables types whenever possible.
and allow optional formatting
Codecov Report
@@ Coverage Diff @@
## dev #489 +/- ##
==========================================
+ Coverage 96.67% 96.69% +0.01%
==========================================
Files 9 9
Lines 662 665 +3
==========================================
+ Hits 640 643 +3
Misses 22 22
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## dev #489 +/- ##
==========================================
+ Coverage 96.67% 96.69% +0.01%
==========================================
Files 9 9
Lines 662 665 +3
==========================================
+ Hits 640 643 +3
Misses 22 22
Continue to review full report at Codecov.
|
decls/i18n.js
Outdated
@@ -110,5 +110,5 @@ declare interface I18n { | |||
}; | |||
|
|||
declare interface Formatter { | |||
interpolate (message: string, values?: any): Array<any> | |||
interpolate (message: string, values: any, path: string): Array<any> | void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case that interpolate return the nothing, I hope that it's better to be null
than undefined
.
from undefined to null
Closes #484.
Proposed changes to the API:
Formatter now accepts a third argument: path to the message. This is meant to be used in a case if a custom formatter shall have a specific purpose for the specific keys in a translation object.
If a formatter does not want to work with a specific key - it needs to simply return
undefined
.For more details, see proposed API at #484.