Skip to content

Part options support for $n #2170

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

Merged
merged 5 commits into from
Apr 28, 2025

Conversation

mauryapari
Copy link
Contributor

@mauryapari mauryapari commented Apr 26, 2025

Added test cases for the same
@kazupon kazupon added the Type: Feature Includes new features label Apr 27, 2025
@kazupon kazupon requested a review from Copilot April 27, 2025 10:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for part options with the n function, allowing it to return detailed number formatting parts. Key changes include adding new test cases to verify part formatting, updating type assertions in the tests, and modifying the n function’s return type in the composer module.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/vue-i18n-core/test/composer.test.ts Added new test case “part formating with n” to verify number part formatting support
packages/vue-i18n-core/test/composer.test-d.ts Updated type assertions for the n function’s return type to support part formatting
packages/vue-i18n-core/src/composer.ts Changed the n function’s return type from string to string

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Size Report

Bundles

File Size Gzip Brotli
core.esm-browser.prod.js 38.05 kB 11.62 kB 10.39 kB
core.global.prod.js 31.11 kB 10.78 kB 9.67 kB
core.runtime.esm-browser.prod.js 23.77 kB 7.71 kB 6.90 kB
core.runtime.global.prod.js 18.08 kB 7.04 kB 6.32 kB
message-compiler.esm-browser.prod.js 19.29 kB 5.76 kB 5.14 kB
message-compiler.global.prod.js 17.32 kB 5.55 kB 4.98 kB
petite-vue-i18n-core.esm-browser.prod.js 20.67 kB 6.96 kB 6.26 kB
petite-vue-i18n-core.global.prod.js 15.63 kB 6.06 kB 5.51 kB
petite-vue-i18n.esm-browser.prod.js 36.98 kB 11.34 kB 10.17 kB
petite-vue-i18n.global.prod.js 29.84 kB 10.19 kB 9.20 kB
petite-vue-i18n.runtime.esm-browser.prod.js 22.55 kB 7.33 kB 6.63 kB
petite-vue-i18n.runtime.global.prod.js 16.83 kB 6.40 kB 5.80 kB
vue-i18n.esm-browser.prod.js 50.67 kB (+0.01 kB) 15.15 kB (-0.00 kB) 13.54 kB (+0.00 kB)
vue-i18n.global.prod.js 40.54 kB (+0.01 kB) 13.61 kB (+0.00 kB) 12.25 kB (+0.01 kB)
vue-i18n.runtime.esm-browser.prod.js 36.24 kB (+0.01 kB) 11.15 kB (-0.00 kB) 10.02 kB (+0.00 kB)
vue-i18n.runtime.global.prod.js 27.52 kB (+0.01 kB) 9.86 kB (+0.00 kB) 8.89 kB (+0.00 kB)

Usages

Name Size Gzip Brotli
packages/size-check-core (@intlify/core) 9.22 kB 3.82 kB 3.46 kB
packages/size-check-petite-vue-i18n (petite-vue-i18n) 77.63 kB 30.24 kB 27.28 kB
packages/size-check-vue-i18n (vue-i18n) 82.84 kB (+0.01 kB) 31.74 kB (-0.00 kB) 28.54 kB (+0.03 kB)

Copy link

pkg-pr-new bot commented Apr 27, 2025

Open in StackBlitz

@intlify/core

npm i https://pkg.pr.new/@intlify/core@2170

@intlify/core-base

npm i https://pkg.pr.new/@intlify/core-base@2170

@intlify/devtools-types

npm i https://pkg.pr.new/@intlify/devtools-types@2170

@intlify/message-compiler

npm i https://pkg.pr.new/@intlify/message-compiler@2170

petite-vue-i18n

npm i https://pkg.pr.new/petite-vue-i18n@2170

@intlify/shared

npm i https://pkg.pr.new/@intlify/shared@2170

vue-i18n

npm i https://pkg.pr.new/vue-i18n@2170

@intlify/vue-i18n-core

npm i https://pkg.pr.new/@intlify/vue-i18n-core@2170

commit: c7471d9

@kazupon
Copy link
Member

kazupon commented Apr 27, 2025

The below comments are our notes:

  • support the part options for d ($d)
  • back-port for v11

@kazupon
Copy link
Member

kazupon commented Apr 27, 2025

@mauryapari
Thank you for your contribution!
I've just reviewed your PR.
Your implementation is, LGTM

If you can improve the type of my comments, please take up the challenge. If you can't, I will have someone else work on it as a separate issue.
Please feel free to comment. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If n ($n) will pass the NumberOptions, n ($n) would be a good, inferred return type,
such as, pass string or Intl.NumberFormatPart[] to type parameter and the return type of it, or automatically infer from NumberOptions

$n(value: number, options: NumberOptions): string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am new to Typescript and have tried to add the change you requested. Please have a look.
Do let me know if I might have missed something. I'll work on that.
Thanks

@mauryapari
Copy link
Contributor Author

If you can improve the type of my comments, please take up the challenge.

By improving the type of comments, do you mean should I add some details to the below new issues you opened?

  • support the part options for d ($d)
  • back-port for v11

Sorry if I misunderstood. Could you please clarify?

@kazupon
Copy link
Member

kazupon commented Apr 27, 2025

By improving the type of comments, do you mean should I add some details to the below new issues you opened?

  • support the part options for d ($d)
  • back-port for v11

Sorry if I misunderstood. Could you please clarify?

Sorry, my poor explanation.

That meas is type improvement of this PR.
Those items are already open as separate issues.

@mauryapari
Copy link
Contributor Author

Okay Got it. Thanks. I have added type improvement as you asked. Do let me know if that is fine. :)

@kazupon
Copy link
Member

kazupon commented Apr 28, 2025

Thanks! LGTM!

@kazupon kazupon merged commit 07143af into intlify:master Apr 28, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Includes new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

part option for n fails with an error
2 participants