Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3424701
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
drupal-3424701
Commits
3e3b6687
Unverified
Commit
3e3b6687
authored
6 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2949825
by Sutharsan, andypost, alexpott: Downloaded translation file...
Issue
#2949825
by Sutharsan, andypost, alexpott: Downloaded translation file should replace existing
parent
a9cd69a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/locale/locale.batch.inc
+1
-1
1 addition, 1 deletion
core/modules/locale/locale.batch.inc
core/modules/locale/tests/src/Functional/LocaleTranslationDownloadTest.php
+65
-0
65 additions, 0 deletions
...le/tests/src/Functional/LocaleTranslationDownloadTest.php
with
66 additions
and
1 deletion
core/modules/locale/locale.batch.inc
+
1
−
1
View file @
3e3b6687
...
@@ -292,7 +292,7 @@ function locale_translation_http_check($uri) {
...
@@ -292,7 +292,7 @@ function locale_translation_http_check($uri) {
* File object if download was successful. FALSE on failure.
* File object if download was successful. FALSE on failure.
*/
*/
function
locale_translation_download_source
(
$source_file
,
$directory
=
'temporary://'
)
{
function
locale_translation_download_source
(
$source_file
,
$directory
=
'temporary://'
)
{
if
(
$uri
=
system_retrieve_file
(
$source_file
->
uri
,
$directory
))
{
if
(
$uri
=
system_retrieve_file
(
$source_file
->
uri
,
$directory
,
FALSE
,
FILE_EXISTS_REPLACE
))
{
$file
=
clone
(
$source_file
);
$file
=
clone
(
$source_file
);
$file
->
type
=
LOCALE_TRANSLATION_LOCAL
;
$file
->
type
=
LOCALE_TRANSLATION_LOCAL
;
$file
->
uri
=
$uri
;
$file
->
uri
=
$uri
;
...
...
This diff is collapsed.
Click to expand it.
core/modules/locale/tests/src/Functional/LocaleTranslationDownloadTest.php
0 → 100644
+
65
−
0
View file @
3e3b6687
<?php
namespace
Drupal\Tests\locale\Functional
;
use
Drupal\Core\StreamWrapper\PublicStream
;
use
Drupal\language\Entity\ConfigurableLanguage
;
use
org\bovigo\vfs\vfsStream
;
/**
* Tests locale translation download.
*
* @group locale
*/
class
LocaleTranslationDownloadTest
extends
LocaleUpdateBase
{
/**
* The virtual file stream for storing translations.
*
* @var \org\bovigo\vfs\vfsStreamDirectory
*/
protected
$translationsStream
;
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
parent
::
setUp
();
$moduleHandler
=
$this
->
container
->
get
(
'module_handler'
);
$moduleHandler
->
loadInclude
(
'locale'
,
'inc'
,
'locale.batch'
);
ConfigurableLanguage
::
createFromLangcode
(
'de'
)
->
save
();
// Let the translations:// stream wrapper point to a virtual file system to
// make it independent from the test environment.
$this
->
translationsStream
=
vfsStream
::
setup
(
'translations'
);
\Drupal
::
configFactory
()
->
getEditable
(
'locale.settings'
)
->
set
(
'translation.path'
,
$this
->
translationsStream
->
url
())
->
save
();
}
/**
* Tests translation download from remote sources.
*/
public
function
testUpdateImportSourceRemote
()
{
// Provide remote and 'previously' downloaded translation file.
$this
->
setTranslationFiles
();
vfsStream
::
create
([
'contrib_module_one-8.x-1.1.de._po'
=>
'__old_content__'
,
],
$this
->
translationsStream
);
$url
=
\Drupal
::
service
(
'url_generator'
)
->
generateFromRoute
(
'<front>'
,
[],
[
'absolute'
=>
TRUE
]);
$uri
=
$url
.
PublicStream
::
basePath
()
.
'/remote/8.x/contrib_module_one/contrib_module_one-8.x-1.1.de._po'
;
$source_file
=
(
object
)
[
'uri'
=>
$uri
,
];
$result
=
locale_translation_download_source
(
$source_file
,
'translations://'
);
$this
->
assertEquals
(
'translations://contrib_module_one-8.x-1.1.de._po'
,
$result
->
uri
);
$this
->
assertFalse
(
file_exists
(
'translations://contrib_module_one-8.x-1.1.de_0._po'
));
$this
->
assertTrue
(
file_exists
(
'translations://contrib_module_one-8.x-1.1.de._po'
));
$this
->
assertNotContains
(
'__old_content__'
,
file_get_contents
(
'translations://contrib_module_one-8.x-1.1.de._po'
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment