Skip to content

Slug doesn't revert locale correctly #815

Open
@Jenselme

Description

@Jenselme

Expected and Actual Behavior

I am using Slug.php to generate slugs in a phalcon project. The project is configured to display the dates in French. However, after I generate a slug, the dates are in English. If I don't create a slug, the dates are in French as expected.

I expect the date to be always in French.

Locale value (from setlocale(LC_ALL, '0');):

LC_CTYPE=C;LC_NUMERIC=C;LC_TIME=fr_FR.utf8;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C

I use the Slug like this:

$slug = SlugGenerator::generate($str);

Sample controller:

<?php

namespace Controllers;

use Phalcon\Utils\Slug;

class TestController extends Base\ViewController
{
    public function indexAction()
    {
        $this->view->setVars(['slug' => Slug::generate('à moi')]);
    }
}

Sample view

<div class="row page-content sale">
    {{ slug }}

    <div class="date">
        <span class="day-string">{{ strftime("%a", strtotime('2017-10-22T08:00:00.000Z')) }}</span>
        <span class="day">{{ strftime("%d", strtotime('2017-10-22T08:00:00.000Z')) }}</span>
        <span class="month">{{ strftime("%b", strtotime('2017-10-22T08:00:00.000Z')) }}</span>
    </div>
</div>

I was able to track the error to this line: if I comment it, the locales are correctly restaure. Is the operation it does really required?

Details

  • Phalcon Framework version: 3.2.1
  • Phalcon Incubator version: v3.2.2
  • PHP Version: 7.1.6
  • Operating System: Linux inside docker
  • Server: Nginx
  • Other related info (Database, table schema): NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions