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

fix: remove i18n routing #161

Merged
merged 2 commits into from
Oct 9, 2024
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
5 changes: 1 addition & 4 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
engine-strict=true
# still necessary for nuxt 3
# @see https://github.com/nuxt/nuxt/issues/14146
shamefully-hoist=true
shell-emulator=true
package-manager-strict=false
shell-emulator=true
3 changes: 1 addition & 2 deletions components/app-footer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts" setup>
const t = useTranslations();
const localePath = useLocalePath();
</script>

<template>
Expand All @@ -27,7 +26,7 @@ const localePath = useLocalePath();
<img class="mx-auto" src="/assets/images/logo-fwf.svg" alt="" />
</div>
<div>
<NuxtLink class="text-lg hover:underline" :href="localePath('/imprint')">
<NuxtLink class="text-lg hover:underline" href="/imprint">
{{ t("common.imprint") }}
</NuxtLink>
</div>
Expand Down
30 changes: 5 additions & 25 deletions components/app-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/vue";
import { Menu as MenuIcon, X } from "lucide-vue-next";

import type { NavLink } from "@/lib/types";

const t = useTranslations();
const localePath = useLocalePath();

const switchLocalePath = useSwitchLocalePath();

const links = computed(() => {
return {
home: { href: { path: localePath("/") }, label: t("pages.home.label") },
search: { href: { path: localePath("/search/persons") }, label: t("pages.search.label") },
hierarchy: { href: { path: localePath("/hierarchy") }, label: t("pages.hierarchy.label") },
home: { href: { path: "/" }, label: t("pages.home.label") },
search: { href: { path: "/search/persons" }, label: t("pages.search.label") },
hierarchy: { href: { path: "/hierarchy" }, label: t("pages.hierarchy.label") },
documentation: {
href: { path: localePath("/documentation/project") },
href: { path: "/documentation/project" },
label: t("pages.documentation.label"),
},
} satisfies Record<string, NavLink>;
};
});

defineProps<{ compact?: boolean }>();
Expand All @@ -44,7 +39,6 @@ defineProps<{ compact?: boolean }>();
</li>
</ul>
</nav>
<LocaleSwitch class="select-none" />
</div>
<div class="md:hidden">
<Menu v-slot="{ open, close }" as="div" class="relative z-50 inline-block">
Expand Down Expand Up @@ -73,20 +67,6 @@ defineProps<{ compact?: boolean }>();
{{ link.label }}
</NuxtLink>
</MenuItem>
<MenuItem
v-for="loc in ['de', 'en']"
v-slot="{ active }"
:key="loc"
class="flex justify-around overflow-hidden rounded-bl text-center last:rounded-l-none last:rounded-br last:border-l"
>
<NuxtLink
class="w-full p-4 text-gray-900 transition hover:bg-gray-300"
:class="active && 'bg-gray-400'"
:href="switchLocalePath(loc)"
>
{{ loc.toUpperCase() }}
</NuxtLink>
</MenuItem>
</MenuItems>
</MenuTransition>
</Menu>
Expand Down
7 changes: 1 addition & 6 deletions components/detail-disclosure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const props = defineProps<{
collectionName: string;
}>();

const localePath = useLocalePath();
const t = useTranslations();

