You are here

private function LingotekApi::check_url_alias_translation in Lingotek Translation 7.7

Checks if this content needs to have it's url translated, strips it out if it doesn't. Best place for this function as the function that puts the url alias into the content is used in other places.

Parameters

type $translatable_object:

string $content:

Return value

string

2 calls to LingotekApi::check_url_alias_translation()
LingotekApi::addContentDocument in lib/Drupal/lingotek/LingotekApi.php
Add a document to the Lingotek platform.
LingotekApi::updateContentDocument in lib/Drupal/lingotek/LingotekApi.php
Updates the content of an existing Lingotek document with the current object contents.

File

lib/Drupal/lingotek/LingotekApi.php, line 267
Defines Drupal\lingotek\LingotekApi

Class

LingotekApi
@file Defines Drupal\lingotek\LingotekApi

Code

private function check_url_alias_translation($translatable_object, $content) {
  if ($translatable_object->lingotek['url_alias_translation'] != 1) {
    $openTagPosition = strpos($content, '<url_alias>');
    if ($openTagPosition !== FALSE) {
      $closeTagPosition = strpos($content, '</url_alias>') + strlen('</url_alias>');
      $firstChunk = substr($content, 0, $openTagPosition);
      $lastChunk = substr($content, $closeTagPosition);
      $content = $firstChunk . $lastChunk;
    }
  }
  return $content;
}