"Ligipääs keelatud" (et). $translation = [ 'Access denied' => 'Ligipääs keelatud', 'You are not authorized to access this page.' => 'Sul puudub õigus antud lehte vaadata.', ]; foreach ($translation as $source => $target) { // Kontrolli kas source juba olemas. $lid = \Drupal::database()->select('locales_source', 'ls') ->fields('ls', ['lid']) ->condition('source', $source) ->condition('context', '') ->execute()->fetchField(); if (!$lid) { $lid = \Drupal::database()->insert('locales_source') ->fields(['source' => $source, 'context' => '', 'version' => '']) ->execute(); echo "SOURCE_ADDED: $source\n"; } // Lisa tõlge (et). $exists = \Drupal::database()->select('locales_target', 'lt') ->fields('lt', ['lid']) ->condition('lid', $lid) ->condition('language', 'et') ->execute()->fetchField(); if (!$exists) { \Drupal::database()->insert('locales_target') ->fields([ 'lid' => $lid, 'language' => 'et', 'translation' => $target, 'customized' => 1, ]) ->execute(); echo "TRANSLATION_ADDED: $source -> $target\n"; } else { \Drupal::database()->update('locales_target') ->fields(['translation' => $target, 'customized' => 1]) ->condition('lid', $lid) ->condition('language', 'et') ->execute(); echo "TRANSLATION_UPDATED: $source -> $target\n"; } }