When using PWA Shortcuts, is it possible to localize the shortcut name?

Viewed 243

Our PWA is used globally and is localized for users.

If we use PWA shortcuts, is it possible to localize the shortcut names in the manifest.json file?

https://web.dev/app-shortcuts/

For example, if we had a shortcut called "Search", I would want that to appear in Japanese "検索" for a user with a Japanese language set in their operating system.

1 Answers

There's no way to specify different language strings in the manifest today, the only way to do it would be to serve a different manifest depending on the language of the users browser.

There are two options for doing that:

  1. Have the server return a different manifest file depending on the Accept-Language HTTP header sent by the users browser.
  2. Add (or update) the manifest link in the page after checking the users preferred language.

Personally, I'd recommend the first option. The manifest file name would remain the same for all users, and it would require no client side code and wouldn't affect page performance in any way.

The second would require JavaScript to update the manifest link, and while not expensive, the less client side code you run, the better. It also means each language would have it's own manifest file, so if I change my browser language, I may be prompted to install the PWA again because it's now a new manifest.

Related