Welcome Guest, Not a member yet? Register   Sign In
Setting default language in config
#1

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.
Reply
#2

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
Reply
#3

(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.
Reply
#4

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/
Reply
#5

ciadmin is correct there is no english_lang.php file in CodeIgniter.

The only specification is directory english.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

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!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB