From 83a62992dd94a4f4879d67fb8002834025642193 Mon Sep 17 00:00:00 2001 From: DONGSHIH TENG Date: Thu, 2 Mar 2017 21:30:44 +0900 Subject: [PATCH 1/4] Not return s behind non-english --- pluralize.js | 1 + test.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pluralize.js b/pluralize.js index 9d6afe8..46dd615 100644 --- a/pluralize.js +++ b/pluralize.js @@ -301,6 +301,7 @@ */ [ [/s?$/i, 's'], + [/[^\u0000-\u007F]+/i, '$0'], [/([^aeiou]ese)$/i, '$1'], [/(ax|test)is$/i, '$1es'], [/(alias|[^aou]us|tlas|gas|ris)$/i, '$1es'], diff --git a/test.js b/test.js index db70f5b..a2d7c27 100644 --- a/test.js +++ b/test.js @@ -581,7 +581,11 @@ var BASIC_TESTS = [ ['camelCase', 'camelCases'], ['PascalCase', 'PascalCases'], ['Alumnus', 'Alumni'], - ['CHICKEN', 'CHICKENS'] + ['CHICKEN', 'CHICKENS'], + ['日本語', '日本語'], + ['한국', '한국'], + ['中文', '中文'], + ['اللغة العربية', 'اللغة العربية'] ]; /** From e545b6213c62c101a7a630abd35e62fb03ca0452 Mon Sep 17 00:00:00 2001 From: DONGSHIH TENG Date: Thu, 2 Mar 2017 21:38:05 +0900 Subject: [PATCH 2/4] Sample code for chinese word --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index ede0ae7..7579b1f 100644 --- a/Readme.md +++ b/Readme.md @@ -63,6 +63,8 @@ pluralize.plural('irregular') //=> "regular" pluralize.plural('paper') //=> "papers" pluralize.addUncountableRule('paper') pluralize.plural('paper') //=> "paper" + +pluralize('蘋果', 2, true) //=> "2 蘋果" ``` ## License From a34683dc2306212e5be7095baef2ac38043c993d Mon Sep 17 00:00:00 2001 From: DONGSHIH TENG Date: Fri, 3 Mar 2017 11:13:19 +0900 Subject: [PATCH 3/4] Consider ending word's ASCII --- pluralize.js | 2 +- test.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pluralize.js b/pluralize.js index 46dd615..d0a41a1 100644 --- a/pluralize.js +++ b/pluralize.js @@ -301,7 +301,7 @@ */ [ [/s?$/i, 's'], - [/[^\u0000-\u007F]+/i, '$0'], + [/[^\u0000-\u007F]$/i, '$0'], [/([^aeiou]ese)$/i, '$1'], [/(ax|test)is$/i, '$1es'], [/(alias|[^aou]us|tlas|gas|ris)$/i, '$1es'], diff --git a/test.js b/test.js index a2d7c27..19396f2 100644 --- a/test.js +++ b/test.js @@ -585,7 +585,8 @@ var BASIC_TESTS = [ ['日本語', '日本語'], ['한국', '한국'], ['中文', '中文'], - ['اللغة العربية', 'اللغة العربية'] + ['اللغة العربية', 'اللغة العربية'], + ['四 chicken', '四 chickens'] ]; /** From 72bdcb7291be0cb5e9f3562eb7022ae60c96838d Mon Sep 17 00:00:00 2001 From: DONGSHIH TENG Date: Fri, 3 Mar 2017 11:15:11 +0900 Subject: [PATCH 4/4] Move sample code --- Readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 7579b1f..dc5342d 100644 --- a/Readme.md +++ b/Readme.md @@ -47,6 +47,7 @@ pluralize('test', 1) //=> "test" pluralize('test', 5) //=> "tests" pluralize('test', 1, true) //=> "1 test" pluralize('test', 5, true) //=> "5 tests" +pluralize('蘋果', 2, true) //=> "2 蘋果" pluralize.plural('regex') //=> "regexes" pluralize.addPluralRule(/gex$/i, 'gexii') @@ -63,8 +64,6 @@ pluralize.plural('irregular') //=> "regular" pluralize.plural('paper') //=> "papers" pluralize.addUncountableRule('paper') pluralize.plural('paper') //=> "paper" - -pluralize('蘋果', 2, true) //=> "2 蘋果" ``` ## License