Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve internationalisation #192

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions apps/client/components/ListTodo/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TrashIcon } from "@heroicons/react/20/solid";
import { getCookie } from "cookies-next";
import useTranslation from "next-translate/useTranslation";
import { useState } from "react";
import { useQuery } from "react-query";

Expand All @@ -18,6 +19,7 @@ async function getTodos(token) {

export default function ListTodo() {
const token = getCookie("session");
const { t } = useTranslation("peppermint");
const { status, data, refetch } = useQuery("repoData", () => getTodos(token));

const [minValue, setMinValue] = useState(0);
Expand Down Expand Up @@ -50,8 +52,6 @@ export default function ListTodo() {
});
}

console.log(data);

async function deleteTodo(id) {
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/todo/${id}/delete`, {
method: "DELETE",
Expand All @@ -62,12 +62,6 @@ export default function ListTodo() {
}).then(() => refetch());
}

// async function markDone(id) {
// await fetch(`api/v1/todo/mark-done/${id}`, {
// method: "POST",
// }).then(() => refetch());
// }

const handleKeyDown = (event) => {
if (event.key === "Enter") {
onSubmit();
Expand All @@ -83,7 +77,7 @@ export default function ListTodo() {
name="text"
id="text"
className="w-full shadow-sm text-gray-900 bg-gray-100 rounded-lg font-semibold border-none focus:outline-none "
placeholder="Enter todo here..."
placeholder={t("enter_todo")}
onChange={(e) => {
setText(e.target.value);
}}
Expand Down
6 changes: 3 additions & 3 deletions apps/client/i18n.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
locales: ['en', 'de', 'se'],
defaultLocale: 'en',
locales: ["en", "da", "de", "es", "fr", "no", "pt", "se", "tl"],
defaultLocale: "en",
pages: {
'*': ['peppermint'],
"*": ["peppermint"],
},
localeDetection: false,
};
18 changes: 9 additions & 9 deletions apps/client/layouts/newLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function NewLayout({ children }: any) {

const navigation = [
{
name: "Create a ticket",
name: t("create_ticket"),
href: `/${locale}/new`,
icon: PlusIcon,
current: location.pathname === "/new" ? true : false,
Expand Down Expand Up @@ -88,7 +88,6 @@ export default function NewLayout({ children }: any) {
}

async function logout() {
// clears session on server
const res = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/user/${user.id}/logout`,
{
Expand All @@ -100,7 +99,6 @@ export default function NewLayout({ children }: any) {
}
).then((res) => res.json());

// delete session cookie
if (res.success) {
deleteCookie("session");
location.reload();
Expand All @@ -111,9 +109,9 @@ export default function NewLayout({ children }: any) {
getQueues();
}, [user]);

useEffect(() => {
// location.push(`${locale}/${location.pathname}`);
}, []);
// useEffect(() => {
// location.push(`${locale}/${location.pathname}`);
// }, [user, location]);

const handleKeyPress = useCallback((event: any) => {
if (
Expand Down Expand Up @@ -458,7 +456,9 @@ export default function NewLayout({ children }: any) {
className="h-6 w-6 shrink-0 text-white group-hover:text-white"
aria-hidden="true"
/>
<span className="whitespace-nowrap">Admin Settings</span>
<span className="whitespace-nowrap">
{t("admin_settings")}
</span>
<div className="flex w-full justify-end float-right">
<span className="flex h-6 w-6 shrink-0 items-center justify-center rounded-lg border border-gray-700 bg-gray-800 text-[0.625rem] font-medium text-gray-400 group-hover:text-white">
a
Expand Down Expand Up @@ -557,7 +557,7 @@ export default function NewLayout({ children }: any) {
"block px-3 text-sm font-bold h-full p-2 w-full rounded-md text-gray-900"
)}
>
Profile
{t("profile")}
</Link>
)}
</Menu.Item>
Expand All @@ -572,7 +572,7 @@ export default function NewLayout({ children }: any) {
"block px-3 text-left text-sm font-bold h-full p-2 w-full rounded-md text-gray-900"
)}
>
Sign Out
{t("logout")}
</button>
)}
</Menu.Item>
Expand Down
9 changes: 6 additions & 3 deletions apps/client/layouts/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { useState } from "react";

import useTranslation from "next-translate/useTranslation";
import Link from "next/link";
import { useRouter } from "next/router";

