Skip to content

Commit

Permalink
Internationalize
Browse files Browse the repository at this point in the history
  • Loading branch information
r-southworth committed Oct 7, 2024
1 parent b75418d commit 44aca0e
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 36 deletions.
25 changes: 12 additions & 13 deletions src/components/posts/AddFavorite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,9 @@ export const FavoriteButton: Component<Props> = (props) => {
heading={"Save To"}
buttonId={`addFavoriteBtn ${props.id}`}
buttonClass="absolute right-0 top-0 z-30"
// TODO Internationalize
buttonAriaLabel={`Add to Favorites ${props.id}`}
buttonAriaLabel={
t("ariaLabels.addToFavorites") + " " + props.id
}
buttonContent={
<svg
fill="none"
Expand Down Expand Up @@ -321,7 +322,9 @@ export const FavoriteButton: Component<Props> = (props) => {
onclick={(e) => notSignedInAdd(e)}
class="absolute right-0 top-0"
id="addFavoriteBtn"
aria-label={`Add to Favorites ${props.id}`}
aria-label={
t("ariaLabels.addToFavorites") + " " + props.id
}
>
<svg
fill="none"
Expand Down Expand Up @@ -409,8 +412,9 @@ export const FavoriteButton: Component<Props> = (props) => {
lang={lang}
user_id={session()?.user.id || ""}
onListCreated={getFavoriteLists}
//TODO Internationalize
buttonContent={"+ Create New List"}
buttonContent={
"+ " + t("buttons.createList")
}
/>
</div>
</div>
Expand All @@ -419,8 +423,9 @@ export const FavoriteButton: Component<Props> = (props) => {
heading={"Save To"}
buttonId={`addFavoriteBtn ${props.id}`}
buttonClass="absolute right-0 top-0"
// TODO Internationalize
buttonAriaLabel={`Add to Favorites ${props.id}`}
buttonAriaLabel={
t("ariaLabels.addToFavorites") + " " + props.id
}
buttonContent={
<svg
fill="none"
Expand Down Expand Up @@ -456,12 +461,6 @@ export const FavoriteButton: Component<Props> = (props) => {
}
headingLevel={6}
></Modal>
{/* <button
onclick={(e) => removeFromFavorites(e)}
class="absolute right-0 top-0"
id="removeFavoriteBtn"
aria-label="Remove from Favorites"
></button> */}
</Show>
<Show when={added() === true}>
<div class="absolute -right-1 top-24 z-0 w-[190px] rounded-lg bg-background1 py-0.5 text-black shadow-md dark:bg-background1-DM md:w-[194px] lg:w-[240px]">
Expand Down
3 changes: 1 addition & 2 deletions src/components/posts/ViewUserFavorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ export const ViewUserFavorites: Component = () => {
setListName(list_name);
setListNumber(list_id);
} else {
//TODO Internationalize
alert("No posts to display");
alert(t("messages.noPosts"));
setFavoritedItems([]);
setLoading(false);
}
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/UI/English.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ export const English = {
emailNotConfirmed:
"Email not registered. If you previously registered this email address please use the forgot password option below, otherwise please use the sign up option below.",
noFavoriteLists: "No Favorite Lists found",
noFavoriteItems: "Error: No favorite items found",
errorFavoriteFetch: "Error fetching favorites",
generalErrorFavorite: "Error Getting User Favorites",
singleListFavoriteError: "Error getting single list favorites",
favoriteListError: "Error fetching favorite list",
multipleListFavoriteError: "Error handling multiple lists",
},

socialModal: {
Expand Down Expand Up @@ -436,6 +442,7 @@ export const English = {
checkboxGrade: "Checkbox for selecting grade level",
checkbox: "Checkbox",
readMoreAbout: "Read more about ",
addToFavorites: "Add to Favorites",
},

headerData: {
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/UI/French.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,13 @@ export const French = {
checkboxGrade: "Case à cocher pour sélectionner le niveau scolaire",
checkbox: "Case à cocher",
readMoreAbout: "En savoir plus sur",
addToFavorites: "Ajouter aux favoris",
noFavoriteItems: "Aucun favori",
errorFavoriteFetch: "Erreur lors de la recuperation des favoris",
generalErrorFavorite: "Erreur lors de la recuperation des favoris",
singleListFavoriteError: "Erreur lors de l'obtention d'une seule liste de favoris",
favoriteListError: "Erreur lors de l'obtention de la liste de favoris",
multipleListFavoriteError: "Erreur lors de l'analyse de plusieurs listes de favoris",
},

headerData: {
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/UI/Spanish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,13 @@ export const Spanish = {
"Casilla de verificación para seleccionar el nivel de grado",
checkbox: "Caja",
readMoreAbout: "Leer más sobre",
addToFavorites: "Añadir a favoritos",
noFavoriteItems: "No hay elementos favoritos",
errorFavoriteFetch: "Error al obtener favoritos",
generalErrorFavorite: "Error al obtener favoritos",
singleListFavoriteError: "Error al obtener favoritos de lista única",
favoriteListError: "Error al obtener lista de favoritos",
multipleListFavoriteError: "Error al manejar varias listas",
},

headerData: {
Expand Down
7 changes: 7 additions & 0 deletions src/i18n/uiType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ export interface uiObject {
createUserError: string;
emailNotConfirmed: string;
noFavoriteLists: string;
noFavoriteItems: string;
errorFavoriteFetch: string;
generalErrorFavorite: string;
singleListFavoriteError: string;
favoriteListError: string;
multipleListFavoriteError: string;
};

socialModal: {
Expand Down Expand Up @@ -423,6 +429,7 @@ export interface uiObject {
checkboxGrade: string;
checkbox: string;
readMoreAbout: string;
addToFavorites: string;
};

headerData: {
Expand Down
9 changes: 3 additions & 6 deletions src/pages/api/getFavoritesOnList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,14 @@ export const POST: APIRoute = async ({ request, redirect }) => {
console.log(error);
return new Response(
JSON.stringify({
//TODO Internationalize
message: "Error fetching favorites",
message: t("apiErrors.errorFavoriteFetch"),
}),
{ status: 500 }
);
} else if (!data) {
return new Response(
JSON.stringify({
//TODO Internationalize
message: "Error No favorite items found",
message: t("apiErrors.noFavoriteItems"),
}),
{ status: 500 }
);
Expand Down Expand Up @@ -143,8 +141,7 @@ export const POST: APIRoute = async ({ request, redirect }) => {

return new Response(
JSON.stringify({
// TODO Internationalize
message: "Error Getting User Favorites",
message: t("apiErrors.generalErrorFavorite"),
}),
{ status: 500 }
);
Expand Down
9 changes: 3 additions & 6 deletions src/pages/api/getUserFavoriteIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export const POST: APIRoute = async ({ request, redirect }) => {
if (error) {
return new Response(
JSON.stringify({
//TODO Fix error message
message: t("apiErrors.postError"),
message: t("apiErrors.favoriteListError"),
}),
{ status: 500 }
);
Expand All @@ -55,8 +54,7 @@ export const POST: APIRoute = async ({ request, redirect }) => {
if (favoritesProductsError) {
return new Response(
JSON.stringify({
// TODO Internationalize
message: "Error Getting User Favorites from Single List",
message: t("apiErrors.singleListFavoriteError"),
}),
{ status: 500 }
);
Expand All @@ -74,8 +72,7 @@ export const POST: APIRoute = async ({ request, redirect }) => {

return new Response(
JSON.stringify({
// TODO Internationalize
message: "GeneralError Getting User Favorites",
message: t("apiErrors.generalErrorFavorite"),
}),
{ status: 500 }
);
Expand Down
13 changes: 4 additions & 9 deletions src/pages/api/getUserFavorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,15 @@ export const POST: APIRoute = async ({ request, redirect }) => {
} else {
return new Response(
JSON.stringify({
// TODO Internationalize
message: "Error Getting User Favorites from Single List",
message: t("apiErrors.singleListFavoriteError"),
}),
{ status: 500 }
);
}
} catch (error) {
console.error("Error handling single list:", error);
return new Response(
//TODO Internationalize
JSON.stringify({
message: "Error handling single list",
message: t("apiErrors.singleListFavoriteError"),
}),
{ status: 500 }
);
Expand Down Expand Up @@ -202,9 +199,8 @@ export const POST: APIRoute = async ({ request, redirect }) => {
} catch (error) {
console.error("Error handling multiple lists:", error);
return new Response(
//TODO Internationalize
JSON.stringify({
message: "Error handling multiple lists",
message: t("apiErrors.multipleListFavoriteError"),
}),
{ status: 500 }
);
Expand All @@ -213,8 +209,7 @@ export const POST: APIRoute = async ({ request, redirect }) => {

return new Response(
JSON.stringify({
// TODO Internationalize
message: "GeneralError Getting User Favorites",
message: t("apiErrors.generalErrorFavorite"),
}),
{ status: 500 }
);
Expand Down

0 comments on commit 44aca0e

Please sign in to comment.