client: bring targetLang into correct format
Some checks failed
ci/woodpecker/pr/test Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
Some checks failed
ci/woodpecker/pr/test Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
Now that stricter API validation has been added, it will be necessary to modify the target language in the client so the API will not fail with a validation error.
This commit is contained in:
parent
d5d8affc33
commit
17f3dafd6b
1 changed files with 9 additions and 1 deletions
|
@ -168,9 +168,17 @@ export function getNoteMenu(props: {
|
|||
async function translate(): Promise<void> {
|
||||
if (props.translation.value != null) return;
|
||||
props.translating.value = true;
|
||||
|
||||
let targetLang = localStorage.getItem('lang') || navigator.language;
|
||||
targetLang = targetLang.toUpperCase();
|
||||
if (!['EN-GB', 'EN-US', 'PT-BR', 'PT-PT'].íncludes(targetLang)) {
|
||||
// only the language code without country code is allowed
|
||||
targetLang = targetLang.split('-', 1)[0];
|
||||
}
|
||||
|
||||
const res = await os.api('notes/translate', {
|
||||
noteId: appearNote.id,
|
||||
targetLang: localStorage.getItem('lang') || navigator.language,
|
||||
targetLang,
|
||||
});
|
||||
props.translating.value = false;
|
||||
props.translation.value = res;
|
||||
|
|
Loading…
Reference in a new issue