Localisation & 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.
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]
Translatable values
The following values are translation keys. The domain is pwa
.
Manifest
name
short_name
description
categoriesstart_url
Screenshot
label
Share Target
title
text
Shortcut
name
short_name
description
Widget
name
short_name
description
The value categories
should not be translated. This capability will be removed in 2.0.0.
The value start_url cannot be translated since 1.3.0 (BC break). See the migration path.
How To?
This feature relies on the framework.enabled_locales
to generate static manifest files. Please refer to the Symfony documentation for more information.
To enable it, the manifest public URL shall contain the placeholder {locale}
. Also, if you defined the lang
parameter, please remove it; it will automatically set by the bundle.
Example:
pwa:
manifest:
enabled: true
public_url: "/site.{locale}.webmanifest"
When done, the Twig function should provide a translated version of the Web Manifest. Since 1.3.0, there is no need to set a parameter to the Twig function.
<!DOCTYPE html>
<html lang="{{ app.request.locale }}">
<head>
{{ pwa() }}
</head>
<body>
...
</body>
</html>
Now you can have translation files for each locale you support:
<?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>
Last updated
Was this helpful?