whitecube / laravel-cookie-consent

Register, configure and ask for cookies consent in a EU-compliant way
MIT License
312 stars 37 forks source link

Translations not working #22

Closed Headpetrol closed 9 months ago

Headpetrol commented 9 months ago

I have just duplicated the folder the de folder and renamed it to sv for Swedish. I have translated the strings ` <?php return [ 'title' => 'Vi använder cookies', 'intro' => 'Denna webbplats använder cookies för att förbättra den övergripande användarupplevelsen.', 'link' => 'Ta en titt på vår Cookies-policy för mer information.',

'essentials' => 'Endast det väsentliga',
'all' => 'Acceptera alla',
'customize' => 'Anpassa',
'manage' => 'Hantera cookies',
'details' => [
    'more' => 'Mer detaljer',
    'less' => 'Mindre detaljer',
],
'save' => 'Spara inställningar',

'categories' => [
    'essentials' => [
        'title' => 'Väsentliga cookies',
        'description' => 'Det finns vissa cookies som vi måste inkludera för att vissa webbsidor ska fungera. Därför kräver de inte ditt samtycke.',
    ],
    'analytics' => [
        'title' => 'Analyscookies',
        'description' => 'Vi använder dessa för intern forskning om hur vi kan förbättra den tjänst vi tillhandahåller för alla våra användare. Dessa cookies bedömer hur du interagerar med vår webbplats.',
    ],
    'optional' => [
        'title' => 'Valfria cookies',
        'description' => 'Dessa cookies aktiverar funktioner som kan förbättra din användarupplevelse, men deras frånvaro kommer inte påverka din förmåga att surfa på vår webbplats.',
    ],
],

'defaults' => [
    'consent' => 'Används för att lagra användarens cookie-samtyckesinställningar.',
    'session' => 'Används för att identifiera användarens webbläsarsession.',
    'csrf' => 'Används för att säkra både användaren och vår webbplats mot CSRF-attacker (cross-site request forgery).',
    '_ga' => 'Huvudcookie använd av Google Analytics, möjliggör en tjänst för att särskilja en besökare från en annan.',
    '_ga_ID' => 'Används av Google Analytics för att behålla sessionstillståndet.',
    '_gid' => 'Används av Google Analytics för att identifiera användaren.',
    '_gat' => 'Används av Google Analytics för att reglera förfrågningstakten.',
],
    ];
     `

but it doesn't work, I get cookieConsent::cookies.title instead of Vi använder cookies. I need help solving this as quickly as possible as my project is due to launch this week.

toonvandenbos commented 9 months ago

Hi @Headpetrol,

I presume you checked if the project's language configuration is set to sv at the time Cookie configurations are defined ? Can you dd() the current locale just before the cookie consent definitions ? In some cases the ServiceProvider loads before the locales are set correctly, in which case you should defer them at a later moment in the request's lifecycle.

Also, do not hesitate to open a PR with the Swedish translations. Thanks !

Headpetrol commented 9 months ago

Hi @Headpetrol,

I presume you checked if the project's language configuration is set to sv at the time Cookie configurations are defined ? Can you dd() the current locale just before the cookie consent definitions ? In some cases the ServiceProvider loads before the locales are set correctly, in which case you should defer them at a later moment in the request's lifecycle.

Also, do not hesitate to open a PR with the Swedish translations. Thanks !

Hi @toonvandenbos I still can't find the problem. My page is multilingual and it is in english, german and Swedish and the banner works fine with English and German but when I switch to Swedish it doesn't.

I am new to GitHub so how can I open a PR.

Headpetrol commented 9 months ago

@toonvandenbos I found the problem why my translations translations didn't work. I had my translation file inside resources and as soon as I moved them to root folder the cookies.php translations started to work.