0

I am developing a user library in cakephp for translation operations in my app. I want to create .po files in Lib directory itself that's why i created Locale folder inside Lib directory and create po files in respective language directories. But the problem is CakePHP is by default searching for po files in its default Locale location. And my locale directory in inside Lib folder now.

How can i make cakephp to search for po files in my own Locale directory which is inside Lib folder?

Here is my Translate class code:-

//App::uses($className, $location)
class Translate {
//put your code here

    public $defaultLanguage = "";

    public function __construct() {              
        $this->defaultLanguage = Configure::read('Config.language');
    }

    public function get($key,$language){
        Configure::write('Config.language',$language);
        return __($key);
    }

    public function getDefaultLanguage(){
        return $this->defaultLanguage;
    }

    //public function setNewKey()
}

enter image description here

Sumit Parakh
  • 1,098
  • 9
  • 19
  • This doesn't make any sense. CakePHP has a built in powerful translation system. https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html – floriank May 29 '17 at 09:40
  • @burzum Yep. And i am trying to utilize its in-built translation system to create a more simplified and robust translation library for my own app. – Sumit Parakh May 29 '17 at 10:02

1 Answers1

0

I got it working myself. I have used build method of cake core library to define custom path of my own Locale library. Here is the code:-

public function __construct() {              
    $this->defaultLanguage = Configure::read('Config.language');

    App::build(array(
       'Locale'=>ROOT.DS.'app'.DS.'Lib'.DS.'Locale'.DS
    ));      
}
Sumit Parakh
  • 1,098
  • 9
  • 19