Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Issue 78 refactor translator #122

Merged
merged 68 commits into from
Jun 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d850c69
start fixing tests
prisis Dec 25, 2015
a48c9f3
Fixed some tests | add narrowspark-cs-fixer-config
prisis Dec 25, 2015
733682f
fixed all PluralCategorys tests
prisis Dec 26, 2015
79d6b62
Merge branch 'develop' into issue-78-refactor-translator
prisis Dec 27, 2015
1410495
cs fixes
prisis Dec 27, 2015
3650e7c
removed all not needed traits
prisis Dec 27, 2015
d34e6ca
Merge branch 'develop' into issue-78-refactor-translator
prisis Jan 2, 2016
ca73128
remove some old use
prisis Jan 3, 2016
136582f
small changes
prisis Jan 3, 2016
237be3a
changing all string outputs to int for array support | refactor tests
prisis Jan 3, 2016
4f1d073
fixed all tests
Jan 4, 2016
ddc3994
added log psr and sepia/po-parser to composer
prisis Jan 4, 2016
bdd93d3
Added 3 parser files
prisis Jan 4, 2016
e7cfe97
fixed phpdocs | added test for ValidateLocaleTrait
Jan 5, 2016
88e02a6
rename file
Jan 5, 2016
3a82a8d
small changes
Jan 5, 2016
6b439b6
Merge branch 'develop' into issue-78-refactor-translator
prisis Jan 5, 2016
30eb701
remove fallbackresolver | samll changes
prisis Jan 6, 2016
86f23a0
Merge branch 'develop' into issue-78-refactor-translator
prisis Jan 6, 2016
0390195
Merge branch 'develop' into issue-78-refactor-translator
Jan 18, 2016
6c41ae1
Applied fixes from StyleCI
prisis Jan 18, 2016
5ff946c
Merge pull request #134 from narrowspark/analysis-8AD2Py
prisis Jan 18, 2016
6bb895c
Added LoggerwareTrait | update some composer.json files
Jan 18, 2016
3043d7d
Applied fixes from StyleCI
prisis Jan 22, 2016
ea7cd45
Merge pull request #150 from narrowspark/analysis-XZllbR
prisis Jan 22, 2016
f51c50b
Merge branch 'develop' into issue-78-refactor-translator
prisis May 12, 2016
d2c3a1d
Merge branch 'develop' into issue-78-refactor-translator
prisis May 15, 2016
3b68fda
Merge branch 'develop' into issue-78-refactor-translator
prisis May 16, 2016
c68039f
fix composer
prisis May 16, 2016
58130f3
fix namespace
prisis May 16, 2016
3348448
moved some classes to formats
prisis May 17, 2016
e7fde20
Applied fixes from StyleCI
prisis May 17, 2016
3dd4f3f
Merge pull request #238 from narrowspark/analysis-8neK2N
prisis May 17, 2016
ec28f81
added more tests
prisis May 17, 2016
51b4fcf
added manager
prisis May 17, 2016
4443f58
Applied fixes from StyleCI
prisis May 17, 2016
2c60a5e
Merge pull request #240 from narrowspark/analysis-zDyD6L
prisis May 17, 2016
045bdb6
Moved FileLoader | added new Traits | fixed Manager
prisis May 18, 2016
69485cb
Applied fixes from StyleCI
prisis May 18, 2016
1193fb0
Merge pull request #241 from narrowspark/analysis-q16kML
prisis May 18, 2016
fd64610
fix cache setting
prisis May 18, 2016
e8b1a04
fix config tests
prisis May 19, 2016
4fbf9b5
Applied fixes from StyleCI
prisis May 19, 2016
c7f6e85
Merge pull request #242 from narrowspark/analysis-Xa6Qgm
prisis May 19, 2016
c4e7113
Moved some traits
prisis May 20, 2016
7e24308
Applied fixes from StyleCI
prisis May 20, 2016
42d1b05
Merge pull request #244 from narrowspark/analysis-zRPYNY
prisis May 20, 2016
70f6b81
Merge branch 'develop' into issue-78-refactor-translator
prisis May 20, 2016
405b2e9
Rename Translator to Translation
prisis May 20, 2016
6a106f9
update
prisis Jun 20, 2016
afdd760
Merge branch 'develop' into issue-78-refactor-translator
prisis Jun 20, 2016
ff1c742
remove translator
prisis Jun 20, 2016
7187981
fix tests
prisis Jun 20, 2016
bd757dd
fix tests
prisis Jun 20, 2016
fb410e4
Scrutinizer Auto-Fixes (#287)
scrutinizer-auto-fixer Jun 20, 2016
f7be488
try fix humbug
prisis Jun 20, 2016
8c26c98
remove loop
prisis Jun 20, 2016
c53cdd3
Merge branch 'develop' into issue-78-refactor-translator
prisis Jun 23, 2016
358acfb
adding new classes
prisis Jun 23, 2016
cd8a8b2
fix tests
prisis Jun 23, 2016
1966c80
fixed type
prisis Jun 23, 2016
5b8a7be
added small changes
prisis Jun 23, 2016
bb8bb66
update to php7
prisis Jun 24, 2016
21595e9
added csv
prisis Jun 24, 2016
b93e3d3
added all parser tests
prisis Jun 25, 2016
ddca570
added more tests
prisis Jun 25, 2016
3b514f7
changes for php7
prisis Jun 25, 2016
a2c32fe
remove a trait
prisis Jun 25, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ before_install:
- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d
- if [ -f build/travis/php/$TRAVIS_PHP_VERSION.sh]; then ./build/travis/php/$TRAVIS_PHP_VERSION.sh; fi
- if [[ "$PHP" != hhvm* ]]; then composer global require hirak/prestissimo; fi # Now composer can install components parallel
- if [[ "$HUMBUG" = "true" ]]; then composer require humbug/humbug; fi
- if [[ "$HUMBUG" = "true" ]]; then composer global require humbug/humbug; fi
- git config --global user.name travis-ci
- git config --global user.email travis@example.com

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"viserio",
"container",
"pipeline",
"event"
"event",
"translation"
],
"license" : "MIT",
"homepage" : "https://github.com/narrowspark/framework",
Expand Down Expand Up @@ -124,6 +125,7 @@
"roave/security-advisories" : "dev-master",
"symfony/yaml" : "^3.1",
"spatie/array-to-xml" : "^2.1",
"sepia/po-parser" : "^4.2",
"yosymfony/toml" : "^0.3"
},
"autoload": {
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@
<testsuite name="Narrowspark Support Component Test Suite">
<directory>./src/Viserio/Support/Tests</directory>
</testsuite>
<!-- <testsuite name="Narrowspark Translator Component Test Suite">
<directory>./src/Viserio/Translator/Tests</directory>
</testsuite> -->
<testsuite name="Narrowspark Translation Component Test Suite">
<directory>./src/Viserio/Translation/Tests</directory>
</testsuite>
<!-- <testsuite name="Narrowspark View Component Test Suite">
<directory>./src/Viserio/View/Tests</directory>
</testsuite> -->
Expand Down
22 changes: 12 additions & 10 deletions src/Viserio/Cache/CacheManager.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php
namespace Viserio\Cache;

use Cache\Adapter\Apc\ApcCachePool;
use Cache\Adapter\Apcu\ApcuCachePool;
use Cache\Adapter\Filesystem\FilesystemCachePool;
use Cache\Adapter\Memcache\MemcacheCachePool;
use Cache\Adapter\Memcached\MemcachedCachePool;
use Cache\Adapter\MongoDB\MongoDBCachePool;
use Cache\Adapter\PHPArray\ArrayCachePool;
use Cache\Adapter\Predis\PredisCachePool;
use Cache\Adapter\Redis\RedisCachePool;
use Cache\Adapter\Void\VoidCachePool;
use Cache\Adapter\{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one USE keyword per declaration

Apc\ApcCachePool,
Apcu\ApcuCachePool,
Filesystem\FilesystemCachePool,
Memcache\MemcacheCachePool,
Memcached\MemcachedCachePool,
MongoDB\MongoDBCachePool,
PHPArray\ArrayCachePool,
Predis\PredisCachePool,
Redis\RedisCachePool,
Void\VoidCachePool
};
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem as Flysystem;
use Memcache;
Expand Down
60 changes: 32 additions & 28 deletions src/Viserio/Config/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

use ArrayIterator;
use IteratorAggregate;
use Viserio\Contracts\Config\Manager as ManagerContract;
use Viserio\Contracts\Config\Repository as RepositoryContract;
use Viserio\Contracts\Parsers\Loader as LoaderContract;
use Viserio\Contracts\{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be one USE keyword per declaration

Config\Manager as ManagerContract,
Config\Repository as RepositoryContract,
Parsers\Loader as LoaderContract
};

class Manager implements ManagerContract, IteratorAggregate
{
Expand All @@ -19,7 +21,7 @@ class Manager implements ManagerContract, IteratorAggregate
/**
* Fileloader instance.
*
* @var \Viserio\Contracts\Config\Loader
* @var \Viserio\Contracts\Parsers\Loader
*/
protected $loader;

Expand Down Expand Up @@ -61,38 +63,16 @@ public function __call(string $method, array $params = [])
* Set Viserio's defaults using the repository.
*
* @param array $array
*/
public function setArray(array $array): ManagerContract
{
$this->repository->setArray($array);

return $this;
}

/**
* Get the configuration loader.
*
* @param \Viserio\Contracts\Parsers\Loader $loader
*
* @return self
*/
public function setLoader(LoaderContract $loader): ManagerContract
public function setArray(array $array): ManagerContract
{
$this->loader = $loader;
$this->repository->setArray($array);

return $this;
}

/**
* Get the configuration loader.
*
* @return \Viserio\Contracts\Parsers\Loader
*/
public function getLoader(): LoaderContract
{
return $this->loader;
}

/**
* Import configuation from file.
* Can be grouped together.
Expand Down Expand Up @@ -209,4 +189,28 @@ public function getIterator(): ArrayIterator
{
return $this->repository->getIterator();
}

/**
* Set the file loader.
*
* @param \Viserio\Contracts\Parsers\Loader $loader
*
* @return self
*/
public function setLoader(LoaderContract $loader)
{
$this->loader = $loader;

return $this;
}

/**
* Get the file loader.
*
* @return \Viserio\Contracts\Parsers\Loader
*/
public function getLoader()
{
return $this->loader;
}
}
2 changes: 1 addition & 1 deletion src/Viserio/Config/Tests/ConfigManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ConfigManagerTest extends \PHPUnit_Framework_TestCase
private $root;

/**
* @var \Viserio\Filesystem\FileLoader
* @var \Viserio\Parsers\FileLoader
*/
private $fileloader;

Expand Down
18 changes: 0 additions & 18 deletions src/Viserio/Config/Tests/Traits/ConfigAwareTraitTest.php

This file was deleted.

45 changes: 0 additions & 45 deletions src/Viserio/Config/Traits/ConfigAwareTrait.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/Viserio/Config/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"require": {
"php" : "7.0.0 - 7.0.5 || ^7.0.7",
"narrowspark/arr" : "^1.0",
"viserio/cotracts" : "self.version",
"viserio/support" : "self.version"
"viserio/cotracts" : "self.version"
},
"require-dev": {
"phpunit/phpunit" : "^5.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Viserio\Contracts\Translator;
namespace Viserio\Contracts\Translation\Exception;

use InvalidArgumentException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Viserio\Contracts\Translator;
namespace Viserio\Contracts\Translation;

interface MessageCatalogue
{
Expand Down Expand Up @@ -34,8 +34,10 @@ public function all(string $domain = null): array;
* @param string $id The message id
* @param string $translation The messages translation
* @param string $domain The domain name
*
* @return void
*/
public function set($id, string $translation, string $domain = 'messages');
public function set(string $id, string $translation, string $domain = 'messages');

/**
* Checks if a message has a translation.
Expand Down Expand Up @@ -72,14 +74,28 @@ public function get(string $id, string $domain = 'messages'): string;
*
* @param array $messages An array of translations
* @param string $domain The domain name
*
* @return void
*/
public function replace(array $messages, string $domain = 'messages');

/**
* Removes a record.
*
* @param string $messages
* @param string $domain
*
* @return void
*/
public function remove(string $messages, string $domain = 'messages');

/**
* Adds translations for a given domain.
*
* @param array $messages An array of translations
* @param string $domain The domain name
*
* @return void
*/
public function add(array $messages, string $domain = 'messages');

Expand All @@ -89,6 +105,10 @@ public function add(array $messages, string $domain = 'messages');
* The two catalogues must have the same locale.
*
* @param MessageCatalogue $catalogue A MessageCatalogue instance
*
* @throws \LogicException
*
* @return void
*/
public function addCatalogue(MessageCatalogue $catalogue);

Expand All @@ -99,6 +119,10 @@ public function addCatalogue(MessageCatalogue $catalogue);
* This is used to provide default translations when they do not exist for the current locale.
*
* @param MessageCatalogue $catalogue A MessageCatalogue instance
*
* @throws \LogicException
*
* @return void
*/
public function addFallbackCatalogue(MessageCatalogue $catalogue);

Expand All @@ -108,4 +132,13 @@ public function addFallbackCatalogue(MessageCatalogue $catalogue);
* @return MessageCatalogue|null A MessageCatalogue instance or null when no fallback has been set
*/
public function getFallbackCatalogue();

/**
* Set parent.
*
* @param MessageCatalogue $parent
*
* @return self
*/
public function setParent(MessageCatalogue $parent): MessageCatalogue;
}
14 changes: 14 additions & 0 deletions src/Viserio/Contracts/Translation/PluralCategory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Viserio\Contracts\Translation;

interface PluralCategory
{
/**
* Returns category key by count.
*
* @param int|string $count
*
* @return int
*/
public function category($count): int;
}
33 changes: 33 additions & 0 deletions src/Viserio/Contracts/Translation/TransChecker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
namespace Viserio\Contracts\Translation;

interface TransChecker
{
/**
* Get the default locale being used.
*
* @return string
*/
public function getDefaultLocale(): string;

/**
* Get the locales to check.
*
* @return array
*/
public function getLocales(): array;

/**
* Get the ignored translation attributes.
*
* @return array
*/
public function getIgnoredTranslations(): array;

/**
* Check the missing translations.
*
* @return array
*/
public function check(): array;
}
Loading