#59 multilingual support - routing, fixes

This commit is contained in:
Andrea Vos 2020-09-28 19:22:36 +02:00
parent 042bf34638
commit fdfb8b9889
17 changed files with 44 additions and 20 deletions

View File

@ -34,7 +34,7 @@
); );
} }
return h('nuxt-link', {props: { to: linkBuffer || '/neutratywy#' + buffer }}, buffer); return h('nuxt-link', {props: { to: linkBuffer || '/' + this.config.nouns.route + '#' + buffer }}, buffer);
} }
const addChild = _ => { const addChild = _ => {
if (!buffer) { if (!buffer) {

View File

@ -5,7 +5,7 @@
<T>links.headerLong</T> <T>links.headerLong</T>
</h2> </h2>
<ul class="list-unstyled"> <ul class="list-unstyled">
<Link v-for="link in config.links.links" :link="link"/> <Link v-for="link in config.links.links" :link="link" :key="link.url"/>
</ul> </ul>
</section> </section>
</template> </template>

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-if="Object.keys(sources).length"> <div v-if="config.sources.enabled && Object.keys(sources).length">
<h2 class="h4"> <h2 class="h4">
<nuxt-link to="/literatura"> <nuxt-link :to="'/' + config.sources.route">
<Icon v="books"/> <Icon v="books"/>
<T>sources.headerLong</T>: <T>sources.headerLong</T>:
</nuxt-link> </nuxt-link>
@ -42,6 +42,7 @@
return { return {
templates: templates, templates: templates,
getTemplate: getTemplate, getTemplate: getTemplate,
glue: ' ' + this.$t('template.or') + ' ',
} }
} }
} }

View File

@ -5,7 +5,7 @@
<T>links.media</T> <T>links.media</T>
</h2> </h2>
<ul class="list-unstyled"> <ul class="list-unstyled">
<Link v-for="link in config.links.media" :link="link"/> <Link v-for="link in config.links.media" :link="link" :key="link.url"/>
</ul> </ul>
</section> </section>
</template> </template>

View File

@ -5,7 +5,7 @@
<T>links.social</T> <T>links.social</T>
</h2> </h2>
<ul class="list-unstyled"> <ul class="list-unstyled">
<Link v-for="link in config.links.socials" :link="link"/> <Link v-for="link in config.links.socials" :link="link" :key="link.url"/>
</ul> </ul>
</section> </section>
</template> </template>

View File

@ -12,7 +12,6 @@ nouns:
enabled: true enabled: true
route: 'neutratywy' route: 'neutratywy'
links: links:
enabled: true enabled: true
route: 'linki' route: 'linki'

View File

@ -89,6 +89,7 @@ sources:
nouns: nouns:
header: 'Neutratywy' header: 'Neutratywy'
headerLong: 'Słownik neutratywów' headerLong: 'Słownik neutratywów'
description: 'Feminatywy feminatywami, ale prawdziwe wyzwanie to tworzenie neutratywów! Przedstawiamy tworzony przez społeczność słownik rzeczowników z wyszczególnieniem ich formy męskiej, żeńskiej i neutralnej.'
intro: intro:
- > - >
Feminatywy feminatywami, ale prawdziwe wyzwanie to tworzenie neutratywów! Feminatywy feminatywami, ale prawdziwe wyzwanie to tworzenie neutratywów!

View File

@ -1,4 +1,5 @@
import translations from './server/translations'; import translations from './server/translations';
import config from './server/config';
const title = translations.title; const title = translations.title;
const description = translations.description; const description = translations.description;
@ -89,4 +90,27 @@ export default {
axios: { axios: {
baseURL: process.env.BASE_URL, baseURL: process.env.BASE_URL,
}, },
router: {
extendRoutes(routes, resolve) {
if (config.sources.enabled) {
routes.push({ path: '/' + config.sources.route, component: resolve(__dirname, 'routes/sources.vue') });
}
if (config.nouns.enabled) {
routes.push({ path: '/' + config.nouns.route, component: resolve(__dirname, 'routes/nouns.vue') });
}
if (config.links.enabled) {
routes.push({ path: '/' + config.links.route, component: resolve(__dirname, 'routes/links.vue') });
}
if (config.contact.enabled) {
routes.push({ path: '/' + config.contact.route, component: resolve(__dirname, 'routes/contact.vue') });
}
routes.push({ path: '/' + config.template.any.route, component: resolve(__dirname, 'routes/any.vue') });
routes.push({ path: '*', component: resolve(__dirname, 'routes/template.vue') });
},
},
} }

