CodeIgniter Forums

Full Version: Setting default language in config
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello!

I'm using the latest CI version.
Currently, I'm trying to set up multi language support for my website.

In application/config/config.php the default $config['language'] is set to 'english'.
It's working as it should, and loads the application/language/english/english_lang.php file.

But when I change the $config['language'] to something else, for example, polish, it gives me an error:
Unable to load the requested language file: language/polish/english_lang.php

Why is it trying to load english_lang.php and not polish_lang.php from the application/language/polish folder?

Hope to get some input on this.
Best regards.
Have you copied the appropriate language folders from https://github.com/bcit-ci/codeigniter3-translations into your application/language folder?

Code:
$this->lang->load('error_messages', 'english');
echo $this->lang->line('error1'); // looks in system/language/english/error_messages_lang.php
$this->lang->load('error_messages', 'polish');
echo $this->lang->line('error1'); // looks in application/language/polish/error_messages_lang.php
(09-06-2016, 06:32 AM)ciadmin Wrote: [ -> ]Have you copied the appropriate language folders from https://github.com/bcit-ci/codeigniter3-translations into your application/language folder?

Code:
$this->lang->load('error_messages', 'english');
echo $this->lang->line('error1'); // looks in system/language/english/error_messages_lang.php
$this->lang->load('error_messages', 'polish');
echo $this->lang->line('error1'); // looks in application/language/polish/error_messages_lang.php


When I'm loading the language with your example, everything works fine.
The problem is when I set different language than english in the config.php file to use as the default language.
When I set $config['language'] = 'polish';
It gives error: Unable to load the requested language file: language/polish/english_lang.php

Shouldn't it be loading language/polish/polish_lang.php instead of language/polish/english_lang.php?

Sure, I can set my messages for polish language in the language/polish/english_lang.php file, but that doesn't make much sense to me at the moment.
Hmm. something sounds funny, because there is no "english_lang.php" language settings file in CI.

If using language "x", CI looks inside system/language/x/ for specific language files, and then inside application/language/x/
ciadmin is correct there is no english_lang.php file in CodeIgniter.

The only specification is directory english.
Ok, I seem to have figured it out.

In autoload.php I had set $autoload['language'] = array('english');

That's why it was trying to load english_lang.php.

Thanks for your input guys!