mattermost/server/channels/utils/humanize.go
Agniva De Sarker 9431239b2e
MM-57378: Bump up golangci version (#26535)
https://mattermost.atlassian.net/browse/MM-57378
```release-note
NONE
```

Co-authored-by: Mattermost Build <build@mattermost.com>
2024-03-22 10:23:21 +05:30

24 lines
499 B
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package utils
import (
"strings"
"github.com/mattermost/mattermost/server/public/shared/i18n"
)
func JoinList(items []string) string {
if len(items) == 0 {
return ""
} else if len(items) == 1 {
return items[0]
}
return i18n.T(
"humanize.list_join",
map[string]any{
"OtherItems": strings.Join(items[:len(items)-1], ", "),
"LastItem": items[len(items)-1],
})
}