const page = ref(0);
Expand Down Expand Up @@ -151,11 +150,7 @@ const currentRels = computed(() => {
<div v-for="hit in currentRels" :key="String(hit)" class="mt-1 border-t pt-1">
<component
:is="linkTo ? NuxtLink : 'div'"
:to="
localePath(
`/detail/${hit?.target?.model.toLowerCase() + 's'}/${hit?.target?.object_id}`,
)
"
:to="`/detail/${hit?.target?.model.toLowerCase() + 's'}/${hit?.target?.object_id}`"
class="grid grid-cols-[1fr_auto] items-center gap-1"
:class="linkTo && 'rounded transition hover:bg-slate-200 active:bg-slate-300 p-1 -ml-1'"
>
Expand Down
4 changes: 1 addition & 3 deletions components/hierarchy-link-button.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script setup lang="ts">
import { Network } from "lucide-vue-next";

const localePath = useLocalePath();

defineProps<{
model: string;
id: string;
Expand All @@ -12,7 +10,7 @@ defineProps<{

<template>
<NuxtLink
:to="{ path: localePath('hierarchy'), query: { id, label, model } }"
:to="{ path: 'hierarchy', query: { id, label, model } }"
class="rounded-full transition hover:bg-slate-200 active:bg-slate-300"
>
<span class="sr-only">Go to Hierarchy view</span>
Expand Down
6 changes: 1 addition & 5 deletions components/hierarchy-wrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { Tree } from "@/lib/tree";

const router = useRouter();

const localePath = useLocalePath();

const props = defineProps<{
data: TreeEntity;
width: number;
Expand Down Expand Up @@ -50,9 +48,7 @@ function updateTree(data: TreeEntity, width: number) {
const options = {
label: (d: Node) => d.data.meta.label,
link: (d: Node) =>
localePath(
`/hierarchy?id=${d.data.meta.pk}&model=${d.data.meta.entity_type}&label=${d.data.meta.label}`,
),
`/hierarchy?id=${d.data.meta.pk}&model=${d.data.meta.entity_type}&label=${d.data.meta.label}`,
width,
r: 7,
fontSize: "medium",
Expand Down
39 changes: 0 additions & 39 deletions components/locale-switch.vue

This file was deleted.

5 changes: 2 additions & 3 deletions components/search-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useRoute } from "vue-router";
import type { AnyEntity } from "@/types/schema";
import { NuxtLink } from "#components";

const localePath = useLocalePath();
const t = useTranslations();
const queryClient = useQueryClient();

Expand Down Expand Up @@ -106,10 +105,10 @@ const {
placeholderData: keepPreviousData,
});

// TODO: finde better solution
// TODO: find better solution
const getDetailLink = (id: string, entity?: string) => {
const type = entity ?? route.path.split("/")[3];
return localePath(`/detail/${type}/${id}`);
return `/detail/${type}/${id}`;
};

onMounted(() => {
Expand Down
9 changes: 3 additions & 6 deletions config/i18n.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import type { LocaleObject } from "vue-i18n-routing";

import type de from "@/locales/de.json";
import type en from "@/locales/en.json";

export const locales = {
de: { code: "de", iso: "de-AT", file: "de.json" },
en: { code: "en", iso: "en-GB", file: "en.json" },
de: { code: "de", language: "de-AT", file: "de.json" },
} satisfies Record<string, LocaleObject>;

export type Locale = keyof typeof locales;

export const defaultLocale: Locale = "en";
export const defaultLocale: Locale = "de";

export type Messages = typeof en;
export type Messages = typeof de;

export interface Schema {
message: Messages;
Expand All @@ -24,5 +22,4 @@ export function isValidLocale(value: string): value is Locale {

export interface Translations extends Record<Locale, Messages> {
de: typeof de;
en: typeof en;
}
4 changes: 2 additions & 2 deletions content/de/landing-page.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ navigation: false # This will not appear with other documentation

Für die **leopoldinische Zeit** umfasst der Personenbestand darüber hinaus erstens zahlreiche Funktionsträger:innen, die am Wiener Hof politisch-administrative Aufgaben und eine ökonomisch-kulturelle Rolle erfüllt haben, zweitens Personen an ausländischen Höfen, die von der Wiener Hofkammer Zahlungen erhalten haben, und drittens in einem verwandtschaftlichen Verhältnis zu Funktionsträger*innen standen.

::index-button{href="de/search/persons"}
::index-button{href="/search/persons"}
DATENBANK
::
[Die Datenbank befindet sich im Aufbau!]{.text-center.text-xl.font-black.text-primary-600.w-full.block}
Expand All @@ -36,7 +36,7 @@ navigation: false # This will not appear with other documentation
## [Datenbank]{.mb-2.text-3xl.text-primary-600.block.font-black}
Die Datenbank beinhaltet die prosopographischen Datensammlungen zweier abgeschlossener FWF-Projekte zum Wiener Hof von Kaiser Leopold I. (1657–1705) bis Leopold II. (1790–1792). Diese Sammlungen werden durch eine **Datenneuaufnahme** für die Hofgesellschaft unter Kaiser Franz II./I. (1792–1835) erweitert. In seiner technischen Umsetzung setzt das Team auf die am ACDH-CH der ÖAW entwickelte virtuelle Forschungsumgebung **Austrian Prosopographical Information System** (APIS).
#left-button
::index-button{href="de/search/persons"}
::index-button{href="/search/persons"}
DATENBANK
::
#right-content
Expand Down
5 changes: 0 additions & 5 deletions content/en/documentation/.Daten-IVZ.md

This file was deleted.

5 changes: 0 additions & 5 deletions content/en/documentation/data.md

This file was deleted.

5 changes: 0 additions & 5 deletions content/en/documentation/materials.md

This file was deleted.

5 changes: 0 additions & 5 deletions content/en/documentation/partners.md

This file was deleted.

5 changes: 0 additions & 5 deletions content/en/documentation/project.md

This file was deleted.

5 changes: 0 additions & 5 deletions content/en/documentation/team.md

This file was deleted.

5 changes: 0 additions & 5 deletions content/en/documentation/technical.md

This file was deleted.

8 changes: 0 additions & 8 deletions content/en/documentation/test.md

This file was deleted.

61 changes: 0 additions & 61 deletions content/en/landing-page.mdc

This file was deleted.

Loading
Loading