Skip to content

Commit f90d565

Browse files
authored
Merge pull request #4033 from nextcloud/fix/language-code-luxon
Use different formatted language code for luxon
2 parents 7f71965 + 81c4f70 commit f90d565

6 files changed

Lines changed: 12 additions & 6 deletions

File tree

lib/Model/UserBase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ public function getLanguageCode(): string {
167167
return $this->languageCode;
168168
}
169169

170+
public function getLanguageCodeIntl(): string {
171+
return str_replace('_', '-', $this->languageCode);
172+
}
173+
170174
public function getLocaleCode(): string {
171175
if (!$this->localeCode) {
172176
return $this->languageCode;
@@ -323,6 +327,7 @@ public function getRichUserArray(): array {
323327
'isNoUser' => $this->getIsNoUser(),
324328
'isUnrestrictedOwner' => $this->getIsUnrestrictedPollOwner(),
325329
'languageCode' => $this->getLanguageCode(),
330+
'languageCodeIntl' => $this->getLanguageCodeIntl(),
326331
'localeCode' => $this->getLocaleCode(),
327332
'organisation' => $this->getOrganisation(),
328333
'subname' => $this->getSubName(),

src/Types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export type User = {
164164
desc: string | null
165165
organisation: string | null
166166
languageCode: string
167+
languageCodeIntl: string
167168
localeCode: string | null
168169
timeZone: string | null
169170
categories: string[] | null

src/components/Base/modules/DateBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { dateTime: luxonDate, duration: luxonDuration = Duration.fromMillis(0) }
1616
defineProps<Props>()
1717
1818
const from = computed(() =>
19-
luxonDate.setLocale(sessionStore.currentUser.languageCode),
19+
luxonDate.setLocale(sessionStore.currentUser.languageCodeIntl),
2020
)
2121
2222
const sessionStore = useSessionStore()

src/components/Export/ExportPoll.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function getIntervalRaw(option: Option): string {
212212
*/
213213
function getFromFormatted(option: Option): string {
214214
return DateTime.fromSeconds(option.timestamp)
215-
.setLocale(sessionStore.currentUser.languageCode)
215+
.setLocale(sessionStore.currentUser.languageCodeIntl)
216216
.toLocaleString(DateTime.DATETIME_MED_WITH_WEEKDAY)
217217
}
218218
@@ -222,7 +222,7 @@ function getFromFormatted(option: Option): string {
222222
*/
223223
function getToFormatted(option: Option): string {
224224
return DateTime.fromSeconds(option.timestamp)
225-
.setLocale(sessionStore.currentUser.languageCode)
225+
.setLocale(sessionStore.currentUser.languageCodeIntl)
226226
.plus({ seconds: option.duration })
227227
.toLocaleString(DateTime.DATETIME_MED_WITH_WEEKDAY)
228228
}

src/components/Options/OptionItemDateBox.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const { timeStamp, durationSeconds = 0 } = defineProps<Props>()
1919
2020
// computed from as DateTime from Luxon
2121
const from = DateTime.fromSeconds(timeStamp).setLocale(
22-
sessionStore.currentUser.languageCode,
22+
sessionStore.currentUser.languageCodeIntl,
2323
)
2424
2525
const duration = Duration.fromMillis(durationSeconds * 1000)

src/components/Options/OptionsDateAddDialog.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ const dateTimeOptionsFiltered = computed(() => {
8686
// computed from as DateTime from Luxon
8787
const from = computed(() => {
8888
const dateFrom = DateTime.fromJSDate(fromInput.value).setLocale(
89-
sessionStore.currentUser.languageCode,
89+
sessionStore.currentUser.languageCodeIntl,
9090
)
9191
// if the option is an all day option, the time is set to 00:00
9292
if (allDay.value) {
9393
return dateFrom
9494
.startOf('day')
95-
.setLocale(sessionStore.currentUser.languageCode)
95+
.setLocale(sessionStore.currentUser.languageCodeIntl)
9696
}
9797
return dateFrom
9898
})

0 commit comments

Comments
 (0)