mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-24 21:51:34 +10:00
feat(i18n): implement localization using LinguiJS
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
/* eslint-disable lingui/text-restrictions */
|
||||
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { openai } from "./client";
|
||||
|
||||
const PROMPT = `You are an AI writing assistant specialized in writing copy for resumes.
|
||||
@ -23,7 +27,7 @@ export const changeTone = async (text: string, mood: Mood) => {
|
||||
});
|
||||
|
||||
if (result.choices.length === 0) {
|
||||
throw new Error("OpenAI did not return any choices for your text.");
|
||||
throw new Error(t`OpenAI did not return any choices for your text.`);
|
||||
}
|
||||
|
||||
return result.choices[0].text;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { t } from "@lingui/macro";
|
||||
import { OpenAI } from "openai";
|
||||
|
||||
import { useOpenAiStore } from "@/client/stores/openai";
|
||||
@ -7,7 +8,7 @@ export const openai = () => {
|
||||
|
||||
if (!apiKey) {
|
||||
throw new Error(
|
||||
"Your OpenAI API Key has not been set yet. Please go to your account settings to enable OpenAI Integration.",
|
||||
t`Your OpenAI API Key has not been set yet. Please go to your account settings to enable OpenAI Integration.`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
/* eslint-disable lingui/text-restrictions */
|
||||
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { openai } from "./client";
|
||||
|
||||
const PROMPT = `You are an AI writing assistant specialized in writing copy for resumes.
|
||||
@ -21,7 +25,7 @@ export const fixGrammar = async (text: string) => {
|
||||
});
|
||||
|
||||
if (result.choices.length === 0) {
|
||||
throw new Error("OpenAI did not return any choices for your text.");
|
||||
throw new Error(t`OpenAI did not return any choices for your text.`);
|
||||
}
|
||||
|
||||
return result.choices[0].text;
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
/* eslint-disable lingui/text-restrictions */
|
||||
|
||||
import { t } from "@lingui/macro";
|
||||
|
||||
import { openai } from "./client";
|
||||
|
||||
const PROMPT = `You are an AI writing assistant specialized in writing copy for resumes.
|
||||
@ -21,7 +25,7 @@ export const improveWriting = async (text: string) => {
|
||||
});
|
||||
|
||||
if (result.choices.length === 0) {
|
||||
throw new Error("OpenAI did not return any choices for your text.");
|
||||
throw new Error(t`OpenAI did not return any choices for your text.`);
|
||||
}
|
||||
|
||||
return result.choices[0].text;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { t } from "@lingui/macro";
|
||||
import { StatisticsDto, UrlDto } from "@reactive-resume/dto";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { AxiosError } from "axios";
|
||||
@ -25,11 +26,6 @@ export const usePrintResume = () => {
|
||||
if (cache === undefined) return cache;
|
||||
return { ...cache, downloads: cache.downloads + 1 } satisfies StatisticsDto;
|
||||
});
|
||||
|
||||
toast({
|
||||
variant: "success",
|
||||
title: "A PDF of your resume has been successfully generated.",
|
||||
});
|
||||
},
|
||||
onError: (error) => {
|
||||
if (error instanceof AxiosError) {
|
||||
@ -37,7 +33,7 @@ export const usePrintResume = () => {
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
title: "An error occurred while trying to generate your resume.",
|
||||
title: t`An error occurred while trying to print your resume.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { t } from "@lingui/macro";
|
||||
import { ResumeDto, UpdateResumeDto } from "@reactive-resume/dto";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { AxiosError, AxiosResponse } from "axios";
|
||||
@ -31,7 +32,7 @@ export const updateResume = async (data: UpdateResumeDto) => {
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
title: "There was an error while updating your resume.",
|
||||
title: t`There was an error while updating your resume.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user