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

Populate contao_ Symfony translations into $GLOBALS['TL_LANG'] #6518

Merged
merged 12 commits into from Nov 22, 2023

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Nov 13, 2023

Currently we cannot override contao/languages/ translations via Symfony translations in translations/. Also we cannot provide labels for DCA fields via Symfony translations. Our goal is to move away from the old Contao translations in $GLOBALS['TL_LANG'] and this PR provides a first step.

This PR simply populates the $GLOBALS['TL_LANG'] array with any Symfony translations that are found within the contao_* translation domains. Thus you are able to override regular Contao translations in your App like this for example:

# translations/contao_default.en.yaml
MSC:
    goBack: Back to the Future

# equivalent to:
MSC.goBack: Back to the Future

And if your App or extension provides new fields for tl_content for example, the labels can now also be provided via Symfony translations:

# translations/contao_tl_content.en.yaml
tl_content:
    myField:
        - Title of the field
        - Description of the field.
    anotherField:
        - Lorem ipsum title
        - Dolor sit description.

This makes creating translation files more comfortable when manually writing them in YAML (in case you are not using services like Transifex).

Notes:

  • The new LegacyGlobalsProcess helper class extracts functionality that are both needed by the XliffFileLoader and MessageCatalogue when processing these legacy translations.
  • The special handling for tl_layout is there due to the reset.css etc. option values.
  • If an extension provides its labels via Symfony translations, then they can only be overwritten via Symfony translations in your App as well.

@fritzmg fritzmg added this to the 5.3 milestone Nov 13, 2023
@fritzmg fritzmg self-assigned this Nov 13, 2023
@fritzmg
Copy link
Contributor Author

fritzmg commented Nov 13, 2023

Another note: this also removes the OutOfBoundsException if "too many" nesting levels are used in the id of an XLIFF translation. I don't think this arbitrary limitation was ever necessary?

@fritzmg
Copy link
Contributor Author

fritzmg commented Nov 13, 2023

Another note: this now uses var_export (as discussed with @ausi) which also fixes some things that were inconsistent between dev and prod.

ausi
ausi previously approved these changes Nov 13, 2023
@leofeyer leofeyer merged commit 79fcdbf into contao:5.x Nov 22, 2023
16 checks passed
@leofeyer
Copy link
Member

Thank you @fritzmg.

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

Successfully merging this pull request may close these issues.

None yet

3 participants