diff --git a/README.md b/README.md index 061878c..5516576 100755 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ composer update colourbox-account/i18n $api = new CBX\API("https://test-tb.cbx.xyz"); $config = new CBX\Config("en_GB", "i18n-develop-test"); $collections = new CBX\Collections($config); -$i18n = new i18nClass($collections); +$i18n = new CBX\I18nClass($collections); ``` ### Create instance with factory ```php -$i18n = CBX\i18n::create("en_GB", "i18n-develop-test", "https://test-tb.cbx.xyz"); +$i18n = CBX\I18nFactory::create("en_GB", "i18n-develop-test", "https://test-tb.cbx.xyz"); ``` ### Getting simple translation diff --git a/src/CBX/i18nClass.php b/src/CBX/I18nClass.php similarity index 95% rename from src/CBX/i18nClass.php rename to src/CBX/I18nClass.php index f3ec1c7..5f2c764 100755 --- a/src/CBX/i18nClass.php +++ b/src/CBX/I18nClass.php @@ -2,7 +2,7 @@ namespace CBX; -class i18nClass +class I18nClass { private $collections; diff --git a/src/CBX/i18n.php b/src/CBX/I18nFactory.php similarity index 63% rename from src/CBX/i18n.php rename to src/CBX/I18nFactory.php index a917e38..5786106 100755 --- a/src/CBX/i18n.php +++ b/src/CBX/I18nFactory.php @@ -2,13 +2,13 @@ namespace CBX; -class i18n +class I18nFactory { public static function create($language, $domain, $apiUrl) { - return new i18nClass(new Collections(new Config($language, $domain, new API($apiUrl)))); + return new I18nClass(new Collections(new Config($language, $domain, new API($apiUrl)))); } public static function createOffline($language, $domain, $jsonDir) { - return new i18nClass(new Collections(new Config($language, $domain, new APIOffline($jsonDir)))); + return new I18nClass(new Collections(new Config($language, $domain, new APIOffline($jsonDir)))); } } diff --git a/test/index.php b/test/index.php index 29663d7..79c850b 100755 --- a/test/index.php +++ b/test/index.php @@ -7,17 +7,17 @@ require_once __DIR__ . '/../src/'.str_replace('\\', '/', $class_name).'.php'; }); -CBX\i18n::initialize("en_GB", "i18n-develop-example", "https://tb.colourbox.com"); +$i18n = CBX\I18nFactory::create("en_GB", "i18n-develop-example", "https://tb.colourbox.com"); $output = [ - "API Host: ".CBX\i18n::getAPIURL(), - "Language: ".CBX\i18n::getLanguage(), - "Domain: ".CBX\i18n::getDomain(), + "API Host: ".$i18n->getAPIURL(), + "Language: ".$i18n->getLanguage(), + "Domain: ".$i18n->getDomain(), "\n", - "companyAddress: ".CBX\i18n::_('companyAddress'), - "html escaped: ".CBX\i18n::_htmlEscaped('htmlText'), - 'placeholder: '.CBX\i18n::_('addNumber', [ 'nr1' => 1, 'nr2' => 2, 'nr3' => 3 ]), - "notExistingIndex: ".CBX\i18n::_('notExistingIndex'), + "companyAddress: ".$i18n->_('companyAddress'), + "html escaped: ".$i18n->_htmlEscaped('htmlText'), + 'placeholder: '.$i18n->_('addNumber', [ 'nr1' => 1, 'nr2' => 2, 'nr3' => 3 ]), + "notExistingIndex: ".$i18n->_('notExistingIndex'), "\n", ]; diff --git a/test/offline-test.php b/test/offline-test.php index f498952..deabb22 100755 --- a/test/offline-test.php +++ b/test/offline-test.php @@ -41,9 +41,9 @@ public function testCanInstantiateCollectionsObject(): void { public function testCanInstantiateMainObject(): void { global $api, $config, $collections, $i18n; - $i18n = new CBX\i18nClass($collections); + $i18n = new CBX\I18nClass($collections); $this->assertInstanceOf( - CBX\i18nClass::class, + CBX\I18nClass::class, $i18n ); } @@ -82,7 +82,7 @@ public function testCanHandleIfTranslationMissing(): void { public function testCanCreateObjectWithFactory(): void { global $i18nFromFactory; - $i18nFromFactory = CBX\i18n::create(LANGUAGE, DOMAIN, APIURL); + $i18nFromFactory = CBX\I18nFactory::create(LANGUAGE, DOMAIN, APIURL); $this->assertEquals( APIURL, $i18nFromFactory->getAPIURL() diff --git a/test/online-test.php b/test/online-test.php index e125501..0152082 100755 --- a/test/online-test.php +++ b/test/online-test.php @@ -41,9 +41,9 @@ public function testCanInstantiateCollectionsObject(): void { public function testCanInstantiateMainObject(): void { global $api, $config, $collections, $i18n; - $i18n = new CBX\i18nClass($collections); + $i18n = new CBX\I18nClass($collections); $this->assertInstanceOf( - CBX\i18nClass::class, + CBX\I18nClass::class, $i18n ); } @@ -82,7 +82,7 @@ public function testCanHandleIfTranslationMissing(): void { public function testCanCreateObjectWithFactory(): void { global $i18nFromFactory; - $i18nFromFactory = CBX\i18n::create(LANGUAGE, DOMAIN, APIURL); + $i18nFromFactory = CBX\I18nFactory::create(LANGUAGE, DOMAIN, APIURL); $this->assertEquals( APIURL, $i18nFromFactory->getAPIURL()