2

I'm trying to setup a bilingual site and I'm having some issues with setting up the URI.

'siteUrl' => array(
    'en' => 'http://localhost/mysite',
    'fr' => 'http://localhost/mysite/fr',
),
'environmentVariables' => array(
    'baseUrl'  => 'http://localhost/mysite/',
)

In my single settings: URI for french: {baseUrl}fr/nouvelles URI for english: {baseUrl}news

Not sure how to set this up to have it setup the way I want it. Removing the baseURL part just doesn't print the mysite subfolder.

Thanks!

EDIT: Here's the real problematic after investigation.

The URI should not include anything more than the name so: In my single settings: URI for french: nouvelles (http://localhost/mysite/fr/nouvelles) URI for english: news (http://localhost/mysite/news)

Now, those 2 pages work like expected.

But, if I assign those pages to a Entries field, to create my menu, when I pull the url, it never inclues the /fr portion. Even the default template doesn't render the correct link, dropping the /fr part in the url too:

{% for entry in craft.entries.section('news').limit(5).find() %}
    <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
{% endfor %}
3
  • Have you added the physical subfolder (with index.php in it etc.) to your wwwroot for the secondary language? You do not need {baseUrl} in your Section slug settings. Commented Feb 4, 2016 at 15:51
  • Yes! I should specify that everything works like it should when I visit the pages. But, not when I try to access the page's url, or the other locale page's url. localhost/cartovista is in english localhost/cartovista/fr is in french I think I'm getting things confused in the URI part. I don't think it requires the fr part. I will dig a bit more but if someone understands my issue and has already setup a bilingual site, with language switch, I would appreciate some pointers. Commented Feb 4, 2016 at 16:16
  • Ok, I have now pinpointed my issue to url in the twig template. Anytime a page url is called, the fr portion is never included, which renders the link useless. link.page[0].url link page, being a Entries field type. Commented Feb 4, 2016 at 16:28

1 Answer 1

3

Well... the answer was quite simple.

'siteUrl' => array(
    'en_ca' => 'http://localhost/mysite',
    'fr_ca' => 'http://localhost/mysite/fr',
),

The _ca part was what was missing. Now my site works amazingly.

Sorry for the run around and I hope this can help someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.