Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
locale_deploy
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
locale_deploy
Merge requests
!14
Prevent installer downloading translations unnecessarily
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Prevent installer downloading translations unnecessarily
issue/locale_deploy-3524389:3524389-during-an-installation
into
1.0.x
Overview
0
Commits
1
Pipelines
2
Changes
1
Merged
Alex Pott
requested to merge
issue/locale_deploy-3524389:3524389-during-an-installation
into
1.0.x
1 month ago
Overview
0
Commits
1
Pipelines
2
Changes
1
Expand
Closes
#3524389
0
0
Merge request reports
Compare
1.0.x
version 1
352f092e
1 month ago
1.0.x (base)
and
latest version
latest version
352f092e
1 commit,
1 month ago
version 1
352f092e
1 commit,
1 month ago
1 file
+
21
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
locale_deploy.install
+
21
−
0
Options
@@ -5,6 +5,9 @@
* Install, update and uninstall functions for the Locale Deploy module.
*/
use
Drupal\Core\Installer\InstallerKernel
;
use
Drupal\Core\Language\LanguageInterface
;
/**
* Implements hook_install().
*/
@@ -12,6 +15,24 @@ function locale_deploy_install(bool $is_syncing): void {
if
(
!
$is_syncing
)
{
_locale_deploy_config_fix
();
}
// Prevent install_config_download_translations() from doing unnecessary
// downloads during an install. This code is inspired by
// install_find_translations().
if
(
InstallerKernel
::
installationAttempted
()
&&
$is_syncing
)
{
global
$install_state
;
$files
=
\Drupal
::
service
(
'file_system'
)
->
scanDirectory
(
'translations://'
,
'!drupal\.'
.
LanguageInterface
::
VALID_LANGCODE_REGEX
.
'\.po$!'
,
[
'recurse'
=>
FALSE
]);
foreach
(
$files
as
$uri
=>
$file
)
{
// Strip off the file name component before the language code.
$langcode
=
preg_replace
(
'!^(.+\.)?([^\.]+)$!'
,
'\2'
,
$file
->
name
);
// Language codes cannot exceed 12 characters to fit into the {language}
// table.
if
(
strlen
(
$langcode
)
<=
12
)
{
$install_state
[
'translations'
][
$langcode
]
=
$uri
;
}
}
}
}
/**
Loading