function locale_translation_get_status

Same name in other branches
  1. 9 core/modules/locale/locale.module \locale_translation_get_status()
  2. 10 core/modules/locale/locale.module \locale_translation_get_status()
  3. 11.x core/modules/locale/locale.module \locale_translation_get_status()

Gets the current translation status.

@todo What is 'translation status'?

13 calls to locale_translation_get_status()
LocaleConfigTranslationImportTest::testConfigTranslationImport in core/modules/locale/tests/src/Functional/LocaleConfigTranslationImportTest.php
Test update changes configuration translations if enabled after language.
LocaleUpdateInterfaceTest::testInterface in core/modules/locale/tests/src/Functional/LocaleUpdateInterfaceTest.php
Tests the user interfaces of the interface translation update system.
LocaleUpdateTest::testUpdateCheckStatus in core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
Checks if local or remote translation sources are detected.
LocaleUpdateTest::testUpdateImportSourceLocal in core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
Tests translation import from local sources.
LocaleUpdateTest::testUpdateImportSourceRemote in core/modules/locale/tests/src/Functional/LocaleUpdateTest.php
Tests translation import from remote sources.

... See full list

File

core/modules/locale/locale.module, line 884

Code

function locale_translation_get_status($projects = NULL, $langcodes = NULL) {
    $result = [];
    $status = \Drupal::keyValue('locale.translation_status')->getAll();
    module_load_include('translation.inc', 'locale');
    $projects = $projects ? $projects : array_keys(locale_translation_get_projects());
    $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
    // Get the translation status of each project-language combination. If no
    // status was stored, a new translation source is created.
    foreach ($projects as $project) {
        foreach ($langcodes as $langcode) {
            if (isset($status[$project][$langcode])) {
                $result[$project][$langcode] = $status[$project][$langcode];
            }
            else {
                $sources = locale_translation_build_sources([
                    $project,
                ], [
                    $langcode,
                ]);
                if (isset($sources[$project][$langcode])) {
                    $result[$project][$langcode] = $sources[$project][$langcode];
                }
            }
        }
    }
    return $result;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.