You are here

protected function RangeInternationalizationWebTestCase::translateRangeFieldInstanceSettings in Range 7

Translates range field instance settings.

This method translates strings by writing to the databse directly instead of using string translation UI, because this test is designed to verify that range module works, not the Drupal core.

3 calls to RangeInternationalizationWebTestCase::translateRangeFieldInstanceSettings()
RangeInternationalizationWebTestCase::testRangeFieldFormatterRespectsInterfaceLanguage in tests/range.i18n.test
Verifies that range module field formatters respect interface language.
RangeInternationalizationWebTestCase::testRangeFieldFormErrorsRespectInterfaceLanguage in tests/range.i18n.test
Verify that range field form widget errors respect interface language.
RangeInternationalizationWebTestCase::testRangeFieldWidgetRespectsInterfaceLanguage in tests/range.i18n.test
Verifies that range module field widget respects interface language.

File

tests/range.i18n.test, line 324
Contains range i18n tests.

Class

RangeInternationalizationWebTestCase
Tests translatability of range fields.

Code

protected function translateRangeFieldInstanceSettings() {
  $field_name = $this
    ->getTestFieldName();
  $strings = $this
    ->getRangeFieldInstanceTranslatableStringTargets();
  foreach ($strings as $key => $value) {

    // Find locale source ID.
    $lid = db_select('locales_source', 'ls')
      ->fields('ls', array(
      'lid',
    ))
      ->condition('context', "{$field_name}:{$this->contentType}:{$key}")
      ->condition('textgroup', 'field')
      ->execute()
      ->fetchField();

    // Insert translation.
    db_insert('locales_target')
      ->fields(array(
      'lid' => $lid,
      'translation' => $value,
      'language' => static::SECONDARY_LANGUAGE,
      'i18n_status' => I18N_STRING_STATUS_CURRENT,
    ))
      ->execute();
  }

  // Clear string localization caches.
  cache_clear_all("i18n:string:", 'cache', TRUE);
  cache_clear_all('locale:', 'cache', TRUE);
}