Skip to content
Snippets Groups Projects
Commit 22029f3b authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: add humanJoin helper function

parent 8e07ad21
No related branches found
No related tags found
No related merge requests found
......@@ -695,6 +695,12 @@ export default {
size: 'Dateigröße',
},
humanJoin: {
default: ', ',
and: ' und ',
or: ' oder ',
},
rrule: {
rrule: 'Wiederholungsregel',
......
......@@ -687,7 +687,12 @@ export default {
size: 'File size',
},
// Etc
humanJoin: {
default: ', ',
and: ', and ',
or: ', or ',
},
rrule: {
rrule: 'Repetition rule',
......
......@@ -337,3 +337,14 @@ export function useForeignSlotNames() {
.map(([key]) => key)
})
}
export function humanJoin(iterable: Iterable<string>, glue: string, lastGlue: string) {
const array = Array.from(iterable)
if (array.length === 0) return ''
if (array.length === 1) return array[0]
if (array.length === 2) return array.join(lastGlue)
const lastValue = array.pop() as string
return `${array.join(glue)}${lastGlue}${lastValue}`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment