Skip to main content
15 votes
Accepted

Craft 3 language switcher

The concept of localization has changed in Craft 3, there are not only locales anymore - now you have different sites and site groups. Example without multisite - only different locals You can get ...
Robin Schambach's user avatar
8 votes
Accepted

How to add locales in Craft 3

"Sites" in Craft 3 replaces the old "Locales" concept in Craft 2. There's not much documentation on them yet, but the setup process is virtually the same as it is in Craft 2 for locales. The main ...
Brad Bell's user avatar
  • 67.5k
8 votes
Accepted

Craft 3: how can I set dynamic Base URL in sites setting?

So as of Craft CMS 3 RC7, they added a new alias() Twig function. So what you can do is something like this in your general.php: 'aliases' => [ '@basePath' => getenv('CRAFTENV_BASE_PATH'), ...
andrew.welch's user avatar
  • 11.6k
6 votes
Accepted

Adding new locale - hangs at Step 3 'ResaveAllElements'

You probably need to up Craft's internal memory limit, as well – the following should go into the array in your general.php configuration file: 'phpMaxMemoryLimit' => '1024M',
Mats Mikkel Rummelhoff's user avatar
6 votes
Accepted

Override admin local name

You can add your own translations by placing a region-specific translation file in a craft/translations folder. The filename should be named after your locale and return an array of translations. In ...
Ben Parizek's user avatar
  • 13.5k
6 votes
Accepted

Scaling channels with 35 locales

You could have a single News section that is enabled for each of the locales, and choose which locale each entry should target from their Edit pages. To make it easer on the authors, you can set the ...
Brandon Kelly's user avatar
6 votes
Accepted

Craft 3 Multi-site with no "default" site

This can be done in 3 main steps. 1. Get the site subdirectories working First just get the /en/ and /es/ subdirectory working: Create en/ and es/ subfolders in your webroot Each subfolder should ...
Brandon Kelly's user avatar
6 votes
Accepted

What is the difference between the Translation Methods when creating a new site

Not translatable The field will always have the same value for each site Translate for each site Easy: the field can have a different value for each of your sites. Create 10 sites, all can have ...
Robin Schambach's user avatar
5 votes
Accepted

Retrieve entry field value from a different locale?

You can just manually fetch the entry in the other locale. Assuming you already have the first entry, something like: {% set localeEntry = craft.entries.id(entry.id).locale(languageID1).first() %} {...
Brad Bell's user avatar
  • 67.5k
5 votes
Accepted

Getting all entries from all locales

In my experience this has been problematic - instead have looped through locales to fetch entries then merged and sorted with supersort. Eg: {% set locales = craft.i18n.getSiteLocales %} {% set ...
Cole Henley's user avatar
  • 1,741
5 votes
Accepted

Multi-lingual site with a splash (language select screen) at the root

Well that was easy enough. I had forgotten about the .htaccess in the subfolders. Everything works like planned now. public/.htaccess (redirects to craft.php if file doesn't exist) public/index....
Eric Chantigny's user avatar
5 votes

How can I get the locales that are actually enabled for a given entry?

Actually, entry.getLocales() (or just entry.locales) will return an array of the locales enabled for the entry's section, not all locales in the system. Unfortunately, there's no easy way to ...
Mats Mikkel Rummelhoff's user avatar
5 votes
Accepted

Passing JSON to Twig

The answer is to create a custom plugin that will read the json files from the folders in the public directory, parse the json, and pull them into the template. An alternative solution is to use ...
Sam Hernandez's user avatar
5 votes
Accepted

Possible to change locale in PHP?

I think I got this resolved the proper way... looks like you just need to make sure that your AJAX calls are localized. In my main _layout template: <script type="text/javascript"> window....
Lindsey D's user avatar
  • 24k
5 votes

Craft 3 language switcher

Little addition with a fallback to the homepage and check if entry exist. currentSite is a global variable already defined in craft3 https://docs.craftcms.com/v3/templating/global-variables.html#...
Jeroen's user avatar
  • 308
5 votes
Accepted

Is there some way to create sections inside static translations? (craft v3)

You can include custom translation categories within your config/app.php return [ 'modules' => [ 'my-module' => \modules\Module::class, ], 'components' => [ '...
Robin Schambach's user avatar
5 votes

How to handle a single page that is a different language?

Another way you could do this - that wouldn't be sustainable to expand later - is to create two landing pages as singles in Craft CMS. Then, create a new template for wherever you keep your header ...
cherrykoda's user avatar
  • 1,114
4 votes
Accepted

Element API locale

I had the same problem lately and solved it with a locale query parameter. The code for this inside craft/config/elementapi.php looks like this: return [ 'endpoints' => function () { '...
periodical's user avatar
4 votes

Locale change based on geolocation

I recently released Country Redirect, a plugin that handles this smoothly: https://superbig.co/plugins/country-redirect It lets you map which countries get redirected to which locales, let visitors ...
Fred Carlsen's user avatar
  • 2,997
4 votes
Accepted

How to setup a multi-lingual site on IIS

Looks like it was only because I was missing the clear tag in my rules in the subfolders. Everything works like a charm now.
Eric Chantigny's user avatar
4 votes
Accepted

Control panel field name & instructions translations

If your main language site is dutch for example, you can do that using your own php files locale and naming them according the other locales languages, en.php, fr.php and put those files in craft/...
Barbara Cinotti's user avatar
4 votes
Accepted

Using user-selectable timezones to show localized post dates

It is possible to work around the Craft 2 bug, by converting the Craft DateTime object to a native one. {% set craftDateTime = entry.postDate %} {% set nativeDateTime = date(craftDateTime|date('c')) %...
carlcs's user avatar
  • 36.3k
4 votes
Accepted

Set Locale in template

You can’t set the craft.locale from the template. You can set the locale for your Element Criteria though. {% set entry = craft.entries.id(14).locale('en').first() %}
carlcs's user avatar
  • 36.3k
4 votes

Craft 3 language switcher

As of today, Site Switcher is now available in the plugin store! * It was called "Language Link" in Craft 2, but the premise is the same... It allows you to switch between sites while staying on the ...
Lindsey D's user avatar
  • 24k
4 votes

Craft 3 multi-lingual multi-sites setup with shared assets

You could create 2 site groups. One group for site A and one group for site B. Sitegroup A will contain contain 2 sites, the other one only one site. Your setup will look like this SiteGroup A -...
Robin Schambach's user avatar
4 votes
Accepted

Getting full native language name in Craft 3 language switcher

The site.language attribute is just a string, i.e. the language code or locale ID, e.g. 'en'. To get the native name you'll need to go through the I18N service to pull the actual Locale object via ...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Sending a custom email in the users prefered locale

You can translate string in PHP and Twig via translate function public static function t($message, $variables = array(), $source = null, $language = null, $category = 'craft') Twig {{ 'my string'|t(...
Robin Schambach's user avatar
4 votes
Accepted

How to query entries written in a specific locale? (Craft 3)

In Craft 3, you can't really have locales. If in Craft 2 you had multiple locales, that should have been automatically migrated to multiple sites (as now the site is always single locale) Having said ...
Yuri Salimovskiy's user avatar
4 votes

How to host a huge website on Craft (10k pages, over a dozen languages, 2GB database)

"Digital Ocean through Forge" is a good solution. Sounds like you're on a well-powered droplet as well. I'd recommend moving your assets into the cloud to speed things up a bit. Something like Amazon ...
Lindsey D's user avatar
  • 24k
4 votes
Accepted

Is it possible to localize Freeform fields and labels?

You can render the fields by your own and use the twig translate filter and do it with translation files. But I think there is no way to do it via the CP currently.
davidhellmann's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible