From 39d5313a2ca699a819ac001692c00659f203b30a Mon Sep 17 00:00:00 2001 From: nationalcat Date: Tue, 20 Jun 2017 13:57:38 +0800 Subject: [PATCH 1/3] add zh-TW locale --- src/dict/zh-tw.php | 87 ++++++++++++++++++++++++++++++++++ src/lang/zh-tw/validation.php | 5 ++ tests/ProfaneValidatorTest.php | 8 ++-- 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 src/dict/zh-tw.php create mode 100644 src/lang/zh-tw/validation.php diff --git a/src/dict/zh-tw.php b/src/dict/zh-tw.php new file mode 100644 index 0000000..cad3c14 --- /dev/null +++ b/src/dict/zh-tw.php @@ -0,0 +1,87 @@ + ':attribute欄位內容包含粗俗用詞,請您修正:)' +]; diff --git a/tests/ProfaneValidatorTest.php b/tests/ProfaneValidatorTest.php index d93a3b2..dd72042 100644 --- a/tests/ProfaneValidatorTest.php +++ b/tests/ProfaneValidatorTest.php @@ -28,8 +28,8 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase { $this->mockConfigs(); $attribute = 'description'; - $text = 'fck you bitch'; - $parameters = ['es', 'en']; + $text = 'fck you bitch. 幹!'; + $parameters = ['es', 'en' , 'zh-TW']; $profane = new ProfaneValidator(); @@ -117,9 +117,9 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase $this->mockConfigs(); $profane = new ProfaneValidator(); - $profane->setDictionary(['es', 'en']); + $profane->setDictionary(['es', 'en', 'it', 'zh-TW']); - $expected = array_merge(include __DIR__.'/../src/dict/es.php', include __DIR__.'/../src/dict/en.php'); + $expected = array_merge(include __DIR__.'/../src/dict/es.php', include __DIR__.'/../src/dict/en.php', include __DIR__.'/../src/dict/it.php', include __DIR__.'/../src/dict/zh-TW.php'); $this->assertEquals($profane->getBadwords(), $expected); } From 579ceafc9c52c630a619a4b967f717e0b5a25f92 Mon Sep 17 00:00:00 2001 From: Nationalcat Date: Tue, 20 Jun 2017 14:03:43 +0800 Subject: [PATCH 2/3] add zh-TW locale --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 22653dd..9eccab5 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Pull requests are welcome, but please make sure you provide unit tests to cover - English - Spanish - Italian ( provided by @aletundo ) +- Traditional Chinese ( provided by @Nationalcat ) ## License This project is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT). From 2ffa02d32909185088697f5bc6117dd7ca09c604 Mon Sep 17 00:00:00 2001 From: Nationalcat Date: Tue, 20 Jun 2017 18:36:10 +0800 Subject: [PATCH 3/3] Update ProfaneValidatorTest.php --- tests/ProfaneValidatorTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ProfaneValidatorTest.php b/tests/ProfaneValidatorTest.php index dd72042..d3c4b4c 100644 --- a/tests/ProfaneValidatorTest.php +++ b/tests/ProfaneValidatorTest.php @@ -29,7 +29,7 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase $this->mockConfigs(); $attribute = 'description'; $text = 'fck you bitch. 幹!'; - $parameters = ['es', 'en' , 'zh-TW']; + $parameters = ['es', 'en' , 'zh-tw']; $profane = new ProfaneValidator(); @@ -117,9 +117,9 @@ class ProfaneValidatorTest extends PHPUnit_Framework_TestCase $this->mockConfigs(); $profane = new ProfaneValidator(); - $profane->setDictionary(['es', 'en', 'it', 'zh-TW']); + $profane->setDictionary(['es', 'en', 'it', 'zh-tw']); - $expected = array_merge(include __DIR__.'/../src/dict/es.php', include __DIR__.'/../src/dict/en.php', include __DIR__.'/../src/dict/it.php', include __DIR__.'/../src/dict/zh-TW.php'); + $expected = array_merge(include __DIR__.'/../src/dict/es.php', include __DIR__.'/../src/dict/en.php', include __DIR__.'/../src/dict/it.php', include __DIR__.'/../src/dict/zh-tw.php'); $this->assertEquals($profane->getBadwords(), $expected); }