feat(i18n): implement localization using LinguiJS

This commit is contained in:
Amruth Pillai
2023-11-10 09:07:47 +01:00
parent 13d91411e3
commit 6ad4358d70
108 changed files with 4631 additions and 798 deletions

View File

@ -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;

View File

@ -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.`,
);
}

View File

@ -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;

View File

@ -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;

View File

@ -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,
});
}

View File

@ -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,
});
}