Skip to content

Commit

Permalink
fix(l10n): add context for translators (second vs. seconds)
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <[email protected]>
  • Loading branch information
st3iny committed Feb 20, 2025
1 parent 7de5bde commit 9d76c8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
27 changes: 5 additions & 22 deletions src/components/Editor/Repeat/RepeatFirstLastSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<script>
import { NcSelect } from '@nextcloud/vue'
import { getTranslatedOrdinalNumber } from '../../../filters/recurrenceRuleFormat.js'

export default {
name: 'RepeatFirstLastSelect',
Expand All @@ -41,28 +42,10 @@ export default {
},
computed: {
options() {
return [{
label: this.$t('calendar', 'first'),
value: 1,
}, {
label: this.$t('calendar', 'second'),
value: 2,
}, {
label: this.$t('calendar', 'third'),
value: 3,
}, {
label: this.$t('calendar', 'fourth'),
value: 4,
}, {
label: this.$t('calendar', 'fifth'),
value: 5,
}, {
label: this.$t('calendar', 'second to last'),
value: -2,
}, {
label: this.$t('calendar', 'last'),
value: -1,
}]
return [1, 2, 3, 4, 5, -2, -1].map((ordinal) => ({
label: getTranslatedOrdinalNumber(ordinal),
value: ordinal,
}))

Check warning on line 48 in src/components/Editor/Repeat/RepeatFirstLastSelect.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Editor/Repeat/RepeatFirstLastSelect.vue#L46-L48

Added lines #L46 - L48 were not covered by tests
},
selected() {
return this.options.find(option => option.value === this.bySetPosition)
Expand Down
3 changes: 2 additions & 1 deletion src/filters/recurrenceRuleFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@ function getTranslatedMonths(byMonthList) {
* @param {number} bySetPositionNum The by-set-position number to get the translation of
* @return {string}
*/
function getTranslatedOrdinalNumber(bySetPositionNum) {
export function getTranslatedOrdinalNumber(bySetPositionNum) {
switch (bySetPositionNum) {
case 1:
return t('calendar', 'first')

case 2:
// TRANSLATORS This refers to the second item in a series, not to the unit of time
return t('calendar', 'second')

case 3:
Expand Down

0 comments on commit 9d76c8c

Please sign in to comment.