From e710b045691c4f2a6bb9dc842aa02a782f9c4bf3 Mon Sep 17 00:00:00 2001 From: Nikita Katkov Date: Tue, 26 Mar 2024 12:32:02 +0100 Subject: [PATCH] [json + javascript] IJ-CR-129937 Fix wording and utilize message bundle's choice feature GitOrigin-RevId: 192f55c99b60bfddf8e75f0588bd95e09a05ca4a --- json/resources/messages/JsonBundle.properties | 3 +-- .../json/psi/impl/jsonArrayPresentationUtils.kt | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/json/resources/messages/JsonBundle.properties b/json/resources/messages/JsonBundle.properties index 5bc0456049e0..557badf7baf6 100644 --- a/json/resources/messages/JsonBundle.properties +++ b/json/resources/messages/JsonBundle.properties @@ -245,5 +245,4 @@ JsonJacksonReformatAction.command.name.json.reformat=JSON Reformat JsonJacksonReformatAction.dialog.title.json.reformatting=JSON Reformatting JsonJacksonReformatAction.dialog.message.this.action.not.undoable.do.you.want.to.reformat.document=This action cannot be reverted. Do you want to reformat the document? -folding.collapsed.array.one.element.text=[ {0} element\u2026 ] -folding.collapsed.array.several.elements.text=[ {0} elements\u2026 ] \ No newline at end of file +folding.collapsed.array.one.element.text=[ {0} {1,choice,1#element|2#elements}\u2026 ] \ No newline at end of file diff --git a/json/src/com/intellij/json/psi/impl/jsonArrayPresentationUtils.kt b/json/src/com/intellij/json/psi/impl/jsonArrayPresentationUtils.kt index d44cf3f2e536..454ee22e3da4 100644 --- a/json/src/com/intellij/json/psi/impl/jsonArrayPresentationUtils.kt +++ b/json/src/com/intellij/json/psi/impl/jsonArrayPresentationUtils.kt @@ -13,10 +13,13 @@ internal fun getCollectionPsiPresentationText(array: JsonArray): @Nls String { } fun getCollectionPsiPresentationText(childrenCount: Int): @Nls String { - return if (childrenCount % 10 == 1) { - JsonBundle.message("folding.collapsed.array.one.element.text", childrenCount) + return if (childrenCount % 10 == 1 && childrenCount % 100 != 11) { + JsonBundle.message("folding.collapsed.array.one.element.text", childrenCount, SINGULAR_FORM) } else { - JsonBundle.message("folding.collapsed.array.several.elements.text", childrenCount) + JsonBundle.message("folding.collapsed.array.one.element.text", childrenCount, PLURAL_FORM) } -} \ No newline at end of file +} + +private const val SINGULAR_FORM = 1 +private const val PLURAL_FORM = 2 \ No newline at end of file