<commit_before><?php

/**
 * Make DataObjects easily sluggables
 *
 * You can configure which fields should be use in the slug through the slug_fields
 * property
 *
 * For the Link() method to work, you need to have a Page() method or relation defined
 *
 * @author Koala
 */
class SlugExtension extends DataExtension
{
    private static $db      = array(
        'Slug' => 'Varchar(150)',
    );
    private static $indexes = array(
        'Slug' => true,
    );

    public function onAfterWrite()
    {
        parent::onAfterWrite();

        $class  = $this->ownerBaseClass;
        $config = Config::inst()->forClass($class);

        // look for fields to use in slug
        $fields = array('Title');
        if ($config->slug_fields) {<commit_msg>fix slug generation if slug is not localized<commit_after><?php

/**
 * Make DataObjects easily sluggables
 *
 * You can configure which fields should be use in the slug through the slug_fields
 * property
 *
 * For the Link() method to work, you need to have a Page() method or relation defined
 *
 * @author Koala
 */
class SlugExtension extends DataExtension
{
    private static $db      = array(
        'Slug' => 'Varchar(150)',
    );
    private static $indexes = array(
        'Slug' => true,
    );

    public function onAfterWrite()
    {
        parent::onAfterWrite();

        // Do not attempt to generate a slug if not using default locale and that slug is not localized
        if(class_exists('Fluent')) {
            if(Fluent::current_locale() != Fluent::default_locale()) {
                return;
            }
        }

        $class  = $this->ownerBaseClass;
        $config = Config::inst()->forClass($class);

        // look for fields to use in slug
        $fields = array('Title');
        if ($config->slug_fields) {
{'fraction_non_alphanumeric': 0.1132596685082873, 'fraction_numerical': 0.0033149171270718232, 'mean_word_length': 2.476007677543186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6171521', 'n_tokens_mistral': 519, 'n_tokens_neox': 498, 'n_words': 175}