Commit bb8be56e authored by Alex Bronstein's avatar Alex Bronstein
Browse files

Issue #1832946 by Sutharsan, Jose Reyero, Gábor Hojtsy, Wim Leers, vijaycs85:...

Issue #1832946 by Sutharsan, Jose Reyero, Gábor Hojtsy, Wim Leers, vijaycs85: Runtime translation download fallback works different from installer translation download fallback
parent 866be5fb
Loading
Loading
Loading
Loading
+1 −1
Changes for core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
 */
class LanguageNegotiationFormOverrideTest extends WebTestBase {

  public static $modules = array('language', 'locale');
  public static $modules = array('language', 'locale', 'locale_test');

  /**
   * Tests that overrides do not affect language-negotiation form values.
+1 −1
Changes for core/modules/language/src/Tests/LanguageSwitchingTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ class LanguageSwitchingTest extends WebTestBase {
   *
   * @var array
   */
  public static $modules = array('locale', 'language', 'block', 'language_test', 'menu_ui');
  public static $modules = array('locale', 'locale_test', 'language', 'block', 'language_test', 'menu_ui');

  protected function setUp() {
    parent::setUp();
+10 −31
Changes for core/modules/locale/locale.compare.inc: 10 added lines, 31 removed lines.
Original line number Diff line number Diff line
@@ -44,11 +44,6 @@ function locale_translation_flush_projects() {
 *   - "status": Project status, 1 = enabled.
 */
function locale_translation_build_projects() {
  // This function depends on Update module. We degrade gracefully.
  if (!\Drupal::moduleHandler()->moduleExists('update')) {
    return array();
  }

  // Get the project list based on .info.yml files.
  $projects = locale_translation_project_list();

@@ -57,35 +52,20 @@ function locale_translation_build_projects() {

  $default_server = locale_translation_default_translation_server();

  // If project is a dev release, or core, find the latest available release.
  $project_updates = update_get_available(TRUE);
  foreach ($projects as $name => $data) {
    if (isset($project_updates[$name]['releases']) && $project_updates[$name]['project_status'] != 'not-fetched') {
      // Find out if a dev version is installed.
      if (preg_match("/^\d+\.x-(\d+)\..*-dev$/", $data['info']['version'], $matches) ||
          preg_match("/^(\d+)\.\d+\.\d+.*-dev$/", $data['info']['version'], $matches)) {
        // Find a suitable release to use as alternative translation.
        foreach ($project_updates[$name]['releases'] as $project_release) {
          // The first release with the same major release number which is not a
          // dev release is the one. Releases are sorted the most recent first.
          // For example the major release number for a contrib module
          // 8.x-2.x-dev is "2", for core 8.1.0-dev is "8".
          // @todo https://www.drupal.org/node/1774024 Make a helper function.
          if ($project_release['version_major'] == $matches[1] &&
              (!isset($project_release['version_extra']) || $project_release['version_extra'] != 'dev')) {
            $release = $project_release;
            break;
    // For dev releases, remove the '-dev' part and trust the translation server
    // to fall back to the latest stable release for that branch.
    if (isset($data['info']['version']) && strpos($data['info']['version'], '-dev')) {
      if (preg_match("/^(\d+\.x-\d+\.).*$/", $data['info']['version'], $matches)) {
        // Example matches: 8.x-1.x-dev, 8.x-1.0-alpha1+5-dev => 8.x-1.x
        $data['info']['version'] = $matches[1] . 'x';
      }
      elseif (preg_match("/^(\d+\.\d+\.).*$/", $data['info']['version'], $matches)) {
        // Example match: 8.0.0-dev => 8.0.x (Drupal core)
        $data['info']['version'] = $matches[1] . 'x';
      }
    }

      if (!empty($release['version'])) {
        $data['info']['version'] = $release['version'];
      }

      unset($release);
    }

    // For every project store information.
    $data += array(
      'name' => $name,
@@ -96,6 +76,7 @@ function locale_translation_build_projects() {
      'server_pattern' => isset($data['info']['interface translation server pattern']) && $data['info']['interface translation server pattern'] ? $data['info']['interface translation server pattern'] : $default_server['pattern'],
      'status' => !empty($data['project_status']) ? 1 : 0,
    );

    $project = (object) $data;
    $projects[$name] = $project;

@@ -117,8 +98,6 @@ function locale_translation_build_projects() {
function locale_translation_project_list() {
  $projects = &drupal_static(__FUNCTION__, array());
  if (empty($projects)) {
    module_load_include('compare.inc', 'update');
    $config = \Drupal::config('locale.settings');
    $projects = array();

    $additional_whitelist = array(
+1 −1
Changes for core/modules/locale/locale.translation.inc: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ function locale_translation_get_projects(array $project_names = array()) {
    $row_count = \Drupal::service('locale.project')->countProjects();
    // https://www.drupal.org/node/1777106 is a follow-up issue to make the
    // check for possible out-of-date project information more robust.
    if ($row_count == 0 && \Drupal::moduleHandler()->moduleExists('update')) {
    if ($row_count == 0) {
      module_load_include('compare.inc', 'locale');
      // At least the core project should be in the database, so we build the
      // data if none are found.
+0 −6
Changes for core/modules/locale/src/Form/TranslationStatusForm.php: 0 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -232,9 +232,6 @@ protected function prepareUpdateData(array $status) {
   * This method will produce debug information including the respective path(s)
   * based on this setting.
   *
   * Translations for development versions are never fetched, so the debug info
   * for that is a fixed message.
   *
   * @param array $project_info
   *   An array which is the project information of the source.
   *
@@ -245,9 +242,6 @@ protected function createInfoString($project_info) {
    $remote_path = isset($project_info->files['remote']->uri) ? $project_info->files['remote']->uri : FALSE;
    $local_path = isset($project_info->files['local']->uri) ? $project_info->files['local']->uri : FALSE;

    if (strpos($project_info->version, 'dev') !== FALSE) {
      return $this->t('No translation files are provided for development releases.');
    }
    if (locale_translation_use_remote_source() && $remote_path && $local_path) {
      return $this->t('File not found at %remote_path nor at %local_path', array(
        '%remote_path' => $remote_path,
Loading