I prefer my cp in English but I've noticed that it also sets the locale to "en_us" for the entire site. I need that locale to be "nl" since the site is in Dutch. Any idea how to achieve this?
3 Answers
This solutions works for any locale, even if you don't have it installed as a front-end locale. It also works for Personal or Client Craft installs.
Add a translations file into craft/translations/xx.php named after the currently selected user locale or system locale for Craft Personal installs and use this code to include any locale's translations you want. You can also customize it further by overwriting select translations:
<?php
namespace Craft;
if (craft()->request->isCpRequest())
{
$en = (include '../craft/app/translations/en.php');
$custom = array(
'Globals' => 'I freak out!',
);
return array_merge($en, $custom);
}
return [];
- 36,220
- 5
- 62
- 139
-
One downside of this approach: it doesn't override plugin translations (if you don not include them aswell). – carlcs Dec 02 '15 at 21:52
I've modified the snippet a bit. For me as Admin and Developer it's urgent to have it in English. But we figured out that clients want rather the native language. I think it's fine in this way.
<?php
namespace Craft;
if (craft()->request->isCpRequest())
{
if (craft()->userSession->isAdmin())
{
return (include '../craft/app/translations/en_gb.php');
}
else
{
$de = (include '../craft/app/translations/de.php');
$custom = array(
//'Globals' => 'I freak out!',
);
return array_merge($de, $custom);
}
}
return [];
- 67,440
- 6
- 73
- 143
- 154
- 10
If you're running Craft Pro, you can go to your account's profile page where you can set your user's preferred language to English and the CP will display in English.
- 67,440
- 6
- 73
- 143
-
-
-
The same reason why adding a define locale statement to index.php isn't working either I guess? – erwinheiser May 17 '15 at 21:35
-
-
Is it possible to have the CP in English without actually installing the en_us content locale? I'm running a site w/ content in Norwegian and I also prefer having the CP in English. However even if I specifically set my sections to target Norwegian only, Craft renders the language select dropdown above all index tables. When there's no actual content in English, that can be confusing. I tried setting the the 'defaultCpLanguage' to 'en' without actually having the English locale installed, which – oddly enough – does render the CP in English, but then my Norwegian content is invisible :) – Mats Mikkel Rummelhoff Sep 11 '15 at 11:29
-
@mmikkel haven't had coffee yet, so that could explain it, but I'm not following. Can you hit up support@buildwithcraft.com explaining what you're looking for? – Brad Bell Sep 11 '15 at 16:06
-
Cheers @BradBell – just sent you an email. In short, I'm looking to render the CP in a locale that isn't installed as a content locale. The email explains further. Also, turning on your computer before coffee? Reckless :) – Mats Mikkel Rummelhoff Sep 11 '15 at 19:30
-
I too would like to see this as an option - simply stated: I prefer my CP in English without having to install an english locale. – erwinheiser Mar 17 '17 at 14:18