validation errors multi-lingual

Hey there!

I'm just doing my small form, using CI's
validation capabilities.

How can I make this multi-lingual? The returned errors are by default english, but I'd like german and russian too Smile


You can add additional languages in your system/application/languages folder and then use this language in your config file.

I think there is already some translations out there, you should run a search about that here in the forums.

Good luck!

[eluser]Derek Allard[/eluser]
I do this in BambooInvoice if you want to download the code and poke. I think there's... 7 or 8... lost count, supported langs in there.

Thx for the inputs.

I already saw that I can configure the language in the conf-file and download additional languages (not sure about russian yet), but I would like to alter the language on runtime (the user can select between three languages).

I will have a look at Bamboolnvoice and see if the language is changed during runtime?


The hardest part about changing languages at runtime is loading the choosen language files. I've made a method for this a while ago
    * Makes switching between languages easier
    *  example :
    function switch_to($idiom)
        $CI =& get_instance();
        if(is_string($idiom) && $idiom != $CI->config->item('language'))
            $loaded = $this->is_loaded;
            $this->is_loaded = array();
            foreach($loaded as $file)
How you do the switch that is up to you, there are some solutions floating around the on the forum and wiki.

thx! The language-switcher I already have implemented. Now I would only need to call this additional method, nice!

here a corrected script which worked for me (based on Xwero's script, which had some errors concerning $this, maybe I tried it in a wrong context):

$CI =& get_instance();
if($lang != $CI->config->item('language'))
    $loaded = $CI->config->is_loaded;
    $CI->config->is_loaded = array();
    foreach($loaded as $file)

I wrote a small helper. A better way might be to inherit the Config-class and add this specialized function, but I was lazy... Smile

Gosh, I only realized now that the above snippet (which I use in a helper) doesn't seem to work. The language-files are not loaded when I change the language. It seems that the array is_loaded (from Config-class) is empty, therefore there is nothing to replace.
Why is it empty?

Ok, since Config::is_loaded is empty, I tried Config::config. That's how it looks like:

    [index_page] => index.php
    [uri_protocol] => AUTO
    [url_suffix] =>
    [language] => de
    [charset] => UTF-8
    [enable_hooks] =>
    [subclass_prefix] => MY_
    [permitted_uri_chars] => a-z 0-9~%.:_\-
    [enable_query_strings] =>
    [directory_trigger] => d
    [controller_trigger] => c
    [function_trigger] => m
    [log_threshold] => 1
    [log_path] =>
    [log_date_format] => Y-m-d H:i:s
    [cache_path] =>
    [encryption_key] =>
    [sess_cookie_name] => ci_session_//[...]
    [sess_expiration] => 7200
    [sess_encrypt_cookie] =>
    [sess_use_database] => 1
    [sess_table_name] => ci_sessions
    [sess_match_ip] =>
    [sess_match_useragent] => 1
    [sess_time_to_update] => 300
    [cookie_prefix] =>
    [cookie_domain] =>
    [cookie_path] => /
    [global_xss_filtering] =>
    [compress_output] =>
    [time_reference] => local
    [rewrite_short_tags] =>

There is the language, of course, but there is nothing about what CI language-files are loaded. Where would I find them? Could somebody with some more CI-insights give me a hint where to find (and manipulate) them?

I created a Multi-Language Hook that I created for a project I have been working on. Multi-Language front-end support seems to be a very desired functionality that doesn't seem to be well supported in any frameworks, heres hoping this helps some people.

My main goal was to support multi-lingual search engine friendly URL's, for example: (home page in English) (home page in French)

This does require a config file to keep track of controller and function translations, for those who don't wish to maintain translations it reverts to URL's like this:

There is also an option to use a query string:

I've put the project up on Github and would love some feedback, feel free to fork and improve on the code.
A lot of people seem to want to use cookies for storing user language preference, however I don't believe this is the best practice for search engine crawlers. Will eventually get to supporting this method too (as well as subdomain).


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.