mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-23 20:54:48 -04:00
(nuxt) replace mechanism in router.options.ts for locale-specific noun pages with route.meta.translatedPaths
now possible because Nuxt scans definePageMeta for pages added by pages:extend
This commit is contained in:
parent
73005d0d2c
commit
86c59d7d82
@ -30,11 +30,6 @@ const routerOptions: RouterOptions = {
|
||||
meta: translatedRoute.meta,
|
||||
};
|
||||
});
|
||||
} else if (typeof route.name === 'string' &&
|
||||
route.name.startsWith('nouns-') && !route.name.startsWith(`nouns-${config.locale}`)) {
|
||||
// workaround for dynamic inclusion of nouns subroutes,
|
||||
// as translatedPaths does not work because definePageMeta is not scanned in pages:extend hook in Nuxt 3
|
||||
return [];
|
||||
}
|
||||
return [route];
|
||||
});
|
||||
|
8
app/utils/translatedPathForSingleLocale.ts
Normal file
8
app/utils/translatedPathForSingleLocale.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import type { Config } from '~~/locale/config.ts';
|
||||
|
||||
export default (config: Config, locale: string, route: string): string[] => {
|
||||
if (config.locale !== locale) {
|
||||
return [];
|
||||
}
|
||||
return [`/${encodeURIComponent(route)}`];
|
||||
};
|
@ -12,6 +12,10 @@ import { neutralGenderNameInjectionKey } from '~~/shared/injectionKeys.ts';
|
||||
import { availableGenders, genders, numeri, symbolsByNumeri } from '~~/shared/nouns.ts';
|
||||
import type { NounDeclension, NounWords } from '~~/shared/nouns.ts';
|
||||
|
||||
definePageMeta({
|
||||
translatedPaths: (config) => translatedPathForSingleLocale(config, 'pl', 'dukatywy'),
|
||||
});
|
||||
|
||||
const dukajDeclension: NounDeclension = {
|
||||
singular: {
|
||||
m: ['u'],
|
||||
|
@ -13,6 +13,10 @@ import { neutralGenderNameInjectionKey } from '~~/shared/injectionKeys.ts';
|
||||
import { availableGenders, genders, numeri, symbolsByNumeri } from '~~/shared/nouns.ts';
|
||||
import type { NounWords, NounDeclension } from '~~/shared/nouns.ts';
|
||||
|
||||
definePageMeta({
|
||||
translatedPaths: (config) => translatedPathForSingleLocale(config, 'pl', 'iksatywy'),
|
||||
});
|
||||
|
||||
const xDeclension: NounDeclension = {
|
||||
singular: {
|
||||
m: ['x'],
|
||||
|
@ -8,6 +8,10 @@ import { removeSuffix } from '~~/shared/helpers.ts';
|
||||
import { numeri, symbolsByNumeri } from '~~/shared/nouns.ts';
|
||||
import type { NounDeclension } from '~~/shared/nouns.ts';
|
||||
|
||||
definePageMeta({
|
||||
translatedPaths: (config) => translatedPathForSingleLocale(config, 'pl', 'neutratywy'),
|
||||
});
|
||||
|
||||
const { $translator: translator } = useNuxtApp();
|
||||
const config = useConfig();
|
||||
|
||||
|
@ -9,6 +9,10 @@ import type { Source } from '~~/shared/classes.ts';
|
||||
import { neutralGenderNameInjectionKey } from '~~/shared/injectionKeys.ts';
|
||||
import { availableGenders } from '~~/shared/nouns.ts';
|
||||
|
||||
definePageMeta({
|
||||
translatedPaths: (config) => translatedPathForSingleLocale(config, 'pl', 'osobatywy'),
|
||||
});
|
||||
|
||||
const { $translator: translator } = useNuxtApp();
|
||||
useSimpleHead({
|
||||
title: translator.translate('nouns.personNouns.header'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user