Add a language will never import the translation for modules.

Created on 21 January 2016, about 9 years ago
Updated 30 April 2024, 11 months ago

Problem/Motivation

1. The module/foo/foo.info.yml:

...
interface translation project: foo
interface translation server pattern: modules/foo/translations/%project.%language.po
...

2. write the translation in modules/foo/translations/foo.zh-hans.po
3. Add the "Chinese, Simplified" language in /admin/config/regional/language

result: the translation will not import
expected result: the translation will be imported

After check the code, the locale_translation_batch_fetch_import() in locale.batch.inc will check the $source->type:

    if (isset($source->type)) {
      if ($source->type == LOCALE_TRANSLATION_REMOTE || $source->type == LOCALE_TRANSLATION_LOCAL) {
        $file = $source->files[LOCALE_TRANSLATION_LOCAL];
        module_load_include('bulk.inc', 'locale');
        $options += array(
          'message' => t('Importing translation for %project.', array('%project' => $source->project)),
        );
        // Import the translation file. For large files the batch operations is
        // progressive and will be called repeatedly until finished.
        locale_translate_batch_import($file, $options, $context);

        // The import is finished.
        if (isset($context['finished']) && $context['finished'] == 1) {
          // The import is successful.
          if (isset($context['results']['files'][$file->uri])) {
            $context['message'] = t('Imported translation for %project.', array('%project' => $source->project));

            // Save the data of imported source into the {locale_file} table and
            // update the current translation status.
            locale_translation_status_save($project, $langcode, LOCALE_TRANSLATION_CURRENT, $source->files[LOCALE_TRANSLATION_LOCAL]);
          }
        }
      }
    }

But the $source->type never be set at locale_translation_source_build() in locale.translation.inc.

Proposed resolution

Setup the $source->type at locale_translation_source_build() in locale.translation.inc.

πŸ› Bug report
Status

Closed: outdated

Version

11.0 πŸ”₯

Component
LocaleΒ  β†’

Last updated 4 days ago

Created by

πŸ‡¨πŸ‡³China jian he

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    @jian he, Thank you for reporting this problem.

    There has been no discussion here for 8 years which might mean that this has been fixed in the meantime. A check should also be done to see if there are duplicates of this issue.

    For now, can we get confirmation that this problem still exists on Drupal 10? Thanks.

    Since we need more information to move forward with this issue, I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • Status changed to Closed: outdated 11 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    this was a bug smash daily triage target 18 days ago. On that day I ask in #multilingual about this issue. There was one response, from penyaskito who was not aware that this was a problem in Drupal 10+ and suggested checking Drupal 7. https://drupal.slack.com/archives/C55J600UX/p1712881085175659

    However, this issue was filed on Drupal 8 and the file locale.batch.inc is not in the Drupal 7 code base. Therefore, I will close this as outdated.

Production build 0.71.5 2024