export default function Settings({ children }) {
const router = useRouter();

const { t } = useTranslation("peppermint");

const linkStyles = {
active:
"w-full bg-teal-50 border-teal-500 text-teal-700 hover:bg-teal-50 hover:text-teal-700 group border-l-4 px-3 py-2 flex items-center text-sm font-medium",
Expand Down Expand Up @@ -46,7 +49,7 @@ export default function Settings({ children }) {
d="M5.121 17.804A13.937 13.937 0 0112 16c2.5 0 4.847.655 6.879 1.804M15 10a3 3 0 11-6 0 3 3 0 016 0zm6 2a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
<span className="truncate">Profile</span>
<span className="truncate">{t("profile")}</span>
</Link>

<Link
Expand All @@ -72,7 +75,7 @@ export default function Settings({ children }) {
d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
/>
</svg>
<span className="truncate">Notifications</span>
<span className="truncate">{t("notifications")}</span>
</Link>

<Link
Expand All @@ -98,7 +101,7 @@ export default function Settings({ children }) {
d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"
/>
</svg>
<span className="truncate">Password</span>
<span className="truncate">{t("reset_password")}</span>
</Link>
</nav>
</aside>
Expand Down
84 changes: 84 additions & 0 deletions apps/client/locales/da/peppermint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"hello_good": "Godt",
"hello_morning": "Morgen",
"hello_afternoon": "Eftermiddag",
"sl_dashboard": "Instrumentbræt",
"sl_tickets": "Billetter",
"sl_history": "Historie",
"sl_notebook": "Personlig notesbog",
"sl_users": "Brugere",
"sl_clients": "Kunder",
"sl_settings": "Indstillinger",
"open_tickets": "Åbne billetter",
"completed_tickets": "Afsluttede billetter",
"account_status": "Kontostatus",
"todo_list": "Opgaveliste",
"personal_files": "Personlige filer",
"create_ticket": "Opret billet",
"ticket_new": "Ny billet",
"ticket_name_here": "Navn",
"ticket_email_here": "Email",
"ticket_details": "Titel",
"ticket_select_client": "Vælg en klient",
"ticket_select_eng": "Vælg en ingeniør",
"ticket_extra_details": "Indtast ekstra detaljer her.... understøtter markdown",
"cancel": "Annuller",
"create": "Opret",
"low": "Lav",
"normal": "Normal",
"high": "Høj",
"edit-btn": "Rediger",
"reset_password": "Nulstil adgangskode",
"internal_users": "Interne brugere",
"clients": "Kunder",
"new_user": "Ny bruger",
"new_client": "Ny klient",
"previous": "Forrige",
"next": "Næste",
"show": "Vis",
"name": "Navn",
"email": "Email",
"settings": "Indstillinger",
"webhooks": "Webhooks",
"version": "Version",
"v_profile": "Se profil",
"reminders": "Påmindelser",
"title": "Titel",
"priority": "Prioritet",
"status": "Status",
"created": "Oprettet",
"assigned_to": "Tildelt til",
"enter_todo": "Indtast opgave",
"notebooks": "Notesbøger",
"notebooks_description": "Dette er en personlig notesbog, du kan bruge den til at gemme noter, links, kodeeksempler osv.",
"create_notebook": "Opret notesbog",
"open": "Åben",
"assigned_to_me": "Tildelt til mig",
"unassigned": "Ikke tildelt",
"closed": "Lukket",
"description": "Beskrivelse",
"comments": "Kommentarer",
"leave_comment": "Efterlad en kommentar",
"close_issue": "Luk problem",
"comment": "Kommentar",
"save": "Gem",
"labels": "Mærker",
"created_at": "Oprettet den",
"updated_at": "Opdateret den",
"hide_ticket": "Skjul billet",
"show_ticket": "Vis globalt",
"open_issue": "Åbn problem",
"closed_issue": "Lukket problem",
"recent_tickets": "Seneste billetter",
"notebook_title": "Notesbogstitel",
"admin_settings": "Administratorindstillinger",
"profile": "Profil",
"logout": "Log ud",
"unassigned_tickets": "Ikke tildelte billetter",
"profile_desc": "Disse oplysninger vil blive vist offentligt, så vær forsigtig med, hvad du deler.",
"language": "Sprog",
"notifications": "Notifikationer",
"save_and_reload": "Gem og genindlæs"

}

102 changes: 69 additions & 33 deletions apps/client/locales/de/peppermint.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,82 @@
{
"hello_good": "Wunderschönen",
"hello_good": "Gut",
"hello_morning": "Morgen",
"hello_afternoon": "Tag",
"Account status": "Kontostatus",
"hello_afternoon": "Nachmittag",
"sl_dashboard": "Armaturenbrett",
"sl_tickets": "Eintrittskarten",
"sl_tickets": "Tickets",
"sl_history": "Verlauf",
"sl_notebook": "Persönliche Notizen",
"sl_notebook": "Persönliches Notizbuch",
"sl_users": "Benutzer",
"sl_clients": "Kunden",
"sl_settings": "Einstellungen",
"open_tickets": "Offene Tickets",
"completed_tickets": "Geschlossene Tickets",
"account_status": "Account status",
"todo_list": "Todo Liste",
"completed_tickets": "Abgeschlossene Tickets",
"account_status": "Kontostatus",
"todo_list": "Aufgabenliste",
"personal_files": "Persönliche Dateien",
"create_ticket": "Ticket erstellen",
"ticket_new": "Neues Ticket",
"ticket_name_here": "Namen hier eingeben",
"ticket_email_here": "E-Mail hier eingeben",
"ticket_details": "Tickettitel",
"ticket_select_client": "Bitte Auftraggeber auswählen",
"ticket_select_eng": "Bitte Ingenieur auswählen",
"ticket_extra_details": "Geben Sie hier zusätzliche Details ein.... Markdown wird unterstützt",
"ticket_name_here": "Name",
"ticket_email_here": "E-Mail",
"ticket_details": "Titel",
"ticket_select_client": "Kunde auswählen",
"ticket_select_eng": "Techniker auswählen",
"ticket_extra_details": "Weitere Details hier eingeben... Markdown wird unterstützt",
"cancel": "Abbrechen",
"create": "schaffen",
"low": "niedrig",
"normal": "normal",
"high": "hoch",
"edit": "",
"reset_password": "",
"internal_users": "",
"clients": "",
"new_user": "",
"new_client": "",
"previous": "",
"next": "",
"show": "",
"name": "",
"email": "",
"settings": "",
"webhooks": "",
"version": "",
"v_profile": ""
"create": "Erstellen",
"low": "Niedrig",
"normal": "Normal",
"high": "Hoch",
"edit-btn": "Bearbeiten",
"reset_password": "Passwort zurücksetzen",
"internal_users": "Interne Benutzer",
"clients": "Kunden",
"new_user": "Neuer Benutzer",
"new_client": "Neuer Kunde",
"previous": "Vorherige",
"next": "Nächste",
"show": "Anzeigen",
"name": "Name",
"email": "E-Mail",
"settings": "Einstellungen",
"webhooks": "Webhooks",
"version": "Version",
"v_profile": "Profil anzeigen",
"reminders": "Erinnerungen",
"title": "Titel",
"priority": "Priorität",
"status": "Status",
"created": "Erstellt",
"assigned_to": "Zugewiesen an",
"enter_todo": "Aufgabe eingeben",
"notebooks": "Notizbücher",
"notebooks_description": "Dies ist ein persönliches Notizbuch. Hier können Sie Notizen, Links, Code-Snippets usw. speichern.",
"create_notebook": "Notizbuch erstellen",
"open": "Öffnen",
"assigned_to_me": "Mir zugewiesen",
"unassigned": "Nicht zugewiesen",
"closed": "Geschlossen",
"description": "Beschreibung",
"comments": "Kommentare",
"leave_comment": "Kommentar hinterlassen",
"close_issue": "Problem schließen",
"comment": "Kommentar",
"save": "Speichern",
"labels": "Labels",
"created_at": "Erstellt am",
"updated_at": "Aktualisiert am",
"hide_ticket": "Ticket ausblenden",
"show_ticket": "Global anzeigen",
"open_issue": "Problem öffnen",
"closed_issue": "Geschlossenes Problem",
"recent_tickets": "Aktuelle Tickets",
"notebook_title": "Notizbuchtitel",
"admin_settings": "Admin-Einstellungen",
"profile": "Profil",
"logout": "Abmelden",
"unassigned_tickets": "Nicht zugewiesene Tickets",
"profile_desc": "Diese Informationen werden öffentlich angezeigt, also achten Sie darauf, was Sie teilen.",
"language": "Sprache",
"notifications": "Benachrichtigungen",
"save_and_reload": "Speichern und neu laden"
}
Loading
Loading