Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translator does not implement #338

Open
nikmauro opened this issue Apr 10, 2020 · 5 comments
Open

Translator does not implement #338

nikmauro opened this issue Apr 10, 2020 · 5 comments

Comments

@nikmauro
Copy link

    Date::setLocale('nl');

    echo Date::now()->format('l j F Y H:i:s'); // zondag 28 april 2013 21:58:16

    echo Date::parse('-1 day')->diffForHumans(); // 1 dag geleden
    //$date = new Date('2000-01-31', new DateTimeZone('Europe/Brussels'));
    exit();

Fatal error: Uncaught InvalidArgumentException: Translator does not implement Symfony\Component\Translation\TranslatorInterface and Symfony\Component\Translation\TranslatorBagInterface. in /var/www/vhosts/##.gr/httpdocs/vendor/nesbot/carbon/src/Carbon/Traits/Localization.php:188 Stack trace: #0 /var/www/vhosts/##.gr/httpdocs/vendor/nesbot/carbon/src/Carbon/Traits/Localization.php(214): Carbon\Carbon::getTranslationMessageWith(Object(Carbon\Translator), 'weekdays', NULL, NULL) #1 /var/www/vhosts/##.gr/httpdocs/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(1190): Carbon\Carbon->getTranslationMessage('weekdays') #2 /var/www/vhosts/##.gr/httpdocs/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(1217): Carbon\Carbon->getTranslatedFormByRegExp('weekdays', '', 'dddd D MMMM YYY...', 5, 'Friday') #3 /var/www/vhosts/##.gr/httpdocs/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(1824): Carbon\Carbon->getTranslatedDayName('dddd D MMMM YYY...') #4 /var/www/vhosts/##.gr/httpdocs/vendor/nesbot/carbon/src/Carbon/Traits/Date. in /var/www/vhosts/##.gr/httpdocs/vendor/nesbot/carbon/src/Carbon/Traits/Localization.php on line 188

@kylekatarnls
Copy link
Contributor

Those kind of errors happen when trying to run a symfony/translation version that is not compatible with your PHP version (for example when running composer install with PHP 7.3 then running your app with PHP 7.1).

Your code is not enough to reproduce the bug (it works on a standard installation) and equivalent code also work in the Carbon live editor:
https://try-carbon.herokuapp.com/?embed&input=Carbon%3A%3AsetLocale(%27nl%27)%3B%0D%0A%0D%0Aecho%20Carbon%3A%3Anow()-%3EtranslatedFormat(%27l%20j%20F%20Y%20H%3Ai%3As%27)%3B%20%2F%2F%20zondag%2028%20april%202013%2021%3A58%3A16%0D%0A%0D%0Aecho%20%22%5Cn%22%3B%0D%0A%0D%0Aecho%20Carbon%3A%3Aparse(%27-1%20day%27)-%3EdiffForHumans()%3B%20%2F%2F%201%20dag%20geleden%0D%0A

Please provide your composer.json and check installed versions of jenssegers/date, nesbot/carbon and symfony/translation then check the PHP version you use for install composer dependencies and the one you run on the machine that gives this error.

@nikmauro
Copy link
Author

{
  "name": "cdl/cdl",
  "description": "cdl",
  "license": "MIT",
  "version": "8.9.7.1",
  "config": {
    "discard-changes": true,
    "no-interaction": 1,
    "preferred-install": "dist"
  },
  "require": {
    "phpmailer/phpmailer": "dev-master",
    "ccampbell/chromephp": "dev-master",
    "bdk/debug": "^2.0",
    "jv2222/ezsql": "v3.x-dev",
    "nikmauro/cms39_htm-lawed": "dev-master",
    "nikmauro/dissalowed-words-list": "dev-master",
    "claviska/simpleimage": "dev-master",
    "phpfastcache/phpfastcache": "dev-master",
    "verot/class.upload.php": "*",
    "wikimedia/less.php": "dev-master",
    "gregwar/captcha": "dev-master",
    "altorouter/altorouter": "dev-master",
    "twig/twig": "^3.0",
    "digitalbazaar/json-ld": "dev-master",
    "pelago/emogrifier": "dev-master",
    "matthiasmullie/minify": "dev-master",
    "google/recaptcha": "^1.2",
    "predis/predis": "dev-master",
    "jenssegers/date": "dev-master",
    "nesbot/carbon": "dev-master",
    "symfony/translation": "dev-master",
    "ezyang/htmlpurifier": "dev-master",
    "tinymce/tinymce": "dev-master",
    "webmozart/assert": "dev-master",
    "stefangabos/zebra_pagination": "dev-master",
    "html2text/html2text": "dev-master",
    "mpdf/mpdf": "dev-master",
    "chillerlan/php-qrcode": "^3.2",
    "spatie/array-to-xml": "dev-master",
    "intervention/image": "dev-master",
    "psr/log": "dev-master"
  },
  "minimum-stability": "dev"
}

In the development machine i have php 7.2 and install the composer with args --no-interaction --ignore-platform-reqs , in the production machine i have php 7.3.10 and return this errors

@nikmauro nikmauro reopened this Apr 23, 2020
@kylekatarnls
Copy link
Contributor

Did you clean all you caches (like OPCache, APC, etc.) that may keep some obsolete PHP files as precompiled?

@kevinarrieta
Copy link

I have the same issue, it appeared when upgrading to version 4. Locally using Laravel Valet it works just fine, the issue is on my production server, both local and in production running php 7.3. No idea of what could be happening!

@kylekatarnls
Copy link
Contributor

Possible causes and solutions have been given here:
briannesbitt/Carbon#2033 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants