Skip to content

Commit

Permalink
fix: translations in production
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLunaHey committed Jan 9, 2025
1 parent d63c333 commit ef6038f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ const BetterContext = ({ context }: { context?: string }) => {
const PostDropdownMenu = ({ post, setTranslatedText }: { post: BSkyPost; setTranslatedText: (text: string) => void }) => {
const handleTranslate = async (event: React.MouseEvent<HTMLDivElement>) => {
event.stopPropagation();
const response = await fetch('http://localhost:8787', {
method: 'POST',
body: JSON.stringify({
q: post.record.text,
source: post.record.langs?.[0] ?? 'auto',
target: navigator.language,
}),
headers: { 'Content-Type': 'application/json' },
});
const response = await fetch(
process.env.NODE_ENV === 'production' ? 'https://translate.akari.blue' : 'http://localhost:8787',
{
method: 'POST',
body: JSON.stringify({
q: post.record.text,
source: post.record.langs?.[0] ?? 'auto',
target: navigator.language,
}),
headers: { 'Content-Type': 'application/json' },
},
);
const json = (await response.json()) as {
alternatives: [];
detectedLanguage: {
Expand Down

0 comments on commit ef6038f

Please sign in to comment.