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

[spiral/translator] Adding the ability to register additional translation directories #996

Merged
merged 3 commits into from
Sep 20, 2023

Conversation

msmakouz
Copy link
Member

@msmakouz msmakouz commented Sep 19, 2023

Q A
Bugfix?
Breaks BC?
New feature? ✔️
Issues #951

What was changed

Added the ability to register additional directories with translation files for the Translator component.
This can be useful when developing additional packages for the Spiral Framework, where the package may provide translation files (for example, validators). Translation files in an application can override translations from additional directories.

A directory with translations can be registered via the Spiral\Bootloader\I18nBootloader bootloader or translator.php configuration file.

Via I18nBootloader bootloader

use Spiral\Boot\Bootloader\Bootloader;
use Spiral\Bootloader\I18nBootloader;

final class AppBootloader extends Bootloader
{
    public function init(I18nBootloader $i18n): void
    {
        $i18n->addDirectory('some/directory');
    }
}

Via configuration file

return [
    // ...
    'directories' => [
        'some/directory'
    ],
    // ...
];

@msmakouz msmakouz added this to the 3.9 milestone Sep 19, 2023
@msmakouz msmakouz self-assigned this Sep 19, 2023
@msmakouz msmakouz changed the title Add the ability to register additional locales directories [spiral/translator] Adding the ability to register additional translation directories Sep 19, 2023
@msmakouz msmakouz linked an issue Sep 19, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (fe8484a) 89.43% compared to head (9cf690e) 89.43%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #996   +/-   ##
=========================================
  Coverage     89.43%   89.43%           
- Complexity     6093     6104   +11     
=========================================
  Files           801      801           
  Lines         17204    17225   +21     
=========================================
+ Hits          15386    15406   +20     
- Misses         1818     1819    +1     
Files Changed Coverage Δ
src/Framework/Bootloader/I18nBootloader.php 100.00% <100.00%> (ø)
src/Translator/src/Catalogue/CatalogueLoader.php 96.72% <100.00%> (+0.97%) ⬆️
src/Translator/src/Config/TranslatorConfig.php 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@butschster butschster merged commit 90b95aa into master Sep 20, 2023
9 checks passed
@butschster butschster deleted the feature/translation-directories branch September 20, 2023 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[spiral/translator] Load translations from many directories
2 participants