/**
* Form constructor for the translation import screen.
+ *
+ * @internal
*/
class ImportForm extends FormBase {
$container->get('language_manager')
);
}
+
/**
* Constructs a form for language import.
*
],
'#size' => 50,
'#upload_validators' => $validators,
+ '#upload_location' => 'translations://',
'#attributes' => ['class' => ['file-import-input']],
];
$form['langcode'] = [
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
- $this->file = file_save_upload('file', $form['file']['#upload_validators'], 'translations://', 0);
+ $this->file = _file_save_upload_from_form($form['file'], $form_state, 0);
// Ensure we have the file uploaded.
if (!$this->file) {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- \Drupal::moduleHandler()->loadInclude('locale', 'translation.inc');
+ $this->moduleHandler->loadInclude('locale', 'translation.inc');
// Add language, if not yet supported.
$language = $this->languageManager->getLanguage($form_state->getValue('langcode'));
if (empty($language)) {
$language = ConfigurableLanguage::createFromLangcode($form_state->getValue('langcode'));
$language->save();
- drupal_set_message($this->t('The language %language has been created.', ['%language' => $this->t($language->label())]));
+ $this->messenger()->addStatus($this->t('The language %language has been created.', ['%language' => $this->t($language->label())]));
}
$options = array_merge(_locale_translation_default_update_options(), [
'langcode' => $form_state->getValue('langcode'),
batch_set($batch);
// Create or update all configuration translations for this language.
- \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
if ($batch = locale_config_batch_update_components($options, [$form_state->getValue('langcode')])) {
batch_set($batch);
}