Auto fix common language code issues (i.e. jp not ja)

This commit is contained in:
dangered wolf 2023-08-20 21:50:11 -04:00
parent 775d244c7b
commit 85560e90c0
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -26,6 +26,21 @@ export const translateTweet = async (
let translationApiResponse; let translationApiResponse;
let translationResults: TranslationPartial; let translationResults: TranslationPartial;
/* Fix up some language codes that may be mistakenly used */
switch(language) {
case 'jp':
language = 'ja';
break;
case 'kr':
language = 'ko';
break;
case 'ua':
language = 'uk';
break;
default:
break;
}
headers['x-twitter-client-language'] = language; headers['x-twitter-client-language'] = language;
/* As of August 2023, you can no longer fetch translations with guest token */ /* As of August 2023, you can no longer fetch translations with guest token */