Skip to content
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

Implement localization support in Progressive Web App bundle #182

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

Spomky
Copy link
Member

@Spomky Spomky commented Apr 23, 2024

Updated various modules to support localization, primarily adjusting how manifest files are generated and served. Added new "locales" configuration parameter, made necessary adjustments in manifest and service worker compilers. Additionally, refactored the twig runtime to properly handle localized manifest URLs.

Target branch:
Resolves issue #

  • It is a Bug fix
  • It is a New feature
  • Breaks BC
  • Includes Deprecations

@Spomky Spomky added the enhancement New feature or request label Apr 23, 2024
@Spomky Spomky added this to the 1.2.0 milestone Apr 23, 2024
@Spomky Spomky self-assigned this Apr 23, 2024
@Spomky Spomky force-pushed the features/better-translations branch 4 times, most recently from f3df949 to e8fbfef Compare April 23, 2024 11:47
@Spomky
Copy link
Member Author

Spomky commented Apr 23, 2024

Ping @tacman.

This PR will allow to generate multiple translated manifest files.

  1. Make sure your application is already configured for multilanguages: https://symfony.com/doc/7.1/translation.html
  2. Declare the locales you want to use in the configuration file. The public URL shoud contain a placeholder {locale}:
pwa:
    manifest:
        enabled: true
        locales:
            - 'en'
            - 'de'
        public_url: 'site.{locale}.webmanifest'
  1. Tell the Twig fonction to serve the localized manifest: {{ pwa(locale=app.request.locale) }}
  2. Translate your keys as usual. THe domain is pwa e.g. pwa+intl-icu.en.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" target-language="en" datatype="plaintext" original="file.ext">
    <header>
      <tool tool-id="symfony" tool-name="Symfony"/>
    </header>
    <body>
      <trans-unit id="VKDowX61" resname="app.name">
        <source>app.name</source>
        <target>My PWA</target>
      </trans-unit>
    </body>
  </file>
</xliff>

Updated various modules to support localization, primarily adjusting how manifest files are generated and served. Added new "locales" configuration parameter, made necessary adjustments in manifest and service worker compilers. Additionally, refactored the twig runtime to properly handle localized manifest URLs.
@Spomky Spomky force-pushed the features/better-translations branch from e8fbfef to 7d0cf22 Compare April 23, 2024 15:20
@Spomky Spomky merged commit 934f1dc into 1.2.x Apr 23, 2024
7 checks passed
@Spomky Spomky deleted the features/better-translations branch April 23, 2024 16:34
@Spomky Spomky mentioned this pull request Apr 23, 2024
@tacman
Copy link
Contributor

tacman commented Apr 23, 2024

Shouldn't the locales default to the framework enabled_locales key? That way we don't have to manually keep them in sync.

https://symfony.com/doc/current/reference/configuration/framework.html#enabled-locales

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants