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
10 votes
Accepted

Can I choose a language for the translate filter?

Yes. You can see all of the arguments the |t filter supports by looking at the docs for Craft::t(), the function that |t maps to. Its $language argument defines the target language translation to use. ...
Brandon Kelly'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.4k
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.5k
7 votes
Accepted

Is there a way to have checkbox field labels translatable?

Short of hardcoding all these checkbox values and applying the translate tag on them That's actually the only way to translate field names, checkbox labels/values and whatnot: taking advantage of ...
Mats Mikkel Rummelhoff's user avatar
6 votes
Accepted

Multi Country website - Using locales is the best approach?

Yes you can do this by going to the craft/app/framework/i18n/data folder and copying the language file for each occurrence. You must give each a unique name es_pn, es_co, es_nc. Inside each of those ...
a-am's user avatar
  • 2,857
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.4k
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

Localized ElementTypes in a plugin

The part that I'm not "getting" is I think there should be one Element in craft_elements and then for each localization, there should be one record in craft_elements_i18n yes? Yes. And then for ...
Brandon Kelly's user avatar
5 votes
Accepted

How can I localize a URL in a plugin?

You can use UrlHelper::getSiteUrl() instead, which does have a $localeId argument, for generating a URL relative to a given locale’s base URL (per the siteUrl config setting). So if your siteUrl ...
Brandon Kelly'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.4k
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
  • 954
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

Appraising Craft CMS - newbie questions

Craft is the perfect CMS to handle everything you just pointed out. Can Craft CMS handle bilingual sites? YES. https://craftcms.com/docs/localization-guide Is the Craft CMS admin available in ...
naboovalley's user avatar
  • 2,844
4 votes

Linking a page in a multilanguage website

You could write a Twig macro to get the localized URL from an entry ID. Import it from _layout.html for example. {% macro urlFromId(entryId) %} {%- set entry = craft.entries.id(entryId).first() %}...
carlcs's user avatar
  • 36.2k
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
Accepted

Multilingual slug setup

The problem you're probably facing isn't that URLs like http://example.com/en/news/example http://example.com/fr/nouvelles/exemple don't work, but that you're not getting the sections' index pages ...
carlcs's user avatar
  • 36.2k
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.2k

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