Skip to content

Auto-Set Locale from HTML-lang-attribute when used with international routing  #486

@mkrauser

Description

@mkrauser

We have international routes enabled in our project and we use FosJsRouting with encore like this:

// webpack.config.js
  ...
  .addPlugin(
    new FosRouting({
      locale: "de",
      target: "var/cache/frontend/fosRoutes.json",
    })
  )

I thought, that the locale given here is just the default (or fallback) locale, but this is not the case.
And there is not documented way, of setting the locale after Routing has been initialized. I tried calling Routing.setLocale manually, but the routes were loaded after that by webpack so my setting was overridden.
It would be nice, if the current locale can be read from html-tag attributes (like the symfony ux translator bundle: https://github.com/symfony/ux/blob/412da630824772f1fcb4d363b24b243a7165c4a0/src/Translator/assets/src/translator.ts#L47)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions