-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 page localization #7128
Add page localization #7128
Conversation
* commit 'ccb045b68c5b4d983a90fa125513fc476e4e2387': fix: upgrade @graphql-tools/links from 6.2.4 to 6.2.5 (parse-community#7007) fix: upgrade pg-promise from 10.7.0 to 10.7.1 (parse-community#7009) fix: upgrade jwks-rsa from 1.10.1 to 1.11.0 (parse-community#7008) fix: upgrade graphql from 15.3.0 to 15.4.0 (parse-community#7011) update stale bot (parse-community#6998) fix(beforeSave/afterSave): Return value instead of Parse.Op for nested fields (parse-community#7005) fix(beforeSave): Skip Sanitizing Database results (parse-community#7003) Fix includeAll for querying a Pointer and Pointer array (parse-community#7002) Init (parse-community#6999)
…cases; introduced localization test cases
Codecov Report
@@ Coverage Diff @@
## master #7128 +/- ##
==========================================
+ Coverage 93.92% 94.00% +0.07%
==========================================
Files 169 172 +3
Lines 12547 12835 +288
==========================================
+ Hits 11785 12065 +280
- Misses 762 770 +8
Continue to review full report at Codecov.
|
c95aeba
to
389fb06
Compare
…-localization * commit '6097e82194772847954dc2c2b7559543cc7531cc': fix: upgrade mime from 2.4.7 to 2.5.0 (parse-community#7166) fix: upgrade pg-promise from 10.8.7 to 10.9.0 (parse-community#7168) fix: upgrade apollo-server-express from 2.19.1 to 2.19.2 (parse-community#7165) Upgrade @node-rs/bcrypt to latest version (parse-community#7159) Run Prettier after Definitions (parse-community#7164) # Conflicts: # package-lock.json
…-localization * commit 'b59517fd68a56885c9ab73525526e42ff4003333': Add tests against multiple MongoDB versions (parse-community#7161) # Conflicts: # CHANGELOG.md # README.md # package-lock.json
This is ready for review to merge as experimental feature. Since this is a rather extensive PR, a good starting point for review may be the new localization section in README.md that describes the features. |
…-localization * commit 'cca493b9fb33a4c34eaaf624ec4aedd18b11dca7': fix: upgrade pg-promise from 10.9.0 to 10.9.1 (parse-community#7170)
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.
Great job, @mtrezza . That's an awesome feature. LGTM!
Thanks @davimacedo. I expect this to replace the @TomWFox What do you think would be a good place to encourage developers to turn on this experimental feature so we can get more feedback? A pinned GitHub issue? |
* commit '7f47b0427ea56214d9b0199f0fcfa4af38794e02': Add page localization (parse-community#7128) Improve contribution guide (parse-community#7075) fix: upgrade pg-promise from 10.9.0 to 10.9.1 (parse-community#7170) Add tests against multiple MongoDB versions (parse-community#7161) fix: upgrade mime from 2.4.7 to 2.5.0 (parse-community#7166) fix: upgrade pg-promise from 10.8.7 to 10.9.0 (parse-community#7168) fix: upgrade apollo-server-express from 2.19.1 to 2.19.2 (parse-community#7165) Upgrade @node-rs/bcrypt to latest version (parse-community#7159) Run Prettier after Definitions (parse-community#7164)
* added localized pages; added refactored page templates; adapted test cases; introduced localization test cases * added changelog entry * fixed test description typo * fixed bug in PromiseRouter where headers are not added for text reponse * added page parameters in page headers for programmatic use * refactored tests for PublicAPIRouter * added mustache lib for template rendering * fixed fs.promises module reference * fixed template placeholder typo * changed redirect response to provide headers instead of query parameters * fix lint * fixed syntax errors and typos in html templates * removed obsolete URI encoding * added locale inferring from request body and header * added end-to-end localizaton test * added server option validation; refactored pages server option * fixed invalid redirect URL for no locale matching file * added end-to-end localizaton tests * adapted tests to new response content * re-added PublicAPIRouter; added PagesRouter as experimental feature * refactored PagesRouter test structure * added configuration option for custom path to pages * added configuration option for custom endpoint to pages * fixed lint * added tests * added a distinct page for invalid password reset link * renamed generic page invalidLink to expiredVerificationLink * improved HTML files documentation * improved HTML files documentation * changed changelog entry for experimental feature * improved file naming to make it more descriptive * fixed file naming and env parameter naming * added readme entry * fixed readme TOC - hasn't been updated in a while * added localization with JSON resource * added JSON localization to feature pages (password reset, email verification) * updated readme * updated readme * optimized JSON localization for feature pages; added e2e test case * fixed readme typo * minor refactoring of existing tests * fixed bug where Object type was not recognized as config key type * added feature config placeholders * prettier * added passing locale to page config placeholder callback * refactored passing locale to placeholder to pass test * added config placeholder feature to README * fixed typo in README
🎉 This change has been released in version 5.0.0-beta.1 |
🎉 This change has been released in version 5.0.0 |
New Pull Request Checklist
Issue Description
Allows to localize the Parse Server pages by handling an optional user locale in the query of the public API routes, such as:
Related issue: closes #7127
Approach
PagesRouter.js
as experimental feature (disabled by default) to replacePublicAPIRouter.js
locale
parameterSubdirectory structure:
JSON resource:
Pages are localized by adding placeholders in the HTML files and providing a JSON resource that contains the translations to fill into the placeholders.
Example JSON Content:
public
directory; localization is disabled ifcustomPages
are set (even if the custom pages point to the default pages).Changes
x-parse-page-param-...
to serve the template placeholders additionally in response headers for programmatic use of response.invalid password reset link
andinvalid email verification link
instead of generic pageinvalid link
to allow for more specific user instructions.Breaking changes (when enabling the experimental feature)
public
directory renamedpublic_html
topublic
.views
directory merged withpublic
directorypublic
directory.public
directory, as these files can be served directly or via redirect; removing the hard differentiation by directory allows for more flexibility.views
topublic
directory; mind renaming the files if necessary, see the example template files names in thepublic
directory.apps/choosePassword
has been renamed fromid
toappId
.appId
.invalid_link.html
has been splitinvalid_link.html
has been replaced and split into the more specificpassword_reset_link_invalid.html
andemail_verification_link_invalid.html
.invalid_link.html
for different use cases was shown; using different templates allows for more specific user instructions on how to resolve the issue.Unrelated changes (as side effect)
buildConfigDefinitions
whereObject
type was not recognized as config key typeCaveats
Removing feature flag
Todos when removing the feature flag in the future:
pages.enableRouter
option, this was just used to turn on the experimental featurepublic_html
,views
(PagesRouter only uses files inpublic
)customPages
, they becomepages.customUrls
in thePagesRouter
choose_password
->password_reset
to match naming through code and templates (only the endpoint is namedchoose password
, everything else is namedpassword reset
); also review other endpoint names (verificationEmailRequest
,requestPasswordReset
).Config.js
theget xxxURL()
methods, e.g.verifyEmailSuccessURL()
.Notes
PagesRouter
can be enabled without localization. While the main feature of this new router is the ability to localize, it is not the only improvement compared to the currentPublicAPIRouter
. You are encouraged to try the new router with or without localization so we receive feedback before removing the feature flag.TODOs before merging
[ ] Incorporate outcome of discussion in Remove username from password reset / email verification links #7137; adapt routes if username is removed