/** * Constructor. * * This is private since we want consumers to instantiate via the factory methods. * * @param object $node * A Drupal node. */ private function __construct($entity, $entity_type) { $this->entity = $entity; $this->language = $entity->language; $this->language_targets = Lingotek::getLanguagesWithoutSource($this->language); $this->entity_type = $entity_type; $this->info = entity_get_info($this->entity_type); }
/** * Constructor. * * This is private since we want consumers to instantiate via the factory methods. * * @param $set_id * A Config Set ID. */ private function __construct($set_id = NULL) { $this->sid = $set_id; $this->set_size = LINGOTEK_CONFIG_SET_SIZE; $this->source_data = self::getAllSegments($this->sid); $this->source_meta = self::getSetMeta($this->sid); $this->language = language_default(); if (!isset($this->language->lingotek_locale)) { // if Drupal variable 'language_default' does not exist $this->language->lingotek_locale = Lingotek::convertDrupal2Lingotek($this->language->language); } $this->language_targets = Lingotek::getLanguagesWithoutSource($this->language->lingotek_locale); }
/** * Constructor. * * This is private since we want consumers to instantiate via the factory methods. * * @param $chunk_id * A Config Chunk ID. */ private function __construct($chunk_id = NULL) { $this->cid = $chunk_id; $this->chunk_size = LINGOTEK_CONFIG_CHUNK_SIZE; $this->source_data = self::getAllSegments($this->cid); $this->source_meta = self::getChunkMeta($this->cid); $this->language = language_default(); if (!isset($this->language->lingotek_locale)) { // if Drupal variable 'language_default' does not exist $this->language->lingotek_locale = Lingotek::convertDrupal2Lingotek($this->language->language); } $this->language_targets = Lingotek::getLanguagesWithoutSource($this->language->lingotek_locale); $this->min_lid = $this->getMinLid(); $this->max_lid = $this->getMaxLid(); }
/** * Set the entity's language to be used by Lingotek, which will * sometimes be different from the stated Drupal language. */ public function setLanguage($language = NULL) { if (empty($language)) { $drupal_locale = Lingotek::convertDrupal2Lingotek($this->entity->language); if (!empty($this->entity->lingotek['allow_source_overwriting']) && !empty($this->entity->lingotek['source_language_' . $drupal_locale])) { $language = $this->entity->lingotek['source_language_' . $drupal_locale]; } else { $language = $this->entity->language; } } $this->language = $language; $this->locale = Lingotek::convertDrupal2Lingotek($this->language); $this->language_targets = Lingotek::getLanguagesWithoutSource($this->locale); }
public static function getDirtyChunkLids() { // return the list of all lids from the locale_source table *not* fully translated $source_language = language_default(); if (!isset($source_language->lingotek_locale)) { $source_language->lingotek_locale = Lingotek::convertDrupal2Lingotek($source_language->language); } $lingotek_codes = Lingotek::getLanguagesWithoutSource($source_language->lingotek_locale); if (!count($lingotek_codes)) { LingotekLog::error('No languages configured for this Lingotek account.', array()); return array(); } // get the drupal language for each associated lingotek locale $drupal_codes = array(); foreach ($lingotek_codes as $lc) { $drupal_codes[] = Lingotek::convertLingotek2Drupal($lc); } // get the list of all segments that need updating // that belong to the textgroups the user wants translated $textgroups = array_merge(array(-1), LingotekConfigChunk::getTextgroupsForTranslation()); $max_length = variable_get('lingotek_config_max_source_length', LINGOTEK_CONFIG_MAX_SOURCE_LENGTH); $query = db_select('{locales_source}', 'ls'); $query->fields('ls', array('lid'))->condition('ls.source', '', '!=')->condition('ls.lid', self::getQueryCompletedConfigTranslations($drupal_codes), 'NOT IN')->where('length(ls.source) < ' . (int) $max_length); if (in_array('misc', $textgroups)) { $or = db_or(); $or->condition('ls.textgroup', $textgroups, 'IN'); $or->where("ls.textgroup NOT IN ('default','menu','taxonomy','views','blocks','field')"); $query->condition($or); } else { $query->condition('ls.textgroup', $textgroups, 'IN'); } return $query->execute()->fetchCol(); }