-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby-plugin-manifest): add i18n, localization #13471
feat(gatsby-plugin-manifest): add i18n, localization #13471
Conversation
Huh very cool! I love the idea of supporting i18n manifests! Having both |
Kay agree on the naming 👍 Any thoughts or ideas? We could provide only the first for now and see what feedback we get to start simple..so regex wouldn't be customizable only language has to be defined.. |
@CanRau I love this idea as well. First question, how does the browser know which manifest to use? Second, have you put any thought into implementing this in a way that doesn't break the existing API? If so, is there a reason you didn't choose this method? Thanks for sharing! |
Just read #10250 and saw your discussion around non-breaking API changes. Please expand on why you didn't follow that path if possible. FYI: I know the manifest plugin currently blows up if you configure it multiple times. I believe this could be fixed but it's been a bit since I realized this so I don't remember what causes it. #12754 for ref |
Not sure what is breaking in the proposed API? It's just adding some props, all existing tests pass without a problem. Um, maybe I'm missing something? When you set it up as in the readme example it'll generate all manifests for all languages in the root of the project like And here in gatsby-ssr.js it'll pick the right manifest from the |
@CanRau Thanks for the detailed explanation. I just saw the So you've given examples on how to not duplicate cod using Assign or rest/spread operators. This works well. I'm wondering if it'd be better to keep the shared settings in the module.exports = {
plugins: [
{
resolve: 'gatsby-plugin-manifest',
options: {
name: `GatsbyJS`,
short_name: `GatsbyJS`,
background_color: `#f7f0eb`,
theme_color: `#a2466c`,
display: `standalone`,
manifests: [
{
start_url: `/de/`,
regex: `^/de/.*`,
language: `de`,
},
{
start_url: `/`,
regex: `.*`,
},
],
}
}
]
} This seems more consistent with the existing configuration and simpler to understand what's happening. Anything that is duplicated in the |
Wrong button... |
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 so far. mostly nit picks and then the issue of i18n of icons.
Thank you for your suggestions/comments @moonmeister 🙏 |
@CanRau I understand your reasoning. My thought is let's keep it simple. If using the path is best practice. then let's just build for that. If someone decides they really want to not use path they could contribute that functionality themselves. This keeps the API simpler and more approachable and only adds complexity if the community needs it. If we do decide to keep this let's just make sure it' clearly documented that only one of the options is need. Or we maybe design it so it is a single option. Meaning someone can just type the path or a Regex...then the code determines what it is and uses it appropriately? EDIT: I'm pretty neutral, leaning slightly towards simpler. |
No worries, we all have a lot to do, all fine 👊 😉
I like it 👍 going to bed now, integrating it tomorrow I'm open to dropping the
Would love to know how you'd do that? I mean finding the proper manifest in |
Then let's just KIS (Keep it simple!) and eliminate regex. Using a single option to be one or the other would probably get complicated...but you could probably write a regex to determine if it was regex 🙄. It's a bad idea...just ignore me. |
Just realized we need to make sure this accounts for the use of |
Before merging this I want to discuss if this is actually the best approach: #10250 (comment) |
@moonmeister Think it's already using
Thanks for bringing this up @LekoArts, can't recall my tests and research exactly. Not sure how I missed the Think it's interesting Google uses Pretty sure I've come to the current naming convention from some Stackoverflow but can't find it right now 🤔 think I tested my implementation on our website and it worked, providing the correct manifest depending on the language in pathname, but just tested Chrome though... So should we follow the Chrome Webstore suggestion? Not even 💯 % sure it really applies to web-apps? Probably because of this Google web fundamentals I didn't realized the And then it seems sooner or later people have to implement a Update maybe we go for |
So, I think we need to figure out what of this is actual spec and what of this is Google. Mozilla docs are likely to be closer to the spec. We should build this to enable any spec that exists. I can do more research for tomorrow, for now it's bed time. |
Have a good rest then 😴 👍 Here's some discussion going on in w3c/manifest#676 but there's more to find w3c/manifest?q=i18n |
Curiosity is the enemy of sleep: https://www.w3.org/TR/appmanifest/#internationalization My reading of this is "do what works". For static sites, the proposed seems a good method. Maybe just use the built in "lang" instead of "language". I think both of @LekoArts links are for extension APIs and stores which don't apply, they're a different spec technically. Also, I think event listeners are optional customizations...not required to add to home screen...don't quote me I could be wrong...but at least FF is like this. |
Might not be forever optional https://love2dev.com/blog/beforeinstallprompt/ and this right below the code block sounds reasonable to me
Update: Another note on "add to homescreen" behavior Kay I'm renaming |
Let's leave the event listeners to another PR but sounds like you could open an issue so we don't forget. Yes. Yes. I wouldn't worry about adding it outside the l10n docs Keep the |
Co-Authored-By: CanRau <cansrau@gmail.com>
Co-Authored-By: CanRau <cansrau@gmail.com>
Co-Authored-By: CanRau <cansrau@gmail.com>
Co-Authored-By: CanRau <cansrau@gmail.com>
language manifests in the `manifests` prop now merge top level options as suggested here gatsbyjs#13471 (comment) use option merging style in README docs: change features as suggested here gatsbyjs#13471 (comment)
* rename `manifests` to `localize` * rename `language` to `lang` * include `lang` in manifest file * merge root options and locales * ensure root only merges if it has start_url provided * always generate root options * remove regex * use start_url as matcher * update docs & test
87e8921
to
a938cba
Compare
…e cache busting to file name.
…ring a single build.
… locales. require name based cache busting fixes this issue the simplest.
…ue icon is specified for a locale in automatic mode
@freiksenet Alright, I think I've resolved that issue and added some basic caching to keep duplicate icons from being rebuilt multiple times. The caching made the existing tests do some weird things but I think I have everything passing in a valid way. This Should be ready to merge now. |
Thank you @moonmeister @CanRau! |
Published in |
Thanks a lot for finalizing & shipping it you awesome people!! Thanks a lot! <3 |
With the addition of the localize option in gatsby-plugin-manifest (#13471), multiple manifests can be generated and served depending on the path of the URL. While the correct manifest is served on initial page load, the link to the manifest is never updated even if the user navigates to a page that should include a different manifest. Co-authored-by: Ward Peeters <ward@coding-tech.com>
Description
As introduced here #10250 I thought why not just update my fork and push it
So to use i18n you use the new
manifests
property and give it an array with all versions.The
language
prop works as a filename suffix, so the first array entry will write tomanifest_de.webmanifest
and as a default regex (which is not documented so far).All manifests are written to the root of
/public
It works so far, I'm not exactly sure about all coding styles or if my tests are sufficient, still not enough into testing (really have to get into it!!).
So please let me know if I can improve anything, I'm keen to learn.
Related Issues
Closes #10250