View File

@ -166,7 +166,7 @@
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
<p class="h5"> <p class="h5">
<nuxt-link to="/dowolne"><T>template.any.header</T></nuxt-link> <nuxt-link :to="'/' + config.template.any.route"><T>template.any.header</T></nuxt-link>
</p> </p>
<p> <p>
<T>template.any.description</T> <T>template.any.description</T>
@ -271,7 +271,7 @@
</script> </script>
<style lang="scss"> <style lang="scss">
@import "assets/style"; @import "../assets/style";
.form-input { .form-input {
text-align: center; text-align: center;

View File

@ -60,8 +60,8 @@
}, },
head() { head() {
return head({ return head({
title: 'Moje zaimki to: dowolne', title: `${this.$t('template.intro')}: ${this.$t('template.any.short')}`,
banner: 'banner/dowolne.png', banner: `banner/${this.$t('template.any.short')}.png`,
}); });
}, },
methods: { methods: {

View File

@ -266,8 +266,8 @@
}, },
head() { head() {
return head({ return head({
title: 'Słownik neutratywów', title: this.$t('nouns.headerLong'),
description: 'Feminatywy feminatywami, ale prawdziwe wyzwanie to tworzenie neutratywów! Przedstawiamy tworzony przez społeczność słownik rzeczowników z wyszczególnieniem ich formy męskiej, żeńskiej i neutralnej.', description: this.$t('nouns.description'),
banner: 'bannerNouns.png', banner: 'bannerNouns.png',
}); });
}, },

View File

@ -147,7 +147,7 @@
}, },
head() { head() {
return head({ return head({
title: 'Niebinarna polszczyzna w tekstach kultury', title: this.$t('sources.headerLonger'),
}); });
}, },
computed: { computed: {

View File

@ -90,7 +90,7 @@
}, },
head() { head() {
return this.selectedTemplate ? head({ return this.selectedTemplate ? head({
title: 'Moje zaimki to: ' + this.selectedTemplate.name(this.glue), title: `${this.$t('template.intro')}: ${this.selectedTemplate.name(this.glue)}`,
banner: `banner${this.$route.path.replace(/\/$/, '')}.png`, banner: `banner${this.$route.path.replace(/\/$/, '')}.png`,
}) : {}; }) : {};
}, },
@ -101,7 +101,3 @@
}, },
} }
</script> </script>
<style lang="scss">
</style>

View File

@ -55,7 +55,7 @@ export default async function (req, res, next) {
context.fillText(templateNameOptions.join('\n'), width / leftRatio + imageSize / 1.5, height / 2 + (templateNameOptions.length <= 2 ? 72 : 24)) context.fillText(templateNameOptions.join('\n'), width / leftRatio + imageSize / 1.5, height / 2 + (templateNameOptions.length <= 2 ? 72 : 24))
} else { } else {
context.font = 'regular 120pt Quicksand' context.font = 'regular 120pt Quicksand'
context.fillText('Zaimki.pl', width / leftRatio + imageSize / 1.5, height / 2 + 48) context.fillText(translations.title, width / leftRatio + imageSize / 1.5, height / 2 + 48)
} }
res.setHeader('content-type', mime); res.setHeader('content-type', mime);

3
server/config.js Normal file
View File

@ -0,0 +1,3 @@
import Suml from 'suml';
const fs = require('fs');
export default new Suml().parse(fs.readFileSync('./data/config.suml').toString());