Skip to content
This repository was archived by the owner on Mar 4, 2019. It is now read-only.

Commit d8226bc

Browse files
committed
Stop reversing the suffix (Fixes #1)
1 parent 7933ebd commit d8226bc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ const getPluralMessage = (data, options) => {
4646
const keys = Object.keys(data)
4747
const messages = keys.map(key => getMessageFormat(data[key], options))
4848
const prefix = common(messages)
49-
const suffix = common(messages.map(msg => msg.split('').reverse().join('')))
50-
const cut = suffix ? (
51-
(msg) => msg.slice(prefix.length, -suffix.length)
49+
const suffixLength = common(messages.map(msg => msg.split('').reverse().join(''))).length
50+
const suffix = suffixLength > 0 ? messages[0].slice(-suffixLength) : ''
51+
const cut = suffixLength > 0 ? (
52+
(msg) => msg.slice(prefix.length, -suffixLength)
5253
) : prefix ? (
5354
(msg) => msg.slice(prefix.length)
5455
) : (

0 commit comments

Comments
 (0)