Welcome Guest, Not a member yet? Register   Sign In
Language class suggestion ..
#1

[eluser]Ramania[/eluser]
Some of you guys are so lucky for not having to work with the language class, the language class it self is very straight forward and simple, i have no issues with it at all except for a small suggestion that i find very useful for those of us who create sites with a primary language then secondary languages (Arabic, French, Urdu ..etc).

and before i start i would say this feature might been implemented in CI but it skipped my attention, i won't feel stupid because it didn't require a lot of time at all.

this is an extract from the language class

Code:
function line($line = '')
    {
        $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
        return $line;
    }

I am suggesting something very simple, a parameter that allows the class to return the line used instead of FALSE or return FALSE if this parameter is not set to TRUE an example would illustrate ..

Code:
<?=$this->lang->line('About us');?>

it's written in English .. spaced beautiful English, why would i have an English file for something already written in English? whatever happened to DRY? so simply

Code:
<?=$this->lang->line('About us',TRUE);?>

would return the $lang variable which is 'About us' in case it's not found! ...

Code:
function line($line = '', $return_original = FALSE)
    {
        $line = ($line == '' OR ! isset($this->language[$line])) ? $return_original : $this->language[$line];
        return $line;
    }



won't that save the developer/designer/translator time? anyways i know it's best practice to extend the controller rather than changing it, so in case of a CI patch/update i won't lose my modifications and i won't comprise the integrity of the system classes, but i went ahead and allowed my self to modify it to return the $lang variable instead of false by default... so far so good, if i'd see any side effects or "artifacts" Tongue .. i would report back to you guys.

ps: i'm lately trying to payback to the CI community, so if my paybacks aren't useful to you i apologize, my intentions are good.

edit : i forgot to mention that writing something like

Code:
<?=$this->lang->line('About us') ? $this->lang->line('About us') : 'About us';>

Isn't very "sexy" or practical either ..

Rami.




Theme © iAndrew 2016 - Forum software by © MyBB