From 428ed70b0d3aed60cc7fafc59a4f31a793a10662 Mon Sep 17 00:00:00 2001 From: Oneric Date: Mon, 26 Feb 2024 08:02:13 +0100 Subject: [PATCH] Fix posting for special interface languages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/components/post_status_form/post_status_form.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 703d8a63..6d7cd3a0 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -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 } }