From 02490c798cbfee892c7e51b2e72fcbfaea6b4147 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Tue, 6 Apr 2021 12:38:45 -0400 Subject: [PATCH] Only set lang on initial publish in all editors This fixes #280 in all editors, continuing work from #435. --- templates/bare.tmpl | 9 +++++---- templates/wysiwyg.tmpl | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/templates/bare.tmpl b/templates/bare.tmpl index d2c8bc0..f76eed9 100644 --- a/templates/bare.tmpl +++ b/templates/bare.tmpl @@ -105,15 +105,12 @@ $btnPublish.el.disabled = true; var http = new XMLHttpRequest(); - var lang = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage); - lang = lang.substring(0, 2); var post = H.getTitleStrict(content); var params = { body: post.content, title: post.title, - font: font, - lang: lang + font: font }; {{ if .Post.Slug }} var url = "/api/collections/{{.EditCollection.Alias}}/posts/{{.Post.Id}}"; @@ -124,6 +121,10 @@ } params.token = token; {{ else }} + var lang = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage); + lang = lang.substring(0, 2); + params.lang = lang; + var url = "/api/posts"; var postTarget = '{{if .Blogs}}{{$c := index .Blogs 0}}{{$c.Alias}}{{else}}anonymous{{end}}'; if (postTarget != 'anonymous') { diff --git a/templates/wysiwyg.tmpl b/templates/wysiwyg.tmpl index a1600bc..42a6bce 100644 --- a/templates/wysiwyg.tmpl +++ b/templates/wysiwyg.tmpl @@ -168,15 +168,12 @@ var xpostTarg = H.get('crosspostTarget', '[]'); var http = new XMLHttpRequest(); - var lang = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage); - lang = lang.substring(0, 2); var post = H.getTitleStrict(content); var params = { body: post.content, title: title, - font: font, - lang: lang + font: font }; {{ if .Post.Slug }} var url = "/api/collections/{{.EditCollection.Alias}}/posts/{{.Post.Id}}"; @@ -187,6 +184,10 @@ } params.token = token; {{ else }} + var lang = navigator.languages ? navigator.languages[0] : (navigator.language || navigator.userLanguage); + lang = lang.substring(0, 2); + params.lang = lang; + var url = "/api/posts"; var postTarget = H.get('postTarget', 'anonymous'); if (postTarget != 'anonymous') {