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

Add the path as argument to the custom formatter #489

Merged
merged 9 commits into from
Dec 21, 2018

Conversation

Raiondesu
Copy link
Contributor

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.

…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.
@codecov-io
Copy link

codecov-io commented Dec 19, 2018

Codecov Report

Merging #489 into dev will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/index.js 99.64% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 439ed69...30c71bd. Read the comment docs.

@codecov-io
Copy link

Codecov Report

Merging #489 into dev will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/index.js 99.64% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 439ed69...511148b. Read the comment docs.

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
Copy link
Owner

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.

@kazupon kazupon merged commit b9437ea into kazupon:dev Dec 21, 2018
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

Successfully merging this pull request may close these issues.

3 participants