3 namespace Drupal\language\Plugin\migrate\source;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
11 * source_module = "locale"
14 class Language extends DrupalSqlBase {
19 public function fields() {
21 'language' => $this->t('The language code.'),
22 'name' => $this->t('The English name of the language.'),
23 'native' => $this->t('The native name of the language.'),
24 'direction' => $this->t('The language direction. (0 = LTR, 1 = RTL)'),
25 'enabled' => $this->t('Whether the language is enabled.'),
26 'plurals' => $this->t('Number of plural indexes in this language.'),
27 'formula' => $this->t('PHP formula to get plural indexes.'),
28 'domain' => $this->t('Domain to use for this language.'),
29 'prefix' => $this->t('Path prefix used for this language.'),
30 'weight' => $this->t('The language weight when listed.'),
31 'javascript' => $this->t('Location of the JavaScript translation file.'),
38 public function getIds() {
49 public function query() {
50 return $this->select('languages')->fields('languages');
56 public function prepareRow(Row $row) {
57 if (!empty($this->configuration['fetch_all'])) {
58 // Get an array of all languages.
59 $languages = $this->query()->execute()->fetchAll();
60 $row->setSourceProperty('languages', $languages);
63 if (!empty($this->configuration['domain_negotiation'])) {
64 // Check if domain negotiation is used to be able to fill in the default
65 // language domain, which may be empty. In D6, domain negotiation is used
66 // when the 'language_negotiation' variable is set to '3', and in D7, when
67 // the 'locale_language_negotiation_url_part' variable is set to '1'.
68 if ($this->variableGet('language_negotiation', 0) == 3 || $this->variableGet('locale_language_negotiation_url_part', 0) == 1) {
69 $row->setSourceProperty('domain_negotiation_used', TRUE);
73 return parent::prepareRow($row);