ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Multilingual i18n enviroment for CodeIgniter

October 01, 2012 9:41am

Subscribe [10]
  • #16 / Dec 01, 2012 8:05am

    Hamed

    41 posts

    How can I change current page language?
    for example my user view http://127.0.0.1/en/user/profile now I want to change it to http://127.0.0.1/fa/user/profile?
    How to find out current url..

  • #17 / Dec 01, 2012 8:20am

    keevitaja

    107 posts

    mci_current() - returns current language segment

    for changing the langage just use langbar() helper which prints out the links

  • #18 / Dec 02, 2012 8:04am

    keevitaja

    107 posts

    i added mci_change() method and lchange() helper which gives you current controller uri for different language.

    use in view:

    <?php echo anchor(lchange('en')); ?>

    if no language is not specified, you get an array containing all language uris except current

  • #19 / Dec 02, 2012 8:48am

    Hamed

    41 posts

    I get Fatal error: Call to undefined function mci_current()
    How can I fix it?
    is it yours?
    http://maestric.com/en/doc/php/codeigniter_i18n

  • #20 / Dec 02, 2012 8:58am

    keevitaja

    107 posts

    in the controller you must call it

    $this->lang->mci_current()

    because it is MY_Lang class method. only helpers can be called as functions

    please see my example controller:

    https://github.com/keevitaja/mci-codeigniter/blob/master/application/controllers/example.php

  • #21 / Dec 18, 2012 6:35am

    brizoo

    13 posts

    Hi, Thank you very much for this i18n library, this is the only easy one I’ve found.
    I’m still stuck with a little problem, how do you do to remove the index.php part of the URL ?

    I have

    $config['index_page'] = '';

    like this

    my routes are these :

    $route['default_controller'] = "example";
    $route['404_override'] = '';
    
    // All re-mappings must begin with '^(fr|en|es)' !!!
    
    $route['^((fr|en|es)/)?test/(.+)$'] = "example/test/$3";
    
    $route['^(fr|en|es)/(.+)$'] = "$2";
    $route['^(fr|en|es)$'] = $route['default_controller'];

    and my .htaccess file is like this :

    RewriteEngine on
    
    AddDefaultCharset UTF-8
    
    RewriteCond $1 !^(index\.php|images|img|javascript|js|fonts|content|uploads|images|styles.css|layout.html|public|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]

    What do you think is wrong ?

    Thanks

  • #22 / Dec 18, 2012 7:58am

    keevitaja

    107 posts

    http://ellislab.com/codeigniter/user-guide/general/urls.html

    read the part which begins with the “Removing the index.php file”

  • #23 / Dec 18, 2012 8:47am

    brizoo

    13 posts

    http://ellislab.com/codeigniter/user-guide/general/urls.html

    read the part which begins with the “Removing the index.php file”

    This is exactly what I’ve followed but this is still not working for me :(

  • #24 / Dec 18, 2012 9:02am

    brizoo

    13 posts

    Ok,
    I got it !

    I had to do this for the .htaccess file :


    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 

    <Files “index.php”>
    AcceptPathInfo On
    </Files>  [\Code]

  • #25 / Jan 24, 2013 10:50am

    darksoulsong

    2 posts

    I’m using this library and everything is doing just fine.
    But I’m trying to make CI redirect to the main lang when an unsupported lang is supplied.

    I tried to debug it on the MY_Lang file, but it seems that the language request is handled somewhere else before reaching this location, giving me a 404 page.

    Any ideas about how to acomplish that? TYVM.

  • #26 / Jan 24, 2013 11:17am

    keevitaja

    107 posts

    try config/routes.php

    but what does a unsupported lang stand for? when you have french and english with en and fr then xx would be unsupported? i that case you have to redirect all first uri segments with length of 2. not wise

  • #27 / Jan 24, 2013 2:32pm

    darksoulsong

    2 posts

    Well, the idea is to handle the following situation:
    My site has 2 supported languages: “pt-br” and “en”. The first one was set as the main site language.
    Let’s say a user commits a typo and writes “pt” instead of “pt-br”. In that case, the system redirects him to the default language that was set previously (pt-br, in my situation).
    My goal is to redirect the user to “pt-br” if an unsupported lang is supplied, like “chinese”, for example. That would be much more friendly than just give him a 404 page.

  • #28 / Feb 07, 2013 4:25am

    ranggadablues

    12 posts

    Hi there, I like your multi language helper. But every time I go to another menu it’s always back to default language, so I have to change the other language again. For the example the default language is English, and from about page I change to Dutch language then I go to news page it’s back to default language. How that every time I go to another page without changing the language?

    thank you

  • #29 / Feb 07, 2013 4:42am

    keevitaja

    107 posts

    you must use helper lanchor() instead of anchor() in view files.

  • #30 / Feb 07, 2013 7:40am

    ranggadablues

    12 posts

    you must use helper lanchor() instead of anchor() in view files.

    thanks, I will try..