2

Drupal 7

Here is my code:

<?php
$languages = language_list(); // get all languages
$preferedLang = "sv";
global $language;
$language = $languages[$preferedLang];

$node = new stdClass(); // Create a new node object
$node->type = $type; // Or page, or whatever content type you like

node_object_prepare($node); // Set some default values


$node->title = $title;
$node->language = $preferedLang; // Or e.g. 'en' if locale is enabled

$node->path['pathauto'] = TRUE;

.
.
.

node_save($node);

When the title is set to

Jakt på vildsvin och dovhjort erbjuds i norra Östergötland

it should use Transliteration and produce this path:

/jakt-pa-vildsvin-och-dovhjort-erbjuds-i-norra-ostergotland

Instead the following (incorrent, not transliterated path) is created

/jakt-p-vildsvin-och-dovhjort-erbjuds-i-norra-stergotland

Note that "å" did not transliterate into "a" and "Ö" into "o".

Also note that if I create the node manually this works.

What I have done

Verified that I have checked "Transliterate prior to creating alias"

Verified that I have both English and Swedish languages enabled

I have tried setting:

$path["language"] = 'sv'

1
  • Ok the problem is that transliteration is including the correct file from data data/ folder using relative paths. This means that when your creating nodes programmatically you need to do <?php chdir("/home/of/your/drupal/installation"); ?> so that this works in transliteration <?php include "sites/all/modules/transliteration/data/x00.php"; ?> – Anders Apr 13 '15 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.