diff --git a/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php b/core/modules/locale/lib/Drupal/locale/StringTranslation/Translator/LocaleTranslation.php similarity index 93% rename from core/modules/locale/lib/Drupal/locale/LocaleTranslation.php rename to core/modules/locale/lib/Drupal/locale/StringTranslation/Translator/LocaleTranslation.php index 0c405dd..4957106 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTranslation.php +++ b/core/modules/locale/lib/Drupal/locale/StringTranslation/Translator/LocaleTranslation.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Core\Language\LocaleTranslation. + * Contains \Drupal\locale\StringTranslation\Translator\LocaleTranslation. */ -namespace Drupal\locale; +namespace Drupal\locale\StringTranslation\Translator; use Drupal\Core\DestructableInterface; use Drupal\Core\Language\Language; @@ -35,7 +35,7 @@ class LocaleTranslation implements TranslatorInterface, DestructableInterface { * Array of \Drupal\locale\LocaleLookup objects indexed by language code * and context. */ - protected $translations; + protected $translations = array(); /** * Constructs a translator using a string storage. diff --git a/core/modules/locale/locale.services.yml b/core/modules/locale/locale.services.yml index 2a1f8f2..5ab727a 100644 --- a/core/modules/locale/locale.services.yml +++ b/core/modules/locale/locale.services.yml @@ -11,7 +11,7 @@ services: class: Drupal\locale\StringDatabaseStorage arguments: ['@database'] string_translator.locale.lookup: - class: Drupal\locale\LocaleTranslation + class: Drupal\locale\StringTranslation\Translator\LocaleTranslation arguments: ['@locale.storage'] tags: - { name: string_translator } diff --git a/core/modules/locale/tests/Drupal/locale/Tests/StringTranslation/Translator/LocaleTranslationTest.php b/core/modules/locale/tests/Drupal/locale/Tests/StringTranslation/Translator/LocaleTranslationTest.php new file mode 100644 index 0000000..f5860bb --- /dev/null +++ b/core/modules/locale/tests/Drupal/locale/Tests/StringTranslation/Translator/LocaleTranslationTest.php @@ -0,0 +1,53 @@ + 'Locale translation tests', + 'description' => 'Test locale module translatiob implementation.', + 'group' => 'locale', + ); + } + + /** + * {@inheritdoc} + */ + protected function setUp() { + $this->storage = $this->getMock('Drupal\locale\StringStorageInterface'); + } + + /** + * Tests for \Drupal\locale\Tests\LocaleTranslationTest::destruct() + */ + public function testDestruct() { + $translation = new LocaleTranslation($this->storage); + // Prove that destruction works without errors when translations are empty. + $this->assertAttributeEmpty('translations', $translation); + $translation->destruct(); + } + +}