Feature Requests
Share ideas, discuss and vote on requests from other users in community
 

Use defined language constants instead of complex variables

nadal kumar shared this idea 5 months ago
Under Consideration

The current language processing seems unnecessarily complex and can be simplified by using PHP parse_ini_file() method and define() each value.

  1. $language = parse_ini_file(ROOTDIR.'/lang/'.Setting::getValue('Language').'.ini');

    foreach($language as $key => $value) {

    define(strtoupper($key), $value, true);

    }

The language constants and values (english.ini) would simply be written as

  1. ; navigation labels

    NAV_LBL_HOME="Home"

    NAV_LBL_CLIENTAREA="Clientarea"

    ; client area head tags

    HEAD_TAG_ACCOUNT_INFO="Account Information"

    HEAD_TAG_ACCOUNT_STATS="Account Statistics"

and output is simply

  1. // tpl files

    {HEAD_TAG_ACCOUNT_INFO}

    // php

    echo HEAD_TAG_ACCOUNT_INFO

This adds greater global usage as the constants can be used in XML, TXT and any other file type.