Fix posting for special interface languages
ci/woodpecker/pr/woodpecker Pipeline was successful Details

Easy Japanses (ja_easy) and traditional Chinses (zh_Hant) use
(custom) non-ISO codes in the interface. Because MastoAPI only accepts
ISO 639 codes, the backend will return an error rendering users
unable to do anything unless the post’s language was explicitly set.
This commit is contained in:
Oneric 2024-02-26 08:02:13 +01:00
parent ed0b403c33
commit 428ed70b0d
1 changed files with 11 additions and 2 deletions

View File

@ -62,6 +62,13 @@ const deleteDraft = (draftKey) => {
localStorage.setItem('drafts', JSON.stringify(draftData));
}
const interfaceToISOLanguage = (ilang) => {
const sep = ilang.indexOf("_");
return sep < 0 ?
ilang :
ilang.substr(0, sep);
}
const PostStatusForm = {
props: [
'statusId',
@ -140,6 +147,8 @@ const PostStatusForm = {
const { postContentType: contentType, sensitiveByDefault, sensitiveIfSubject, interfaceLanguage, alwaysShowSubjectInput } = this.$store.getters.mergedConfig
const isoLanguage = interfaceToISOLanguage(interfaceLanguage)
let statusParams = {
spoilerText: this.subject || '',
status: statusText,
@ -149,7 +158,7 @@ const PostStatusForm = {
poll: {},
mediaDescriptions: {},
visibility: this.suggestedVisibility(),
language: interfaceLanguage,
language: isoLanguage,
contentType
}
@ -164,7 +173,7 @@ const PostStatusForm = {
poll: this.statusPoll || {},
mediaDescriptions: this.statusMediaDescriptions || {},
visibility: this.statusScope || this.suggestedVisibility(),
language: this.statusLanguage || interfaceLanguage,
language: this.statusLanguage || isoLanguage,
contentType: statusContentType
}
}