Skip to content

Move languages to site - #706

Merged
giuscris merged 6 commits into
2.xfrom
feature/languages-to-site
Jun 7, 2025
Merged

Move languages to site#706
giuscris merged 6 commits into
2.xfrom
feature/languages-to-site

Conversation

@giuscris

@giuscris giuscris commented Jun 7, 2025

Copy link
Copy Markdown
Member

No description provided.

@giuscris giuscris added this to the 2.0.0 milestone Jun 7, 2025
@giuscris
giuscris requested a review from Copilot June 7, 2025 13:48
@giuscris giuscris self-assigned this Jun 7, 2025
@giuscris giuscris added the enhancement New feature or request label Jun 7, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR moves language configuration from the global system level to per鈥恠ite control, updates various services and controllers to use the new site鈥恖evel API, and migrates translation keys accordingly.

  • Switch panel UI and routing to use Site::languages() instead of system config
  • Introduce LanguagesFactory, Site::setLanguages(), and remove the old loader
  • Migrate translation keys from panel.options.system.languages.* to panel.site.languages.*

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
panel/views/pages/editor.php Update dropdown display check to use site languages
panel/translations/*.yaml Remove old panel.options.system.languages.* and add panel.site.languages.*
formwork/src/Services/Loaders/TranslationsServiceLoader.php Remove unused Languages import and setter call
formwork/src/Panel/Controllers/PagesController.php Use site languages availability and validation
formwork/src/Languages/LanguagesFactory.php Create LanguagesFactory to build language instances
formwork/src/Languages/Languages.php Add hasMultiple() method
formwork/src/Cms/Site.php Inject LanguagesFactory, implement setLanguages()
formwork/src/Cms/App.php Register LanguagesFactory, remove old LanguagesServiceLoader
formwork/routes.php Update language route action to use Site::languages()
formwork/config/system.yaml Remove deprecated languages block
formwork/config/site.yaml Add new languages configuration block
Comments suppressed due to low confidence (4)

formwork/src/Languages/LanguagesFactory.php:18

  • Docblock incorrectly marks default as bool; it should be a string code. Update the type to string|null or similar.
*     @param array{available: list<string>, httpPreferred: bool, default?: bool} $config

panel/views/pages/editor.php:33

  • The method language() does not exist on Site; this should be languages()->hasMultiple().
<?php if ($site->language()->hasMultiple()) : ?>

formwork/routes.php:3

  • Str is used later but not imported. Add use Formwork\Utils\Str; at the top of the file.
use Formwork\Cms\Site;

panel/translations/en.yaml:263

  • Typo in translation: 'prefered' should be spelled 'preferred'.
panel.site.languages.preferredLanguage: Use browser prefered language

@giuscris
giuscris merged commit 75a4ac9 into 2.x Jun 7, 2025
@giuscris
giuscris deleted the feature/languages-to-site branch June 7, 2025 15:42
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