
public function findString($str) {
        if (array_key_exists($str, $this->lang[$this->language])) {
            return $this->lang[$this->language][$str];
        }
        return $str;
    }
    /**
    * after the text is found your explode it by =
    * @param string $str
    * @returneaza Returns the exploded string 
    */
    public function splitStrings($str) {
        return explode('=',trim($str));
    }
    /** 
    * Function that translates the text  
    * it the words/translation are found, if not, default language will be the written native language
    * @param string $str
    * @returneaza returns a translaton trough splitString();
    */
    public function __($str) {    
        if (!array_key_exists($this->language, $this->lang)) {
            if (file_exists($this->language.'.txt')) {
                $strings = array_map(array($this,'splitStrings'),file($this->language.'.txt'));
                foreach ($strings as $k => $v) {
                    $this->lang[$this->language][$v[0]] = $v[1];
                }
                return $this->findString($str);
            }
            else {
                return $str;
            }
        }
        else {
            return $this->findString($str);
        }
    }
 
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.


Recommended Topics
Member Avatar how to add hindi font to website
Member Avatar PHP backdoor security surprise uncovered
Member Avatar passing variables
Member Avatar Username availability check with jquery and php
Member Avatar Automation Script?
Member Avatar Get all links from a webpage
Member Avatar sms on website
Member Avatar sign in with email but welcome message is the name php
Member Avatar Looping through listbox items
Member Avatar Supplier Selection PHP Problem
Member Avatar PHP Server files work on one but not the other
Member Avatar what configuration should I change if I have an already set up blog?
Member Avatar PHP : Required Field Validation
Member Avatar Deleting A file on the FTP via php script
Member Avatar Zend login form in the header
Member Avatar Php Form Processing
Member Avatar Good Morning...I want to Pass a Js Value to the Php..
Member Avatar Drop Database
Member Avatar Good Morning...I want to Pass a Js Value to the Php..
Member Avatar php dynamic title meta keywords per page
Not what you need?
Reach out to all the awesome people in our web development community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.

