#95 [refactor] rename "template" to "pronoun"

This commit is contained in:
Avris 2020-11-11 00:47:44 +01:00
parent 629a12698e
commit e3cd8956d6
48 changed files with 433 additions and 417 deletions

View File

@ -1,11 +1,11 @@
<template> <template>
<span> <span>
<span v-for="part in example[(example.isHonorific ? template.isPluralHonorific(counter) : template.isPlural(counter)) ? 'pluralParts' : 'singularParts']"> <span v-for="part in example[(example.isHonorific ? pronoun.isPluralHonorific(counter) : pronoun.isPlural(counter)) ? 'pluralParts' : 'singularParts']">
<strong v-if="part.variable">{{template.getMorpheme(part.str, counter)}}</strong> <strong v-if="part.variable">{{pronoun.getMorpheme(part.str, counter)}}</strong>
<span v-else>{{part.str}}</span> <span v-else>{{part.str}}</span>
</span> </span>
<small v-if="link"> <small v-if="link">
(<nuxt-link :to="'/' + template.canonicalName">{{ template.canonicalName }}</nuxt-link>) (<nuxt-link :to="'/' + pronoun.canonicalName">{{ pronoun.canonicalName }}</nuxt-link>)
</small> </small>
</span> </span>
</template> </template>
@ -14,7 +14,7 @@
export default { export default {
props: { props: {
example: { required: true }, example: { required: true },
template: { required: true }, pronoun: { required: true },
counter: { default: 0 }, counter: { default: 0 },
link: { type: Boolean }, link: { type: Boolean },
} }

View File

@ -62,7 +62,7 @@
icon: 'home', icon: 'home',
text: this.$t('home.header'), text: this.$t('home.header'),
textLong: this.$t('home.headerLong'), textLong: this.$t('home.headerLong'),
extra: ['all', this.config.template.any.route], extra: ['all', this.config.pronouns.any.route],
}); });
if (this.config.sources.enabled) { if (this.config.sources.enabled) {

View File

@ -11,12 +11,12 @@
<h3 class="h5"> <h3 class="h5">
<nuxt-link :to="'/' + option"> <nuxt-link :to="'/' + option">
<span v-if="option.includes('&')"> <span v-if="option.includes('&')">
<T>template.alt.header</T> <T>pronouns.alt.header</T>
<small>({{ option.replace(/&/g, glue) }})</small> <small>({{ option.replace(/&/g, glue) }})</small>
</span> </span>
<span v-else> <span v-else>
{{ getTemplate(templates, option).description }} {{ getPronoun(pronouns, option).description }}
<small>({{ getTemplate(templates, option).name(glue) }})</small> <small>({{ getPronoun(pronouns, option).name(glue) }})</small>
</span> </span>
</nuxt-link> </nuxt-link>
</h3> </h3>
@ -27,8 +27,8 @@
</template> </template>
<script> <script>
import { templates } from "../src/data"; import { pronouns } from "../src/data";
import { getTemplate } from "../src/buildTemplate"; import { getPronoun } from "../src/buildPronoun";
export default { export default {
props: { props: {
@ -36,9 +36,9 @@
}, },
data() { data() {
return { return {
templates: templates, pronouns,
getTemplate: getTemplate, getPronoun: getPronoun,
glue: ' ' + this.$t('template.or') + ' ', glue: ' ' + this.$t('pronouns.or') + ' ',
} }
} }
} }

View File

@ -1,7 +1,7 @@
<template> <template>
<span class="badge badge-secondary toggle-hover"> <span class="badge badge-secondary toggle-hover">
<Icon v="book-open"/> <Icon v="book-open"/>
<span class="togglable"><T>template.normative</T></span> <span class="togglable"><T>pronouns.normative</T></span>
</span> </span>
</template> </template>

View File

@ -37,7 +37,7 @@
required maxlength="255"/> required maxlength="255"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="templates"><T>sources.submit.extra</T></label> <label for="pronouns"><T>sources.submit.extra</T></label>
<input type="text" id="extra" class="form-control" v-model="form.extra" <input type="text" id="extra" class="form-control" v-model="form.extra"
maxlength="255"/> maxlength="255"/>
</div> </div>
@ -53,8 +53,8 @@
</ListInput> </ListInput>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="templates" class="required"><T>sources.submit.templates</T></label> <label for="pronouns" class="required"><T>sources.submit.pronouns</T></label>
<input type="text" id="templates" class="form-control" v-model="form.templates" <input type="text" id="pronouns" class="form-control" v-model="form.pronouns"
required maxlength="255"/> required maxlength="255"/>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -82,7 +82,7 @@
data() { data() {
return { return {
form: { form: {
templates: '', pronouns: '',
type: '', type: '',
author: '', author: '',
title: '', title: '',
@ -105,7 +105,7 @@
this.submitting = false; this.submitting = false;
this.afterSubmit = true; this.afterSubmit = true;
this.form = { this.form = {
templates: '', pronouns: '',
type: '', type: '',
author: '', author: '',
title: '', title: '',

View File

@ -2,7 +2,7 @@ locale: '_'
header: false header: false
template: pronouns:
enabled: false enabled: false
sources: sources:

View File

@ -5,7 +5,7 @@
<script> <script>
export default { export default {
props: { props: {
selectedTemplate: { required: true }, selectedPronoun: { required: true },
counter: { required: true }, counter: { required: true },
} }
} }

View File

@ -1,4 +1,4 @@
name templates description name pronouns description
Normative forms he,she Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć. Normative forms he,she Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć.
Neutral forms they Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników. Neutral forms they Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników.
Formy wymienne he&she,he&they,she&they Wiele osób niebinarnych używa zamiennie więcej niż jednej formy (np. męskich i żeńskich albo żeńskich i nijakich) i można się do nich zwracać w dowolnej z nich. Formy wymienne he&she,he&they,she&they Wiele osób niebinarnych używa zamiennie więcej niż jednej formy (np. męskich i żeńskich albo żeńskich i nijakich) i można się do nich zwracać w dowolnej z nich.
Can't render this file because it contains an unexpected character in line 3 and column 240.

View File

@ -1,7 +1,7 @@
title: 'Pronouns.page' title: 'Pronouns.page'
description: 'Usage examples of personal pronouns and gender neutral language.' description: 'Usage examples of personal pronouns and gender neutral language.'
template: pronouns:
or: 'or' or: 'or'
notFound: notFound:

View File

@ -2,7 +2,7 @@ locale: 'en'
header: true header: true
template: pronouns:
enabled: true enabled: true
default: 'he' default: 'he'
any: any:
@ -112,3 +112,16 @@ profile:
- ['partner', 'boyfriend', 'girlfriend', 'joyfriend', 'husband', 'wife', 'kissmate'] - ['partner', 'boyfriend', 'girlfriend', 'joyfriend', 'husband', 'wife', 'kissmate']
redirects: [] redirects: []
api:
examples:
pronouns_all: ['/api/pronouns']
pronouns_one:
- '/api/pronouns/she/her'
- '/api/pronouns/she/her?examples[]=Did%20you%20ask%20%7Bpronoun_object%7D%20to%20join%20us%3F'
sources_all: ['/api/sources']
sources_one: ['/api/sources/queerZaimki'] # TODO
nouns_all: ['/api/nouns']
nouns_search: ['/api/nouns/search/person']

View File

@ -18,11 +18,11 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{{ selectedTemplate.getMorpheme('pronoun_subject', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('pronoun_subject', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_object', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('pronoun_object', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('possessive_determiner', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('possessive_determiner', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('possessive_pronoun', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('possessive_pronoun', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('reflexive', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('reflexive', counter) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -33,7 +33,7 @@
<script> <script>
export default { export default {
props: { props: {
selectedTemplate: { required: true }, selectedPronoun: { required: true },
counter: { required: true }, counter: { required: true },
} }
} }

View File

@ -1,4 +1,4 @@
name templates description name pronouns description
Normative forms he,she Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć. Normative forms he,she Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć.
Neutral forms they Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników. Neutral forms they Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników.
Formy wymienne he&she,he&they,she&they Wiele osób niebinarnych używa zamiennie więcej niż jednej formy (np. męskich i żeńskich albo żeńskich i nijakich) i można się do nich zwracać w dowolnej z nich. Formy wymienne he&she,he&they,she&they Wiele osób niebinarnych używa zamiennie więcej niż jednej formy (np. męskich i żeńskich albo żeńskich i nijakich) i można się do nich zwracać w dowolnej z nich.
Can't render this file because it contains an unexpected character in line 3 and column 240.

View File

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -9,7 +9,7 @@ home:
about: about:
- > - >
TODO TODO
templates: 'Propozycje form' pronouns: 'Propozycje form'
generator: generator:
header: 'Generator form' header: 'Generator form'
description: > description: >
@ -21,7 +21,7 @@ home:
alt: 'Możesz tu również wpisać formy wymienne w każdym polu z osobna, np. <code>jego&jej</code> = „jego” lub „jej”.' alt: 'Możesz tu również wpisać formy wymienne w każdym polu z osobna, np. <code>jego&jej</code> = „jego” lub „jej”.'
whatisit: 'O co chodzi w tej stronie?' whatisit: 'O co chodzi w tej stronie?'
template: pronouns:
examples: 'Example usage in sentences' examples: 'Example usage in sentences'
plural: 'Plural' plural: 'Plural'
intro: 'My pronouns are' intro: 'My pronouns are'
@ -389,3 +389,8 @@ terms:
header: 'Terms of Service' header: 'Terms of Service'
lastUpdate: 'Last Updated' lastUpdate: 'Last Updated'
consent: 'By registering you''re accepting the' consent: 'By registering you''re accepting the'
api:
header: 'Public API'
example: 'Example'
query: 'Query string parameters'

View File

@ -2,7 +2,7 @@ locale: 'pl'
header: true header: true
template: pronouns:
enabled: true enabled: true
default: 'on' default: 'on'
any: any:
@ -145,7 +145,7 @@ people:
english: english:
enabled: false enabled: false
route: 'english' route: 'english'
templateGroups: pronounGroups:
- -
name: 'Normative forms' name: 'Normative forms'
description: description:

View File

@ -0,0 +1,72 @@
<template>
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th></th>
<th><em>I received</em></th>
<th><em>You played</em></th>
<th><em>Somebody told them they are pretty</em></th>
</tr>
</thead>
<tbody>
<tr v-for="(description, pronoun) in t">
<th>
<nuxt-link :to="'/' + pronouns[pronoun].canonicalName">
{{pronouns[pronoun].name()}}
<br v-if="description"/>
<small>{{description}}</small>
</nuxt-link>
</th>
<td v-if="pronouns[pronoun].plural">
Dosta<strong>{{pronouns[pronoun].morphemes.verb_end_inter}}śmy</strong>
</td>
<td v-else>
Dostał<strong>{{pronouns[pronoun].morphemes.verb_middle_inter}}m</strong>
</td>
<td v-if="pronouns[pronoun].plural">
Gra<strong>{{pronouns[pronoun].morphemes.verb_end_inter}}ście</strong>
</td>
<td v-else>
Grał<strong>{{pronouns[pronoun].morphemes.verb_middle_inter}}ś</strong>
</td>
<td v-if="pronouns[pronoun].plural">
Powiedzieli <strong>{{pronouns[pronoun].morphemes.pronoun_d}}</strong>,
że [<strong>{{pronouns[pronoun].morphemes.pronoun_n}}</strong>]
ładn<strong>{{pronouns[pronoun].morphemes.adjective_n}}</strong>
</td>
<td v-else>
Powiedzieli <strong>{{pronouns[pronoun].morphemes.pronoun_d}}</strong>,
że [<strong>{{pronouns[pronoun].morphemes.pronoun_n}}</strong>]
jest ładn<strong>{{pronouns[pronoun].morphemes.adjective_n}}</strong>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
import { pronouns } from "../../src/data";
import { getPronoun } from "../../src/buildPronoun";
import { buildDict } from "../../src/helpers";
export default {
props: {
t: { required: true },
},
data() {
const that = this;
return {
pronouns: buildDict(function* () {
for (let name in that.t) {
if (!that.t.hasOwnProperty(name)) {
continue;
}
yield [name, getPronoun(pronouns, name)];
}
}),
};
},
}
</script>

View File

@ -19,12 +19,13 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{{ selectedTemplate.getMorpheme('pronoun_n', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('pronoun_n', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_g', counter) }} / {{ selectedTemplate.getMorpheme('pronoun_g_acc', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('pronoun_g', counter) }} / {{
<td>{{ selectedTemplate.getMorpheme('pronoun_d', counter) }}</td> selectedPronoun.getMorpheme('pronoun_g_acc', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_a', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('pronoun_d', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_i', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('pronoun_a', counter) }}</td>
<td>{{ selectedTemplate.getMorpheme('pronoun_l', counter) }}</td> <td>{{ selectedPronoun.getMorpheme('pronoun_i', counter) }}</td>
<td>{{ selectedPronoun.getMorpheme('pronoun_l', counter) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -42,10 +43,10 @@
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>-{{ selectedTemplate.getMorpheme('verb_middle_inter', counter) }}{{ selectedTemplate.isPlural(counter) ? 'śmy' : 'm'}}</td> <td>-{{ selectedPronoun.getMorpheme('verb_middle_inter', counter) }}{{selectedPronoun.isPlural(counter) ? 'śmy' : 'm'}}</td>
<td>-{{ selectedTemplate.getMorpheme('verb_middle_inter', counter) }}{{ selectedTemplate.isPlural(counter) ? 'ście' : 'ś'}}</td> <td>-{{ selectedPronoun.getMorpheme('verb_middle_inter', counter) }}{{selectedPronoun.isPlural(counter) ? 'ście' : 'ś'}}</td>
<td>-{{ selectedTemplate.getMorpheme('verb_end_about', counter) }}</td> <td>-{{ selectedPronoun.getMorpheme('verb_end_about', counter) }}</td>
<td>-{{ selectedTemplate.getMorpheme('adjective_n', counter) }}</td> <td>-{{ selectedPronoun.getMorpheme('adjective_n', counter) }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -56,7 +57,7 @@
<script> <script>
export default { export default {
props: { props: {
selectedTemplate: { required: true }, selectedPronoun: { required: true },
counter: { required: true }, counter: { required: true },
} }
} }

View File

@ -1,4 +1,4 @@
name templates description name pronouns description
Formy normatywne on,ona Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć. Formy normatywne on,ona Wiele osób niebinarnych, ze względu na ograniczenia polszczyzny lub po prostu dlatego, że tak im bardziej pasuje, decyduje się zwyczajnie używać form „on” lub „ona” czy to zgodnie z ich płcią przypisaną przy urodzeniu, czy przeciwnie. Nie ujmuje to im niebinarności! Zaimki ≠ płeć.
Formy nijakie ono/jego,ono/jej,ono/jejgo,ono/jeno,ono/jenu,vono Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią infantylnie, dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników. Formy nijakie ono/jego,ono/jej,ono/jejgo,ono/jeno,ono/jenu,vono Ze względu na użycie już istniejącego w polszczyźnie rodzaju nijakiego jest to jedna z najczęściej używanych oraz łatwych do zrozumienia opcji. Formy takie jak „zrobiłom” czy „poszłoś”, choć <a href="http://www.rjp.pan.pl/index.php?option=com_content&view=article&id=317:byom-byo&catid=44&Itemid=208" target="_blank" rel="noopener">poprawne gramatycznie</a>, dopiero od niedawna są szerzej używane, i dla wielu brzmią infantylnie, dehumanizująco (póki nie zostaną znormalizowane). W odmianie wiele form nijakich jest tożsamych z męskimi, dlatego niektóre osoby wolą używać zmodyfikowanych wariantów wykorzystujących inne zaimki przy zachowaniu nijakiej koniugacji czasowników.
Dukaizmy onu,onu/jejo,ne Neologiczne formy stworzone oryginalnie dla <a href="https://pl.wikipedia.org/wiki/Perfekcyjna_niedoskona%C5%82o%C5%9B%C4%87" target="_blank" rel="noopener">powieści fantastycznych</a>. Choć system dukaizmów jest spójny i analogiczny do form normatywnych, to dla nieznaznajomionych brzmi obco. Jest to jedna z najczęściej wybieranych opcji. Niektóre osoby używają też zmodyfikowanych wariantów wykorzystujących inne zaimki w części przypadków przy zachowaniu dukajowskiej koniugacji czasowników. Dukaizmy onu,onu/jejo,ne Neologiczne formy stworzone oryginalnie dla <a href="https://pl.wikipedia.org/wiki/Perfekcyjna_niedoskona%C5%82o%C5%9B%C4%87" target="_blank" rel="noopener">powieści fantastycznych</a>. Choć system dukaizmów jest spójny i analogiczny do form normatywnych, to dla nieznaznajomionych brzmi obco. Jest to jedna z najczęściej wybieranych opcji. Niektóre osoby używają też zmodyfikowanych wariantów wykorzystujących inne zaimki w części przypadków przy zachowaniu dukajowskiej koniugacji czasowników.
Can't render this file because it contains an unexpected character in line 3 and column 285.

View File

Can't render this file because it has a wrong number of fields in line 10.

View File

@ -1,72 +0,0 @@
<template>
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th></th>
<th><em>I received</em></th>
<th><em>You played</em></th>
<th><em>Somebody told them they are pretty</em></th>
</tr>
</thead>
<tbody>
<tr v-for="(description, template) in t">
<th>
<nuxt-link :to="'/' + templates[template].canonicalName">
{{templates[template].name()}}
<br v-if="description"/>
<small>{{description}}</small>
</nuxt-link>
</th>
<td v-if="templates[template].plural">
Dosta<strong>{{templates[template].morphemes.verb_end_inter}}śmy</strong>
</td>
<td v-else>
Dostał<strong>{{templates[template].morphemes.verb_middle_inter}}m</strong>
</td>
<td v-if="templates[template].plural">
Gra<strong>{{templates[template].morphemes.verb_end_inter}}ście</strong>
</td>
<td v-else>
Grał<strong>{{templates[template].morphemes.verb_middle_inter}}ś</strong>
</td>
<td v-if="templates[template].plural">
Powiedzieli <strong>{{templates[template].morphemes.pronoun_d}}</strong>,
że [<strong>{{templates[template].morphemes.pronoun_n}}</strong>]
ładn<strong>{{templates[template].morphemes.adjective_n}}</strong>
</td>
<td v-else>
Powiedzieli <strong>{{templates[template].morphemes.pronoun_d}}</strong>,
że [<strong>{{templates[template].morphemes.pronoun_n}}</strong>]
jest ładn<strong>{{templates[template].morphemes.adjective_n}}</strong>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
import { templates } from "../../src/data";
import { getTemplate } from "../../src/buildTemplate";
import { buildDict } from "../../src/helpers";
export default {
props: {
t: { required: true },
},
data() {
const that = this;
return {
templates: buildDict(function* () {
for (let name in that.t) {
if (!that.t.hasOwnProperty(name)) {
continue;
}
yield [name, getTemplate(templates, name)];
}
}),
};
},
}
</script>

View File

@ -40,7 +40,7 @@ home:
„{/oni=dzwonili} z gazowni”, „{/oni=dzwonili} z gazowni”,
„będę robić”, itp. „będę robić”, itp.
Tutaj idziemy po prostu o krok dalej. Tutaj idziemy po prostu o krok dalej.
templates: 'Propozycje form' pronouns: 'Propozycje form'
generator: generator:
header: 'Generator form' header: 'Generator form'
description: > description: >
@ -52,7 +52,7 @@ home:
alt: 'Możesz tu również wpisać formy wymienne w każdym polu z osobna, np. <code>jego&jej</code> = „jego” lub „jej”.' alt: 'Możesz tu również wpisać formy wymienne w każdym polu z osobna, np. <code>jego&jej</code> = „jego” lub „jej”.'
whatisit: 'O co chodzi w tej stronie?' whatisit: 'O co chodzi w tej stronie?'
template: pronouns:
examples: 'Przykłady użycia w zdaniu' examples: 'Przykłady użycia w zdaniu'
plural: 'Liczba mnoga' plural: 'Liczba mnoga'
intro: 'Moje zaimki to' intro: 'Moje zaimki to'
@ -89,7 +89,7 @@ sources:
submit: submit:
header: 'Zgłoś przykład do dodania' header: 'Zgłoś przykład do dodania'
action: 'Zgłoś' action: 'Zgłoś'
templates: 'Które zaimki/formy są użyte?' pronouns: 'Które zaimki/formy są użyte?'
type: 'Rodzaj źródła kultury' type: 'Rodzaj źródła kultury'
author: 'Autor' author: 'Autor'
title: 'Tytuł' title: 'Tytuł'

View File

@ -156,13 +156,13 @@ export default {
} }
} }
if (config.template.enabled) { if (config.pronouns.enabled) {
routes.push({ path: '/' + config.template.any.route, component: resolve(__dirname, 'routes/any.vue') }); routes.push({ path: '/' + config.pronouns.any.route, component: resolve(__dirname, 'routes/any.vue') });
} }
routes.push({ path: '/api', component: resolve(__dirname, 'routes/api.vue') }); routes.push({ path: '/api', component: resolve(__dirname, 'routes/api.vue') });
routes.push({ name: 'all', path: '*', component: resolve(__dirname, 'routes/template.vue') }); routes.push({ name: 'all', path: '*', component: resolve(__dirname, 'routes/pronoun.vue') });
}, },
}, },
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<Homepage v-if="config.template.enabled"/> <Homepage v-if="config.pronouns.enabled"/>
<Select v-else/> <Select v-else/>
</template> </template>

View File

@ -2,18 +2,18 @@
<div class="container"> <div class="container">
<h2> <h2>
<Icon v="tag"/> <Icon v="tag"/>
<T>template.intro</T>: <T>pronouns.intro</T>:
</h2> </h2>
<section> <section>
<div class="alert alert-primary"> <div class="alert alert-primary">
<h2 class="text-center mb-0"> <h2 class="text-center mb-0">
<strong><T>template.any.short</T></strong> <strong><T>pronouns.any.short</T></strong>
</h2> </h2>
<p class="h6 small text-center mb-0 mt-2"> <p class="h6 small text-center mb-0 mt-2">
<em> <em>
<T>template.any.description</T> <T>pronouns.any.description</T>
(<T>template.any.options</T>) (<T>pronouns.any.options</T>)
</em> </em>
</p> </p>
</div> </div>
@ -22,18 +22,18 @@
<section> <section>
<h2 class="h4"> <h2 class="h4">
<Icon v="file-signature"/> <Icon v="file-signature"/>
<T>template.examples</T>: <T>pronouns.examples</T>:
</h2> </h2>
<ul> <ul>
<li v-for="example in examples" class="my-1"> <li v-for="example in examples" class="my-1">
<Example :example="example" :template="randomTemplate()" link/> <Example :example="example" :pronoun="randomPronoun()" link/>
</li> </li>
</ul> </ul>
</section> </section>
<section> <section>
<Share :title="`${$t('template.intro')}: ${$t('template.any.short')}`"/> <Share :title="`${$t('pronouns.intro')}: ${$t('pronouns.any.short')}`"/>
</section> </section>
<Separator icon="info"/> <Separator icon="info"/>
@ -49,7 +49,7 @@
</template> </template>
<script> <script>
import { examples, templates } from "~/src/data"; import { examples, pronouns } from "~/src/data";
import { head } from "../src/helpers"; import { head } from "../src/helpers";
export default { export default {
@ -60,14 +60,14 @@
}, },
head() { head() {
return head({ return head({
title: `${this.$t('template.intro')}: ${this.$t('template.any.short')}`, title: `${this.$t('pronouns.intro')}: ${this.$t('pronouns.any.short')}`,
banner: `api/banner/${this.$t('template.any.short')}.png`, banner: `api/banner/${this.$t('pronouns.any.short')}.png`,
}); });
}, },
methods: { methods: {
randomTemplate() { randomPronoun() {
const keys = Object.keys(templates); const keys = Object.keys(pronouns);
return templates[keys[keys.length * Math.random() << 0]]; return pronouns[keys[keys.length * Math.random() << 0]];
}, },
} }
} }

View File

@ -41,7 +41,7 @@
data() { data() {
return { return {
groups: [{ groups: [{
enabled: this.config.template.enabled, enabled: this.config.pronouns.enabled,
header: 'home.header', header: 'home.header',
icon: 'tags', icon: 'tags',
endpoints: { endpoints: {

View File

@ -12,23 +12,21 @@
<Separator icon="list"/> <Separator icon="list"/>
<ul class="list-group mt-5"> <ul class="list-group mt-5">
<li v-for="templateGroup in config.english.templateGroups" class="list-group-item"> <li v-for="pronounGroup in config.english.pronounGroups" class="list-group-item">
<h3 class="h4"> <h3 class="h4">
{{templateGroup.name}} {{pronounGroup.name}}
</h3> </h3>
<p v-for="p in templateGroup.description"> <p v-for="p in pronounGroup.description">
<LinkedText :text="p"/> <LinkedText :text="p"/>
</p> </p>
<EnglishTable v-if="templateGroup.table" :t="templateGroup.table"/> <EnglishTable v-if="pronounGroup.table" :t="pronounGroup.table"/>
</li> </li>
</ul> </ul>
<ScrollButton/>
</div> </div>
</template> </template>
<script> <script>
import EnglishTable from "../data/templates/EnglishTable"; import EnglishTable from "../data/pronouns/EnglishTable";
import { head } from "../src/helpers"; import { head } from "../src/helpers";
export default { export default {

View File

@ -18,11 +18,11 @@
<section> <section>
<h2> <h2>
<Icon v="tags"/> <Icon v="tags"/>
<T>home.templates</T> <T>home.pronouns</T>
</h2> </h2>
<ul class="list-group mt-4"> <ul class="list-group mt-4">
<li v-for="[group, groupTemplates] in templateLibrary.split()" class="list-group-item"> <li v-for="[group, groupPronouns] in pronounLibrary.split()" class="list-group-item">
<p class="h5"> <p class="h5">
{{ group.name }} {{ group.name }}
</p> </p>
@ -31,37 +31,37 @@
<em v-html="group.description"></em> <em v-html="group.description"></em>
</div> </div>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li v-for="template in groupTemplates" :key="template.canonicalName"> <li v-for="pronoun in groupPronouns" :key="pronoun.canonicalName">
<nuxt-link v-if="typeof template === 'string'" :to="'/' + template"> <nuxt-link v-if="typeof pronoun === 'string'" :to="'/' + pronoun">
<strong>{{template.replace(/&/g, ' ' + $t('template.or') + ' ')}}</strong> <strong>{{pronoun.replace(/&/g, ' ' + $t('pronouns.or') + ' ')}}</strong>
</nuxt-link> </nuxt-link>
<nuxt-link v-else :to="addSlash('/' + template.canonicalName)"> <nuxt-link v-else :to="addSlash('/' + pronoun.canonicalName)">
<strong>{{template.name(glue)}}</strong> <strong>{{pronoun.name(glue)}}</strong>
<small>{{template.description}}</small> <small>{{pronoun.description}}</small>
</nuxt-link> </nuxt-link>
<NormativeBadge v-if="template.normative"/> <NormativeBadge v-if="pronoun.normative"/>
</li> </li>
</ul> </ul>
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
<a v-if="!customiseMultiple" href="#" @click.prevent="customiseMultiple = true" class="btn btn-outline-primary btn-block"> <a v-if="!customiseMultiple" href="#" @click.prevent="customiseMultiple = true" class="btn btn-outline-primary btn-block">
<Icon v="sliders-h-square"/> <Icon v="sliders-h-square"/>
<T>template.alt.button</T> <T>pronouns.alt.button</T>
</a> </a>
<div v-else class="card"> <div v-else class="card">
<div class="card-header"> <div class="card-header">
<Icon v="sliders-h-square"/> <Icon v="sliders-h-square"/>
<T>template.alt.header</T>: <T>pronouns.alt.header</T>:
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="card-title"> <div class="card-title">
<ul class="list-inline d-inline mb-0"> <ul class="list-inline d-inline mb-0">
<li class="list-inline-item" v-for="(template, pronoun) in templates"> <li class="list-inline-item" v-for="(pronoun, pronounName) in pronouns">
<button :class="['btn', multiple.includes(pronoun) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']" <button :class="['btn', multiple.includes(pronounName) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']"
@click="toggleMultiple(pronoun)" @click="toggleMultiple(pronounName)"
> >
{{template.name()}} {{pronoun.name()}}
</button> </button>
</li> </li>
</ul> </ul>
@ -94,11 +94,11 @@
<li class="list-inline-item pt-1 h5"> <li class="list-inline-item pt-1 h5">
<T>home.generator.base</T>: <T>home.generator.base</T>:
</li> </li>
<li class="list-inline-item" v-for="(template, pronoun) in templates"> <li class="list-inline-item" v-for="(pronoun, pronounName) in pronouns">
<button :class="['btn', template.name(glue) === selectedTemplate.name(glue) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']" <button :class="['btn', pronoun.name(glue) === selectedPronoun.name(glue) ? 'btn-primary' : 'btn-outline-primary', 'btn-sm', 'my-1']"
@click="selectedTemplate = templates[pronoun].clone()" @click="selectedPronoun = pronouns[pronounName].clone()"
> >
{{template.name(glue)}} {{pronoun.name(glue)}}
</button> </button>
</li> </li>
</ul> </ul>
@ -106,26 +106,26 @@
<div class="alert alert-primary"> <div class="alert alert-primary">
<p class="h3 mb-0 text-center"> <p class="h3 mb-0 text-center">
{{ selectedTemplate.name(glue) }} {{ selectedPronoun.name(glue) }}
<br/> <br/>
<input v-model="selectedTemplate.description" <input v-model="selectedPronoun.description"
class="form-control form-input p-0 form-control-sm" class="form-control form-input p-0 form-control-sm"
:size="selectedTemplate.description.length + 3" :size="selectedPronoun.description.length + 3"
maxlength="48" maxlength="48"
/> />
</p> </p>
</div> </div>
<p> <p>
<T>template.examples</T>: <T>pronouns.examples</T>:
</p> </p>
<template v-for="isHonorific in [false, true]" v-if="examples.filter(e => e.isHonorific === isHonorific).length"> <template v-for="isHonorific in [false, true]" v-if="examples.filter(e => e.isHonorific === isHonorific).length">
<ul> <ul>
<li v-for="example in examples" v-if="example.isHonorific === isHonorific"> <li v-for="example in examples" v-if="example.isHonorific === isHonorific">
<span v-for="part in clearExampleParts(example[(isHonorific ? selectedTemplate.isPluralHonorific() : selectedTemplate.isPlural()) ? 'pluralParts' : 'singularParts'])"> <span v-for="part in clearExampleParts(example[(isHonorific ? selectedPronoun.isPluralHonorific() : selectedPronoun.isPlural()) ? 'pluralParts' : 'singularParts'])">
<input v-if="part.variable" v-model="selectedTemplate.morphemes[part.str]" <input v-if="part.variable" v-model="selectedPronoun.morphemes[part.str]"
:class="['form-control form-input p-0', {'active': selectedMorpheme === part.str}]" :class="['form-control form-input p-0', {'active': selectedMorpheme === part.str}]"
:size="selectedTemplate.morphemes[part.str] ? selectedTemplate.morphemes[part.str].length : 0" :size="selectedPronoun.morphemes[part.str] ? selectedPronoun.morphemes[part.str].length : 0"
maxlength="12" maxlength="12"
@focus="selectedMorpheme = part.str" @focus="selectedMorpheme = part.str"
@blur="selectedMorpheme = ''" @blur="selectedMorpheme = ''"
@ -136,12 +136,12 @@
</ul> </ul>
<div class="my-3"> <div class="my-3">
<div class="custom-control custom-switch" v-if="isHonorific"> <div class="custom-control custom-switch" v-if="isHonorific">
<input type="checkbox" class="custom-control-input" id="pluralHonorific" v-model="selectedTemplate.pluralHonorific[0]"> <input type="checkbox" class="custom-control-input" id="pluralHonorific" v-model="selectedPronoun.pluralHonorific[0]">
<label class="custom-control-label" for="pluralHonorific"><T>template.plural</T> <Icon v="level-up"/></label> <label class="custom-control-label" for="pluralHonorific"><T>pronouns.plural</T> <Icon v="level-up"/></label>
</div> </div>
<div class="custom-control custom-switch" v-else> <div class="custom-control custom-switch" v-else>
<input type="checkbox" class="custom-control-input" id="plural" v-model="selectedTemplate.plural[0]"> <input type="checkbox" class="custom-control-input" id="plural" v-model="selectedPronoun.plural[0]">
<label class="custom-control-label" for="plural"><T>template.plural</T> <Icon v="level-up"/></label> <label class="custom-control-label" for="plural"><T>pronouns.plural</T> <Icon v="level-up"/></label>
</div> </div>
</div> </div>
</template> </template>
@ -166,10 +166,10 @@
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
<p class="h5"> <p class="h5">
<nuxt-link :to="'/' + config.template.any.route"><T>template.any.header</T></nuxt-link> <nuxt-link :to="'/' + config.pronouns.any.route"><T>pronouns.any.header</T></nuxt-link>
</p> </p>
<p> <p>
<T>template.any.description</T> <T>pronouns.any.description</T>
</p> </p>
</li> </li>
</ul> </ul>
@ -186,21 +186,21 @@
</template> </template>
<script> <script>
import { examples, templates, getSources, templateLibrary } from "~/src/data"; import { examples, pronouns, getSources, pronounLibrary } from "~/src/data";
import { ExamplePart } from "~/src/classes"; import { ExamplePart } from "~/src/classes";
import Compressor from "../src/compressor"; import Compressor from "../src/compressor";
import { getTemplate } from "../src/buildTemplate"; import { getPronoun } from "../src/buildPronoun";
import MORPHEMES from '../data/templates/morphemes'; import MORPHEMES from '../data/pronouns/morphemes';
export default { export default {
data() { data() {
return { return {
examples: examples, examples,
templates: templates, pronouns,
getTemplate: getTemplate, getPronoun,
templateLibrary: templateLibrary, pronounLibrary,
selectedTemplate: templates[this.config.template.default].clone(), selectedPronoun: pronouns[this.config.pronouns.default].clone(),
selectedMorpheme: '', selectedMorpheme: '',
customiseMultiple: false, customiseMultiple: false,
@ -208,18 +208,18 @@
customise: false, customise: false,
glue: ' ' + this.$t('template.or') + ' ', glue: ' ' + this.$t('pronouns.or') + ' ',
} }
}, },
computed: { computed: {
usedBase() { usedBase() {
const name = this.selectedTemplate.name(this.glue); const name = this.selectedPronoun.name(this.glue);
for (let key in this.templates) { for (let key in this.pronouns) {
if (this.templates.hasOwnProperty(key)) { if (this.pronouns.hasOwnProperty(key)) {
if (key === name) { if (key === name) {
return key; return key;
} }
for (let alias of this.templates[key].aliases) { for (let alias of this.pronouns[key].aliases) {
if (alias === name) { if (alias === name) {
return key; return key;
} }
@ -230,17 +230,17 @@
return null; return null;
}, },
usedBaseEquals() { usedBaseEquals() {
return this.usedBase && this.templates[this.usedBase].equals(this.selectedTemplate); return this.usedBase && this.pronouns[this.usedBase].equals(this.selectedPronoun);
}, },
longLink() { longLink() {
const base = this.templates[this.selectedTemplate.morphemes[MORPHEMES[0]]]; const base = this.pronouns[this.selectedPronoun.morphemes[MORPHEMES[0]]];
return base return base
? Compressor.compress(this.selectedTemplate.toArray(), base.toArray()).join(',') ? Compressor.compress(this.selectedPronoun.toArray(), base.toArray()).join(',')
: this.selectedTemplate.toString(); : this.selectedPronoun.toString();
}, },
link() { link() {
if (!this.selectedTemplate.pronoun()) { if (!this.selectedPronoun.pronoun()) {
return null; return null;
} }
return this.addSlash(this.$base + '/' + (this.usedBaseEquals ? this.usedBase : this.longLink)); return this.addSlash(this.$base + '/' + (this.usedBaseEquals ? this.usedBase : this.longLink));
@ -253,7 +253,7 @@
return this.addSlash(this.$base + '/' + this.multiple.join('&')); return this.addSlash(this.$base + '/' + this.multiple.join('&'));
}, },
sources() { sources() {
return getSources(this.selectedTemplate); return getSources(this.selectedPronoun);
}, },
}, },
methods: { methods: {

View File

@ -66,8 +66,8 @@
</h3> </h3>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li v-for="{link, template, opinion} in pronounTemplates"> <li v-for="{link, pronoun, opinion} in pronounOpinions">
<Opinion :word="template.name(glue)" :opinion="opinion" :link="`/${link}`"/> <Opinion :word="pronoun.name(glue)" :opinion="opinion" :link="`/${link}`"/>
</li> </li>
</ul> </ul>
</div> </div>
@ -109,15 +109,15 @@
<script> <script>
import { head } from "../src/helpers"; import { head } from "../src/helpers";
import { templates } from "~/src/data"; import { pronouns } from "~/src/data";
import { buildTemplate } from "../src/buildTemplate"; import { buildPronoun } from "../src/buildPronoun";
export default { export default {
data() { data() {
return { return {
username: this.$route.params.pathMatch, username: this.$route.params.pathMatch,
profiles: {}, profiles: {},
glue: ' ' + this.$t('template.or') + ' ', glue: ' ' + this.$t('pronouns.or') + ' ',
allFlags: process.env.FLAGS, allFlags: process.env.FLAGS,
} }
}, },
@ -136,23 +136,23 @@
return null; return null;
}, },
pronounTemplates() { pronounOpinions() {
const pronounTemplates = []; const pronounOpinions = [];
for (let pronoun in this.profile.pronouns) { for (let pronoun in this.profile.pronouns) {
if (!this.profile.pronouns.hasOwnProperty(pronoun)) { continue; } if (!this.profile.pronouns.hasOwnProperty(pronoun)) { continue; }
const link = pronoun.replace(new RegExp('^' + this.$base), '').replace(new RegExp('^/'), ''); const link = pronoun.replace(new RegExp('^' + this.$base), '').replace(new RegExp('^/'), '');
const template = buildTemplate(templates, link); const pronounEntity = buildPronoun(pronouns, link);
if (template) { if (pronounEntity) {
pronounTemplates.push({ pronounOpinions.push({
link, link,
template, pronoun: pronounEntity,
opinion: this.profile.pronouns[pronoun], opinion: this.profile.pronouns[pronounEntity],
}); });
} }
} }
return pronounTemplates; return pronounOpinions;
}, },
}, },
head() { head() {

View File

@ -99,8 +99,8 @@
<script> <script>
import { head, dictToList, listToDict, buildList } from "../src/helpers"; import { head, dictToList, listToDict, buildList } from "../src/helpers";
import { templates } from "~/src/data"; import { pronouns } from "~/src/data";
import { buildTemplate } from "../src/buildTemplate"; import { buildPronoun } from "../src/buildPronoun";
import config from '../data/config.suml'; import config from '../data/config.suml';
const defaultWords = config.profile.defaultWords.map(c => buildList(function* () { const defaultWords = config.profile.defaultWords.map(c => buildList(function* () {
@ -170,8 +170,8 @@
}; };
}, },
methods: { methods: {
buildTemplate(link) { buildPronoun(link) {
return buildTemplate(templates, link); return buildPronoun(pronouns, link);
}, },
async save() { async save() {
this.saving = true; this.saving = true;
@ -189,9 +189,8 @@
}, },
validatePronoun(pronoun) { validatePronoun(pronoun) {
const link = pronoun.replace(new RegExp('^' + this.$base), '').replace(new RegExp('^/'), ''); const link = pronoun.replace(new RegExp('^' + this.$base), '').replace(new RegExp('^/'), '');
const template = buildTemplate(templates, link);
return template ? null : 'profile.pronounsNotFound' return buildPronoun(pronouns, link) ? null : 'profile.pronounsNotFound'
}, },
}, },
head() { head() {

View File

@ -1,16 +1,16 @@
<template> <template>
<NotFound v-if="!selectedTemplate"/> <NotFound v-if="!selectedPronoun"/>
<div v-else class="container"> <div v-else class="container">
<h2> <h2>
<Icon v="tag"/> <Icon v="tag"/>
<T>template.intro</T>: <T>pronouns.intro</T>:
</h2> </h2>
<section> <section>
<div class="alert alert-primary"> <div class="alert alert-primary">
<h2 class="text-center mb-0"> <h2 class="text-center mb-0">
<strong v-if="nameOptions.length === 1"> <strong v-if="nameOptions.length === 1">
{{ selectedTemplate.name(glue) }} {{ selectedPronoun.name(glue) }}
</strong> </strong>
<template v-else> <template v-else>
<template v-for="(nameOption, i) in nameOptions"> <template v-for="(nameOption, i) in nameOptions">
@ -23,11 +23,11 @@
</template> </template>
</template> </template>
</h2> </h2>
<p class="h6 small text-center mb-0 mt-2" v-if="selectedTemplate.description"> <p class="h6 small text-center mb-0 mt-2" v-if="selectedPronoun.description">
<em> <em>
({{Array.isArray(selectedTemplate.description) ({{Array.isArray(selectedPronoun.description)
? ($t('template.alt.header') + ': ' + selectedTemplate.description.join(glue)) ? ($t('pronouns.alt.header') + ': ' + selectedPronoun.description.join(glue))
: selectedTemplate.description : selectedPronoun.description
}}) }})
</em> </em>
</p> </p>
@ -37,46 +37,46 @@
<section> <section>
<h2 class="h4"> <h2 class="h4">
<Icon v="file-signature"/> <Icon v="file-signature"/>
<T>template.examples</T>: <T>pronouns.examples</T>:
</h2> </h2>
<ul> <ul>
<li v-for="example in examples" class="my-1"> <li v-for="example in examples" class="my-1">
<Example :example="example" :template="selectedTemplate" :counter="counter"/> <Example :example="example" :pronoun="selectedPronoun" :counter="counter"/>
</li> </li>
</ul> </ul>
</section> </section>
<GrammarTables :selectedTemplate="selectedTemplate" :counter="counter"/> <GrammarTables :selectedPronoun="selectedPronoun" :counter="counter"/>
<section v-if="selectedTemplate.history"> <section v-if="selectedPronoun.history">
<div class="alert alert-info" v-for="part in selectedTemplate.history.split('@')"> <div class="alert alert-info" v-for="part in selectedPronoun.history.split('@')">
<Icon v="info-circle"/> <Icon v="info-circle"/>
<LinkedText :text="part"/> <LinkedText :text="part"/>
</div> </div>
</section> </section>
<section v-if="templateGroup && templateGroup.group.description"> <section v-if="pronounGroup && pronounGroup.group.description">
<ul class="list-group mt-4"> <ul class="list-group mt-4">
<li class="list-group-item"> <li class="list-group-item">
<p class="h5"> <p class="h5">
{{ templateGroup.group.name }} {{ pronounGroup.group.name }}
</p> </p>
<div class="small my-1"> <div class="small my-1">
<Icon v="info-circle"/> <Icon v="info-circle"/>
<em v-html="templateGroup.group.description"></em> <em v-html="pronounGroup.group.description"></em>
</div> </div>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li v-for="template in templateGroup.groupTemplates" :key="template.canonicalName"> <li v-for="pronoun in pronounGroup.groupPronouns" :key="pronoun.canonicalName">
<nuxt-link v-if="typeof template === 'string'" :to="'/' + template"> <nuxt-link v-if="typeof pronoun === 'string'" :to="'/' + pronoun">
<strong>{{template.replace(/&/g, ' ' + $t('template.or') + ' ')}}</strong> <strong>{{pronoun.replace(/&/g, ' ' + $t('pronouns.or') + ' ')}}</strong>
</nuxt-link> </nuxt-link>
<nuxt-link v-else :to="addSlash('/' + template.canonicalName)"> <nuxt-link v-else :to="addSlash('/' + pronoun.canonicalName)">
<strong>{{template.name(glue)}}</strong> <strong>{{pronoun.name(glue)}}</strong>
<small>{{template.description}}</small> <small>{{pronoun.description}}</small>
</nuxt-link> </nuxt-link>
<NormativeBadge v-if="template.normative"/> <NormativeBadge v-if="pronoun.normative"/>
</li> </li>
</ul> </ul>
</li> </li>
@ -87,7 +87,7 @@
</section> </section>
<section> <section>
<Share :title="`${$t('template.intro')}: ${selectedTemplate.name(glue)}`"/> <Share :title="`${$t('pronouns.intro')}: ${selectedPronoun.name(glue)}`"/>
</section> </section>
<section v-if="Object.keys(sources).length"> <section v-if="Object.keys(sources).length">
@ -107,27 +107,27 @@
</template> </template>
<script> <script>
import { examples, templates, getSources, templateLibrary } from "~/src/data"; import { examples, pronouns, getSources, pronounLibrary } from "~/src/data";
import { buildTemplate } from "../src/buildTemplate"; import { buildPronoun } from "../src/buildPronoun";
import { head } from "../src/helpers"; import { head } from "../src/helpers";
import GrammarTables from "../data/templates/GrammarTables"; import GrammarTables from "../data/pronouns/GrammarTables";
import LinkedText from "../components/LinkedText"; import LinkedText from "../components/LinkedText";
export default { export default {
components: {LinkedText, GrammarTables }, components: {LinkedText, GrammarTables },
data() { data() {
const selectedTemplate = this.config.template.enabled const selectedPronoun = this.config.pronouns.enabled
? buildTemplate(templates, decodeURIComponent(this.$route.path.substr(1).replace(/\/$/, ''))) ? buildPronoun(pronouns, decodeURIComponent(this.$route.path.substr(1).replace(/\/$/, '')))
: null; : null;
return { return {
examples, examples,
templates, pronouns,
glue: ' ' + this.$t('template.or') + ' ', glue: ' ' + this.$t('pronouns.or') + ' ',
selectedTemplate, selectedPronoun,
nameOptions: selectedTemplate ? selectedTemplate.nameOptions() : [], nameOptions: selectedPronoun ? selectedPronoun.nameOptions() : [],
templateGroup: templateLibrary.find(selectedTemplate), pronounGroup: pronounLibrary.find(selectedPronoun),
counter: 0, counter: 0,
} }
@ -138,8 +138,8 @@
} }
}, },
head() { head() {
return this.selectedTemplate ? head({ return this.selectedPronoun ? head({
title: `${this.$t('template.intro')}: ${this.selectedTemplate.name(this.glue)}`, title: `${this.$t('pronouns.intro')}: ${this.selectedPronoun.name(this.glue)}`,
banner: `api/banner${this.$route.path.replace(/\/$/, '')}.png`, banner: `api/banner${this.$route.path.replace(/\/$/, '')}.png`,
}) : {}; }) : {};
}, },
@ -150,7 +150,7 @@
}, },
computed: { computed: {
sources() { sources() {
return getSources(this.selectedTemplate); return getSources(this.selectedPronoun);
}, },
}, },
} }

View File

@ -27,7 +27,7 @@
<T>sources.toc</T> <T>sources.toc</T>
</button> </button>
<ul v-if="tocShown" class="list-group"> <ul v-if="tocShown" class="list-group">
<li v-for="[group, groupTemplates] in templateLibrary.split(filterTemplate, false)" v-if="groupTemplates.length" class="list-group-item"> <li v-for="[group, groupPronouns] in pronounLibrary.split(filterPronoun, false)" v-if="groupPronouns.length" class="list-group-item">
<p class="h5"> <p class="h5">
{{ group.name }} {{ group.name }}
</p> </p>
@ -36,23 +36,23 @@
<em v-html="group.description"></em> <em v-html="group.description"></em>
</div> </div>
<ul class="list-unstyled"> <ul class="list-unstyled">
<li v-for="template in groupTemplates" :key="template.canonicalName"> <li v-for="pronoun in groupPronouns" :key="pronoun.canonicalName">
<a v-if="typeof template === 'string'" :href="'#' + toId(template)"> <a v-if="typeof pronoun === 'string'" :href="'#' + toId(pronoun)">
<strong>{{ template.replace(/&/g, glue) }}</strong> <strong>{{ pronoun.replace(/&/g, glue) }}</strong>
</a> </a>
<a v-else :href="'#' + toId(template.name(glue))"> <a v-else :href="'#' + toId(pronoun.name(glue))">
<strong>{{ template.name(glue) }}</strong> <strong>{{ pronoun.name(glue) }}</strong>
<small>{{ template.description }}</small> <small>{{ pronoun.description }}</small>
</a> </a>
<NormativeBadge v-if="template.normative"/> <NormativeBadge v-if="pronoun.normative"/>
</li> </li>
</ul> </ul>
</li> </li>
<li class="list-group-item" v-if="otherSources.length"> <li class="list-group-item" v-if="otherSources.length">
<p class="h5 mb-0"> <p class="h5 mb-0">
<a :href="'#' + $t('template.othersRaw')"> <a :href="'#' + $t('pronouns.othersRaw')">
<strong><T>template.others</T></strong> <strong><T>pronouns.others</T></strong>
</a> </a>
</p> </p>
</li> </li>
@ -87,12 +87,12 @@
</div> </div>
</section> </section>
<section v-for="template in templates" v-if="template.sources.length"> <section v-for="pronoun in pronouns" v-if="pronoun.sources.length">
<SourceList :names="template.sources" :filter="filter" :filterType="filterType"> <SourceList :names="pronoun.sources" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="toId(template.name(glue))"> <h2 class="h4" :id="toId(pronoun.name(glue))">
<nuxt-link :to="'/' + template.pronoun()"> <nuxt-link :to="'/' + pronoun.pronoun()">
{{ template.description }} {{ pronoun.description }}
<small>({{ template.name(glue) }})</small> <small>({{ pronoun.name(glue) }})</small>
</nuxt-link> </nuxt-link>
</h2> </h2>
</SourceList> </SourceList>
@ -102,7 +102,7 @@
<SourceList :names="sources" :filter="filter" :filterType="filterType"> <SourceList :names="sources" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="toId(multiple)"> <h2 class="h4" :id="toId(multiple)">
<nuxt-link :to="'/' + multiple"> <nuxt-link :to="'/' + multiple">
<T>template.alt.header</T> <T>pronouns.alt.header</T>
<small>({{ multiple.replace(/&/g, ' lub ') }})</small> <small>({{ multiple.replace(/&/g, ' lub ') }})</small>
</nuxt-link> </nuxt-link>
</h2> </h2>
@ -111,8 +111,8 @@
<section v-if="otherSources.length"> <section v-if="otherSources.length">
<SourceList :names="otherSources" :filter="filter" :filterType="filterType"> <SourceList :names="otherSources" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="$t('template.othersRaw')"> <h2 class="h4" :id="$t('pronouns.othersRaw')">
<T>template.others</T> <T>pronouns.others</T>
</h2> </h2>
</SourceList> </SourceList>
</section> </section>
@ -120,7 +120,7 @@
</template> </template>
<script> <script>
import { templates, sources, templateLibrary } from '../src/data' import { pronouns, sources, pronounLibrary } from '../src/data'
import sourcesForMultipleForms from '../data/sources/sourcesMultiple'; import sourcesForMultipleForms from '../data/sources/sourcesMultiple';
import { Source } from "../src/classes"; import { Source } from "../src/classes";
import { head } from "../src/helpers"; import { head } from "../src/helpers";
@ -128,14 +128,14 @@
export default { export default {
data() { data() {
return { return {
templates: templates, pronouns,
sourcesForMultipleForms: sourcesForMultipleForms, sourcesForMultipleForms: sourcesForMultipleForms,
templateLibrary: templateLibrary, pronounLibrary,
tocShown: false, tocShown: false,
sourceTypes: Source.TYPES, sourceTypes: Source.TYPES,
filter: '', filter: '',
filterType: '', filterType: '',
glue: ' ' + this.$t('template.or') + ' ', glue: ' ' + this.$t('pronouns.or') + ' ',
submitShown: false, submitShown: false,
}; };
}, },
@ -155,8 +155,8 @@
computed: { computed: {
otherSources() { otherSources() {
const other = new Set(Object.keys(sources)); const other = new Set(Object.keys(sources));
for (let template of Object.values(this.templates)) { for (let pronoun of Object.values(this.pronouns)) {
for (let source of template.sources) { for (let source of pronoun.sources) {
other.delete(source); other.delete(source);
} }
} }
@ -172,7 +172,7 @@
toId(str) { toId(str) {
return str.replace(/\//g, '-').replace(/&/g, '_'); return str.replace(/\//g, '-').replace(/&/g, '_');
}, },
filterTemplate(t) { filterPronoun(t) {
if (typeof t === 'string') { if (typeof t === 'string') {
return Object.keys(sourcesForMultipleForms).includes(t); return Object.keys(sourcesForMultipleForms).includes(t);
} }

View File

@ -34,7 +34,7 @@ app.use(require('./routes/user').default);
app.use(require('./routes/profile').default); app.use(require('./routes/profile').default);
app.use(require('./routes/admin').default); app.use(require('./routes/admin').default);
app.use(require('./routes/templates').default); app.use(require('./routes/pronouns').default);
app.use(require('./routes/sources').default); app.use(require('./routes/sources').default);
app.use(require('./routes/nouns').default); app.use(require('./routes/nouns').default);

View File

@ -3,7 +3,7 @@ import SQL from 'sql-template-strings';
import {createCanvas, loadImage, registerFont} from "canvas"; import {createCanvas, loadImage, registerFont} from "canvas";
import { loadSuml } from '../loader'; import { loadSuml } from '../loader';
import avatar from '../avatar'; import avatar from '../avatar';
import {buildTemplate, parseTemplates} from "../../src/buildTemplate"; import {buildPronoun, parsePronouns} from "../../src/buildPronoun";
import {loadTsv} from "../../src/tsv"; import {loadTsv} from "../../src/tsv";
const translations = loadSuml('translations'); const translations = loadSuml('translations');
@ -26,8 +26,8 @@ const drawCircle = (context, image, x, y, size) => {
const router = Router(); const router = Router();
router.get('/banner/:templateName*.png', async (req, res) => { router.get('/banner/:pronounName*.png', async (req, res) => {
const templateName = req.params.templateName + req.params[0]; const pronounName = req.params.pronounName + req.params[0];
const width = 1200 const width = 1200
const height = 600 const height = 600
const mime = 'image/png'; const mime = 'image/png';
@ -52,8 +52,8 @@ router.get('/banner/:templateName*.png', async (req, res) => {
context.fillText(translations.title, width / leftRatio + imageSize / 1.5, height / 2 + 48); context.fillText(translations.title, width / leftRatio + imageSize / 1.5, height / 2 + 48);
} }
if (templateName.startsWith('@')) { if (pronounName.startsWith('@')) {
const user = await req.db.get(SQL`SELECT id, username, email, avatarSource FROM users WHERE username=${templateName.substring(1)}`); const user = await req.db.get(SQL`SELECT id, username, email, avatarSource FROM users WHERE username=${pronounName.substring(1)}`);
if (!user) { if (!user) {
await fallback(); await fallback();
return res.set('content-type', mime).send(canvas.toBuffer(mime)); return res.set('content-type', mime).send(canvas.toBuffer(mime));
@ -77,25 +77,25 @@ router.get('/banner/:templateName*.png', async (req, res) => {
return res.set('content-type', mime).send(canvas.toBuffer(mime)); return res.set('content-type', mime).send(canvas.toBuffer(mime));
} }
const template = buildTemplate( const pronoun = buildPronoun(
parseTemplates(loadTsv(__dirname + '/../../data/templates/templates.tsv')), parsePronouns(loadTsv(__dirname + '/../../data/pronouns/pronouns.tsv')),
templateName, pronounName,
); );
const logo = await loadImage('node_modules/@fortawesome/fontawesome-pro/svgs/light/tags.svg'); const logo = await loadImage('node_modules/@fortawesome/fontawesome-pro/svgs/light/tags.svg');
if (!template && templateName !== 'dowolne') { // TODO if (!pronoun && pronounName !== 'dowolne') { // TODO
await fallback(); await fallback();
return res.set('content-type', mime).send(canvas.toBuffer(mime)); return res.set('content-type', mime).send(canvas.toBuffer(mime));
} }
context.drawImage(logo, width / leftRatio - imageSize / 2, height / 2 - imageSize / 1.25 / 2, imageSize, imageSize / 1.25) context.drawImage(logo, width / leftRatio - imageSize / 2, height / 2 - imageSize / 1.25 / 2, imageSize, imageSize / 1.25)
context.font = 'regular 48pt Quicksand' context.font = 'regular 48pt Quicksand'
context.fillText(translations.template.intro + ':', width / leftRatio + imageSize / 1.5, height / 2 - 36) context.fillText(translations.pronouns.intro + ':', width / leftRatio + imageSize / 1.5, height / 2 - 36)
const templateNameOptions = templateName === 'dowolne' ? ['dowolne'] : template.nameOptions(); const pronounNameOptions = pronounName === 'dowolne' ? ['dowolne'] : pronoun.nameOptions();
context.font = `bold ${templateNameOptions.length <= 2 ? '70' : '36'}pt Quicksand` context.font = `bold ${pronounNameOptions.length <= 2 ? '70' : '36'}pt Quicksand`
context.fillText(templateNameOptions.join('\n'), width / leftRatio + imageSize / 1.5, height / 2 + (templateNameOptions.length <= 2 ? 72 : 24)) context.fillText(pronounNameOptions.join('\n'), width / leftRatio + imageSize / 1.5, height / 2 + (pronounNameOptions.length <= 2 ? 72 : 24))
return res.set('content-type', mime).send(canvas.toBuffer(mime)); return res.set('content-type', mime).send(canvas.toBuffer(mime));
}); });

View File

@ -1,6 +1,6 @@
import { Router } from 'express'; import { Router } from 'express';
import { loadTsv } from '../loader'; import { loadTsv } from '../loader';
import {buildTemplate, parseTemplates} from "../../src/buildTemplate"; import {buildPronoun, parsePronouns} from "../../src/buildPronoun";
import {buildList} from "../../src/helpers"; import {buildList} from "../../src/helpers";
import {Example} from "../../src/classes"; import {Example} from "../../src/classes";
@ -12,7 +12,7 @@ const buildExample = e => new Example(
const requestExamples = r => { const requestExamples = r => {
if (!r || !r.length) { if (!r || !r.length) {
return loadTsv('templates/examples'); return loadTsv('pronouns/examples');
} }
return buildList(function* () { return buildList(function* () {
@ -34,17 +34,17 @@ const addExamples = (pronoun, examples) => {
const router = Router(); const router = Router();
router.get('/pronouns', async (req, res) => { router.get('/pronouns', async (req, res) => {
const templates = parseTemplates(loadTsv('templates/templates')); const pronouns = parsePronouns(loadTsv('pronouns/pronouns'));
for (let template in templates) { for (let pronoun in pronouns) {
if (!templates.hasOwnProperty(template)) { continue; } if (!pronouns.hasOwnProperty(pronoun)) { continue; }
templates[template].examples = addExamples(templates[template], requestExamples(req.query.examples)) pronouns[pronoun].examples = addExamples(pronouns[pronoun], requestExamples(req.query.examples))
} }
return res.json(templates); return res.json(pronouns);
}); });
router.get('/pronouns/:pronoun*', async (req, res) => { router.get('/pronouns/:pronoun*', async (req, res) => {
const pronoun = buildTemplate( const pronoun = buildPronoun(
parseTemplates(loadTsv('templates/templates')), parsePronouns(loadTsv('pronouns/pronouns')),
req.params.pronoun + req.params[0], req.params.pronoun + req.params[0],
); );
if (pronoun) { if (pronoun) {

View File

@ -10,7 +10,7 @@ const generateId = title => {
const buildEmail = (data, user) => { const buildEmail = (data, user) => {
const human = [ const human = [
`<li><strong>user:</strong> ${user ? user.username : ''}</li>`, `<li><strong>user:</strong> ${user ? user.username : ''}</li>`,
`<li><strong>templates:</strong> ${data.templates}</li>`, `<li><strong>pronouns:</strong> ${data.pronouns}</li>`,
]; ];
const tsv = [generateId(data.title) || '???']; const tsv = [generateId(data.title) || '???'];

68
src/buildPronoun.js Normal file
View File

@ -0,0 +1,68 @@
import { Pronoun } from "./classes";
import Compressor from "./compressor";
import { buildDict } from "./helpers";
import MORPHEMES from '../data/pronouns/morphemes';
export const addAliasesToPronouns = (pronouns) => {
const pronounsWithAliases = {}
for (let base in pronouns) {
if (pronouns.hasOwnProperty(base)) {
const pronoun = pronouns[base];
pronounsWithAliases[base] = pronoun;
for (let alias of pronoun.aliases) {
pronounsWithAliases[alias] = pronoun;
}
}
}
return pronounsWithAliases;
}
export const getPronoun = (pronouns, id) => {
return addAliasesToPronouns(pronouns)[id];
}
export const buildPronoun = (pronouns, path) => {
const pronounsWithAliases = addAliasesToPronouns(pronouns);
const pronounStr = path.split(',');
let base = null;
for (let option of pronounStr[0].split('&')) {
if (!base) {
base = pronounsWithAliases[option]
} else {
base = base.merge(pronounsWithAliases[option])
}
}
return pronounStr.length === 1
? base
: Pronoun.from(Compressor.uncompress(pronounStr, base ? base.toArray() : null));
}
export const parsePronouns = (pronounsRaw) => {
return buildDict(function* () {
for (let t of pronounsRaw) {
const aliases = t.key.split(',');
yield [
aliases[0],
new Pronoun(
aliases[0],
t.description,
t.normative,
buildDict(function* () {
for (let morpheme of MORPHEMES) {
yield [morpheme, t[morpheme]];
}
}),
[t.plural],
[t.pluralHonorific],
t.sources ? t.sources.split(',') : [],
aliases.slice(1),
t.history,
)
];
}
});
}

View File

@ -1,68 +0,0 @@
import { Template } from "./classes";
import Compressor from "./compressor";
import { buildDict } from "./helpers";
import MORPHEMES from '../data/templates/morphemes';
export const addAliasesToTemplates = (templates) => {
const templatesWithAliases = {}
for (let base in templates) {
if (templates.hasOwnProperty(base)) {
const template = templates[base];
templatesWithAliases[base] = template;
for (let alias of template.aliases) {
templatesWithAliases[alias] = template;
}
}
}
return templatesWithAliases;
}
export const getTemplate = (templates, id) => {
return addAliasesToTemplates(templates)[id];
}
export const buildTemplate = (templates, path) => {
const templatesWithAliases = addAliasesToTemplates(templates);
const templateStr = path.split(',');
let base = null;
for (let option of templateStr[0].split('&')) {
if (!base) {
base = templatesWithAliases[option]
} else {
base = base.merge(templatesWithAliases[option])
}
}
return templateStr.length === 1
? base
: Template.from(Compressor.uncompress(templateStr, base ? base.toArray() : null));
}
export const parseTemplates = (templatesRaw) => {
return buildDict(function* () {
for (let t of templatesRaw) {
const aliases = t.key.split(',');
yield [
aliases[0],
new Template(
aliases[0],
t.description,
t.normative,
buildDict(function* () {
for (let morpheme of MORPHEMES) {
yield [morpheme, t[morpheme]];
}
}),
[t.plural],
[t.pluralHonorific],
t.sources ? t.sources.split(',') : [],
aliases.slice(1),
t.history,
)
];
}
});
}

View File

@ -1,5 +1,5 @@
import {buildDict, buildList, capitalise} from "./helpers"; import {buildDict, buildList, capitalise} from "./helpers";
import MORPHEMES from '../data/templates/morphemes'; import MORPHEMES from '../data/pronouns/morphemes';
export class ExamplePart { export class ExamplePart {
constructor(variable, str) { constructor(variable, str) {
@ -110,7 +110,7 @@ const escape = s => {
.replace(/\?/g, '%3F'); .replace(/\?/g, '%3F');
} }
export class Template { export class Pronoun {
constructor (canonicalName, description, normative, morphemes, plural, pluralHonorific, sources = [], aliases = [], history = null) { constructor (canonicalName, description, normative, morphemes, plural, pluralHonorific, sources = [], aliases = [], history = null) {
this.canonicalName = canonicalName; this.canonicalName = canonicalName;
this.description = description; this.description = description;
@ -143,7 +143,7 @@ export class Template {
} }
clone() { clone() {
return new Template(this.canonicalName, this.description, this.normative, clone(this.morphemes), this.plural, this.pluralHonorific); return new Pronoun(this.canonicalName, this.description, this.normative, clone(this.morphemes), this.plural, this.pluralHonorific);
} }
equals(other) { equals(other) {
@ -151,7 +151,7 @@ export class Template {
} }
merge(other) { merge(other) {
return new Template( return new Pronoun(
this.canonicalName + '&' + other.canonicalName, this.canonicalName + '&' + other.canonicalName,
Array.isArray(this.description) ? [...this.description, other.description] : [this.description, other.description], Array.isArray(this.description) ? [...this.description, other.description] : [this.description, other.description],
this.normative && other.normative, this.normative && other.normative,
@ -225,7 +225,7 @@ export class Template {
m[MORPHEMES[parseInt(i)]] = data[parseInt(i)]; m[MORPHEMES[parseInt(i)]] = data[parseInt(i)];
} }
return new Template( return new Pronoun(
m[MORPHEMES[0]], m[MORPHEMES[0]],
data[data.length - 1], data[data.length - 1],
false, false,
@ -236,61 +236,61 @@ export class Template {
} }
} }
export class TemplateGroup { export class PronounGroup {
constructor(name, templates, description = null) { constructor(name, pronouns, description = null) {
this.name = name; this.name = name;
this.templates = templates; this.pronouns = pronouns;
this.description = description; this.description = description;
} }
} }
export class TemplateLibrary { export class PronounLibrary {
constructor(groups, templates) { constructor(groups, pronouns) {
this.groups = groups; this.groups = groups;
this.templates = templates; this.pronouns = pronouns;
} }
*split(filter = null, includeOthers = true) { *split(filter = null, includeOthers = true) {
let templatesLeft = Object.keys(this.templates); let pronounsLeft = Object.keys(this.pronouns);
const that = this; const that = this;
for (let g of this.groups) { for (let g of this.groups) {
yield [g, buildList(function* () { yield [g, buildList(function* () {
for (let t of g.templates) { for (let t of g.pronouns) {
templatesLeft = templatesLeft.filter(i => i !== t); pronounsLeft = pronounsLeft.filter(i => i !== t);
const template = that.templates[t] || t; const pronoun = that.pronouns[t] || t;
if (!filter || filter(template)) { if (!filter || filter(pronoun)) {
yield template; yield pronoun;
} }
} }
})]; })];
} }
if (!templatesLeft.length || !includeOthers) { if (!pronounsLeft.length || !includeOthers) {
return; return;
} }
yield [ yield [
new TemplateGroup('Inne formy', templatesLeft), new PronounGroup('Inne formy', pronounsLeft),
buildList(function* () { buildList(function* () {
for (let t of templatesLeft) { for (let t of pronounsLeft) {
if (!filter || filter(that.templates[t])) { if (!filter || filter(that.pronouns[t])) {
yield that.templates[t]; yield that.pronouns[t];
} }
} }
}), }),
]; ];
} }
find(template) { find(pronoun) {
if (!template) { if (!pronoun) {
return null; return null;
} }
for (let [group, groupTemplates] of this.split()) { for (let [group, groupPronouns] of this.split()) {
for (let t of groupTemplates) { for (let t of groupPronouns) {
if (t.canonicalName === template.canonicalName) { if (t.canonicalName === pronoun.canonicalName) {
return {group, groupTemplates}; return {group, groupPronouns};
} }
} }
} }

View File

@ -1,6 +1,6 @@
import {Source, Example, NounTemplate, TemplateGroup, TemplateLibrary, Name, Person, NounDeclension} from './classes' import {Source, Example, NounTemplate, PronounGroup, PronounLibrary, Name, Person, NounDeclension} from './classes'
import { buildDict, buildList } from './helpers'; import { buildDict, buildList } from './helpers';
import { parseTemplates, getTemplate } from './buildTemplate'; import { parsePronouns, getPronoun } from './buildPronoun';
import sourcesForMultipleForms from '../data/sources/sourcesMultiple'; import sourcesForMultipleForms from '../data/sources/sourcesMultiple';
export const locales = { export const locales = {
@ -16,10 +16,10 @@ export const socialProviders = {
google: { name: 'Google' }, google: { name: 'Google' },
} }
import templatesRaw from '../data/templates/templates.tsv'; import pronounsRaw from '../data/pronouns/pronouns.tsv';
export const templates = parseTemplates(templatesRaw); export const pronouns = parsePronouns(pronounsRaw);
import examplesRaw from '../data/templates/examples.tsv'; import examplesRaw from '../data/pronouns/examples.tsv';
export const examples = buildList(function* () { export const examples = buildList(function* () {
for (let e of examplesRaw) { for (let e of examplesRaw) {
yield new Example( yield new Example(
@ -49,23 +49,23 @@ export const sources = buildDict(function* () {
} }
}); });
export const getSources = (selectedTemplate) => { export const getSources = (selectedPronoun) => {
if (!selectedTemplate) { if (!selectedPronoun) {
return {}; return {};
} }
let sources = {}; let sources = {};
for (let multiple in sourcesForMultipleForms) { for (let multiple in sourcesForMultipleForms) {
if (sourcesForMultipleForms.hasOwnProperty(multiple)) { if (sourcesForMultipleForms.hasOwnProperty(multiple)) {
if (multiple === selectedTemplate.canonicalName) { if (multiple === selectedPronoun.canonicalName) {
sources[multiple] = sourcesForMultipleForms[multiple]; sources[multiple] = sourcesForMultipleForms[multiple];
} }
} }
} }
for (let option of selectedTemplate.nameOptions()) { for (let option of selectedPronoun.nameOptions()) {
const template = getTemplate(templates, option); const pronoun = getPronoun(pronouns, option);
if (template && template.sources.length) { if (pronoun && pronoun.sources.length) {
sources[option] = template.sources; sources[option] = pronoun.sources;
} }
} }
return sources; return sources;
@ -85,18 +85,18 @@ export const nounTemplates = buildList(function* () {
} }
}); });
import templateGroupsRaw from '../data/templates/templateGroups.tsv'; import pronounGroupsRaw from '../data/pronouns/pronounGroups.tsv';
export const templateGroups = buildList(function* () { export const pronounGroups = buildList(function* () {
for (let g of templateGroupsRaw) { for (let g of pronounGroupsRaw) {
yield new TemplateGroup( yield new PronounGroup(
g.name, g.name,
g.templates.split(','), g.pronouns.split(','),
g.description, g.description,
); );
} }
}); });
export const templateLibrary = new TemplateLibrary(templateGroups, templates); export const pronounLibrary = new PronounLibrary(pronounGroups, pronouns);
import namesRaw from '../data/names/names.tsv'; import namesRaw from '../data/names/names.tsv';
export const names = buildDict(function* () { export const names = buildDict(function* () {