-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(i18n): better APIs #8908
feat(i18n): better APIs #8908
Conversation
|
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.
Looking good! Left a few notes about comments that could be improved.
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.
LGTM!
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.
Looks good to me, but my gut feeling is to remove the 'it' from the start of the sentences.
Co-authored-by: Elian ☕️ <[email protected]>
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.
LGTM! but you might want to also want a @sarah11918 review.
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.
Nice work @ematipico! I think the docs looks OK.
One thing I’m wondering is if this feels good to use in practice.
Thoughts:
-
While there is the edge case of
/
wherepath
can be omitted, most uses will provide a path (or will provide one programmatically, so may provide one even when the variable’s value is'/'
or''
). That makes requiring{ path: ... }
feel a bit fiddly. -
What are the most common sources of data people might be feeding into these methods? Should they support things like
getLocaleRelativeUrl('es', Astro.url)
? (i.e. support aURL
type as input, not juststring
.) -
The names are all
get…Url()
, but the return type is a string rather than aURL
. Instead of separate relative and absolute methods could we have a single method, which lets you grab.pathname
for relative or.href
for absolute?
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.
Docs looks good to me
+1 on the function naming & URL input support.
I don't see any problem, we could change the signature of the API to
We could, but I am not sure about the flexibility of the APIs if we decided to have one single function and support for URLs. URLs work only with absolute URLs that have a protocol, and in many cases, users don't need it if they only need relative paths, or we don't have that information ( Essentially, if the user needs a relative path, and we only have one API, it's technically impossible to return a |
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Co-authored-by: Elian ☕️ <[email protected]>
Changes
This PR changes the APIs of the virtual module after some discussion in the RFC.
This PR changes the signature of the PRs, by passing a locale mandatory argument, and then a second argument: an object with a set of options.
This type of signature will allow us to add more options in the future.
The reason why this change was needed is that users might need:
Testing
I updated the tests
Docs
This time I need feedback on the APIs, especially the documentation. I will update the RFC accordingly later