✅
PWA Bundle
1.2.x
1.2.x
  • PHPWA Bundle
  • How To Create A PWA?
  • How To Install/Remove A PWA?
  • Bundle Installation
  • Development
  • Events
  • Deployment
  • Debugging
  • The Manifest
    • Application Information
      • Scope
      • ID
      • Direction and Language
      • Orientation
      • Description
      • IARC Rating ID
      • Categories
    • Icons
    • Screenshots
    • Shortcuts
    • Protocol Handlers
    • File Handlers
    • Share Target
    • Complete Example
  • The Service Worker
    • Configuration
    • Content Security Policy
    • Custom Service Worker Rule
    • Custom Cache Strategies
    • Workbox
      • Site Manifest Cache
      • Asset Caching
      • Resource Caching
      • Image Caching
      • Font Caching
      • Offline Fallbacks
      • BackgoundSync
      • CDN and Versions
      • Cache Cleaning
      • Custom Cache Strategy
    • Push Notifications
    • Complete Example
  • Favicons
    • Create Favicons
  • Symfony UX
    • Connection Status
    • Prefetch on demand
    • Sync Broadcast
    • BackgroundSync Form
  • Image Management
    • Icons
    • Screenshots
  • Experimental Features
    • Non-Standard Parameters
      • Launch Handler
      • Display Override
      • Related Applications
      • EDGE Side Panel
    • Translations
    • Widgets (Win10+)
Powered by GitBook
On this page
  • Translatable values
  • How To?
  1. Experimental Features

Translations

The bundle leverages on Symfony Translation component if available. The texts you pass for almost all names, short names, descriptions, labels... are translation keys.

/config/packages/pwa.yaml
pwa:
    manifest:
        enabled: true
        name: "app.name"
        short_name: "app.short_name"
        start_url: "/index.html"
        displa": "standalone"
        background_color: "#ffffff"
        theme_color: "#4285f4"
        shortcuts:
            - name: "app.feature1.shorcut.name"
              short_name: "app.feature1.shorcut.short_name"
              description: "app.feature1.shorcut.description"
              url: "/start-chat"
              icons":          
                - src: "icons/feature1-96x96.png"
                  sizes: [96]

This feature is still in development stage and may not work as expected. Use with caution.

BC is not guaranteed.

Translatable values

The following values are translation keys. The domain is pwa.

Component
Values

Manifest

  • name

  • short_name

  • description

  • categories

  • start_url

Screenshot

  • label

Share Target

  • title

  • text

Shortcut

  • name

  • short_name

  • description

Widget

  • name

  • short_name

  • description

How To?

To enable it, the manifest public URL shall contain the placeholder {locale}.

Example:

/config/packages/pwa.yaml
pwa:
    manifest:
        enabled: true
        public_url: "/site.{locale}.webmanifest"

When done, the Twig function should get the locale to serve the translated version of the manifest.

<!DOCTYPE html>
<html lang="en">
<head>
  {{ pwa(locale=app.request.locale) }}
</head>
<body>
  ...
</body>
</html>

Now you can have translation files for each locale you support:

translations/pwa+intl-icu.en_US.xlf
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
  <file source-language="en-US" target-language="en-US" datatype="plaintext" original="file.ext">
    <header>
      <tool tool-id="symfony" tool-name="Symfony"/>
    </header>
    <body>
      <trans-unit id="f3U2Gqw" resname="app.name">
        <source>app.name</source>
        <target>TODO!</target>
      </trans-unit>
      <trans-unit id="q2FYgid" resname="app.short_name">
        <source>app.short_name</source>
        <target>TODO!</target>
      </trans-unit>
      ...
    </body>
  </file>
</xliff>
PreviousEDGE Side PanelNextWidgets (Win10+)

Last updated 1 year ago

This feature relies on the framework.enabled_locales to generate static manifest files. Please refer to the for more information.

Symfony documentation