From 9ac23fdbd1714ef04994190ecef46d9e61d07793 Mon Sep 17 00:00:00 2001 From: nanaya Date: Sat, 3 Dec 2022 02:53:56 +0900 Subject: [PATCH] Fix joining one component --- resources/assets/lib/utils/lang.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/resources/assets/lib/utils/lang.tsx b/resources/assets/lib/utils/lang.tsx index e571e7d7de8..4286cdc4e15 100644 --- a/resources/assets/lib/utils/lang.tsx +++ b/resources/assets/lib/utils/lang.tsx @@ -15,15 +15,17 @@ export function joinComponents(array: React.ReactElement[], key = 'common.array_ if (array.length > 0) { nodes.push(array[0]); - const lastIndex = array.length - 1; - const lastConnector = lastIndex === 1 ? trans(`${key}.two_words_connector`) : trans(`${key}.last_word_connector`); - const connector = trans(`${key}.words_connector`); + if (array.length > 1) { + const lastIndex = array.length - 1; + const lastConnector = lastIndex === 1 ? trans(`${key}.two_words_connector`) : trans(`${key}.last_word_connector`); + const connector = trans(`${key}.words_connector`); - for (let i = 1; i < lastIndex; i++) { - nodes.push({connector}{array[i]}); - } + for (let i = 1; i < lastIndex; i++) { + nodes.push({connector}{array[i]}); + } - nodes.push({lastConnector}{array[lastIndex]}); + nodes.push({lastConnector}{array[lastIndex]}); + } } return <>{nodes};