Вопрос

My app is ready on development server. Works as expected.

I'm using latest XAMPP / Codeigniter / HMVC

When uploaded to production server there are no errors thrown. Login page simply shows without text

Login view

<a href="login/switchLanguage/italian">
      <i class="icon-font"></i>&nbsp;<?php echo lang('language'); ?>
</a>

When executed, this is the output:

    <a href="login/switchLanguage/italian"><i class="icon-font"></i>&nbsp;</a>
                                                                          ^
                                                                          |
                                                                  Here's supposed 
                                                                 to write "Italian"

Login controller

    class Login extends MX_Controller{

        function __construct(){
            parent::__construct();
            $this->load->helper('language');
        }

        function index($msg = NULL){
            $data['msg'] = $msg;
            $this->load->view('login', $data);
        }

        public function switchLanguage($language = "") {
                $language = ($language != "") ? $language : "english";
                $this->session->set_userdata('site_lang', $language);
                redirect(base_url());
        }

EDIT:

Application/config/hooks.php

    $hook['post_controller_constructor'] = array(
        'class' => 'LanguageLoader',
        'function' => 'initialize',
        'filename' => 'LanguageLoader.php',
        'filepath' => 'hooks'
    );

Application/hooks/Languageloader.php

    <?php 

    class LanguageLoader {
        function initialize() {
            $ci =& get_instance();
            $ci->load->helper('language');
            $site_lang = $ci->session->userdata('site_lang');
            if ($site_lang) {
                $ci->lang->load('login',$ci->session->userdata('site_lang'));
            } else {
                $ci->lang->load('login','english');
            }
        }
    }

EDIT:

Example language file: application/language/italian/common_lang.php

    <?php
    //Application Global
    $lang["common_appName"] ="Customer App";
    $lang["common_search"] = "Cercare";
    $lang["common_search_go"] = "Andare";
    $lang["common_label_created_by"] = "Creato da";

    //Menus
    $lang["common_menu_home"] = "Home";
    $lang["common_menu_dashboard"] = "Cruscotto";
    $lang["common_menu_production"] = "Produzione";
    $lang["common_menu_inventory"] = "Inventario";
    $lang["common_menu_user_edit"] = "Modificare";
    $lang["common_menu_logout"] = "Il logout";
    $lang["common_menu_new_notifications"] = "Ci sono nuove notifiche";

    //Submenus
    $lang["common_submenu_dashboard"] = "Cruscotto";
    $lang["common_submenu_production"] = "Produzione";
    $lang["common_submenu_inventory"] = "Inventario";
    $lang["common_submenu_orderlist"] = "Lista ordini";
    $lang["common_submenu_calendar"] = "Calendario";

I've gone thru a lot of questions & answers unsuccessfully.

Any suggestions are very welcome ...

Thanks!

Это было полезно?

Решение

dont know whether you solved this issue or not. But i faced the same problem when i updated my project to main server. The actual problem is with the file name. In your hooks.php you mention filename as 'LanguageLoader.php' but i think you created a file Languageloader.php (Application/hooks/Languageloader.php). Please check this..

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top