2020-09-29 10:11:46 -07:00
|
|
|
import { Source, Example, NounTemplate, TemplateGroup, TemplateLibrary, Name, Person } from './classes'
|
2020-07-25 10:21:52 -07:00
|
|
|
import { buildDict, buildList } from './helpers';
|
2020-07-26 06:27:36 -07:00
|
|
|
import { parseTemplates, getTemplate } from './buildTemplate';
|
|
|
|
|
2020-09-29 07:27:37 -07:00
|
|
|
export const locales = {
|
|
|
|
en: { name: 'English', url: 'https://en.pronouns.page' },
|
|
|
|
pl: { name: 'Polski', url: 'https://zaimki.pl' },
|
|
|
|
de: { name: 'Deutsch', url: 'https://de.pronouns.page' },
|
|
|
|
nl: { name: 'Nederlands', url: 'https://nl.pronouns.page' },
|
|
|
|
}
|
|
|
|
|
2020-07-26 06:27:36 -07:00
|
|
|
import templatesRaw from '../data/templates.tsv';
|
|
|
|
export const templates = parseTemplates(templatesRaw);
|
2020-07-25 10:21:52 -07:00
|
|
|
|
|
|
|
import examplesRaw from '../data/examples.tsv';
|
|
|
|
export const examples = buildList(function* () {
|
|
|
|
for (let e of examplesRaw) {
|
|
|
|
yield new Example(
|
|
|
|
Example.parse(e.singular),
|
|
|
|
Example.parse(e.plural || e.singular),
|
|
|
|
e.isHonorific,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
import sourcesRaw from '../data/sources.tsv';
|
|
|
|
export const sources = buildDict(function* () {
|
|
|
|
for (let s of sourcesRaw) {
|
|
|
|
yield [
|
|
|
|
s.key,
|
|
|
|
new Source(
|
|
|
|
s.type,
|
|
|
|
s.author,
|
|
|
|
s.title,
|
|
|
|
s.extra,
|
|
|
|
s.year,
|
|
|
|
s.fragments ? s.fragments.replace(/\|/g, '\n').split('@') : [],
|
|
|
|
s.comment,
|
|
|
|
s.link,
|
|
|
|
)
|
|
|
|
];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-09-29 07:27:37 -07:00
|
|
|
// TODO move to locale
|
2020-07-26 06:27:36 -07:00
|
|
|
export const sourcesForMultipleForms = {
|
2020-09-17 12:26:38 -07:00
|
|
|
'on&ona': ['genderneutralizacja', 'niebTlum', 'jurewicz', 'krolowaZimy', 'mlotThora', 'statekUmarlych', 'starWarsKoPo', 'luBart1'],
|
2020-09-01 02:47:41 -07:00
|
|
|
'ona&onu': ['liniaOporuMix'],
|
2020-09-05 05:17:33 -07:00
|
|
|
'ono/jego&ono/jej': ['kazmierczak'],
|
2020-07-26 06:27:36 -07:00
|
|
|
}
|
2020-07-26 06:15:56 -07:00
|
|
|
|
2020-07-26 06:27:36 -07:00
|
|
|
export const getSources = (selectedTemplate) => {
|
|
|
|
if (!selectedTemplate) {
|
2020-07-27 08:26:40 -07:00
|
|
|
return {};
|
2020-07-26 06:27:36 -07:00
|
|
|
}
|
|
|
|
|
2020-07-27 08:26:40 -07:00
|
|
|
let sources = {};
|
2020-07-26 06:43:17 -07:00
|
|
|
for (let multiple in sourcesForMultipleForms) {
|
|
|
|
if (sourcesForMultipleForms.hasOwnProperty(multiple)) {
|
2020-09-05 12:45:30 -07:00
|
|
|
if (multiple === selectedTemplate.canonicalName) {
|
2020-07-27 08:26:40 -07:00
|
|
|
sources[multiple] = sourcesForMultipleForms[multiple];
|
2020-07-26 06:43:17 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-26 06:27:36 -07:00
|
|
|
for (let option of selectedTemplate.nameOptions()) {
|
|
|
|
const template = getTemplate(templates, option);
|
|
|
|
if (template && template.sources.length) {
|
2020-07-27 08:26:40 -07:00
|
|
|
sources[option] = template.sources;
|
2020-07-26 06:27:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return sources;
|
|
|
|
}
|
2020-08-05 11:24:05 -07:00
|
|
|
|
2020-09-04 08:07:32 -07:00
|
|
|
import nounTemplatesRaw from '../data/nounTemplates.tsv';
|
|
|
|
export const nounTemplates = buildList(function* () {
|
|
|
|
for (let t of nounTemplatesRaw) {
|
|
|
|
yield new NounTemplate(
|
|
|
|
t.masc.replace(/-/g, '').split('/'),
|
|
|
|
t.fem.replace(/-/g, '').split('/'),
|
|
|
|
t.neutr.replace(/-/g, '').split('/'),
|
|
|
|
t.mascPl.replace(/-/g, '').split('/'),
|
|
|
|
t.femPl.replace(/-/g, '').split('/'),
|
|
|
|
t.neutrPl.replace(/-/g, '').split('/'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2020-08-05 11:24:05 -07:00
|
|
|
|
2020-09-08 09:10:04 -07:00
|
|
|
import templateGroupsRaw from '../data/templateGroups.tsv';
|
|
|
|
export const templateGroups = buildList(function* () {
|
|
|
|
for (let g of templateGroupsRaw) {
|
|
|
|
yield new TemplateGroup(
|
|
|
|
g.name,
|
|
|
|
g.templates.split(','),
|
|
|
|
g.description,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export const templateLibrary = new TemplateLibrary(templateGroups, templates);
|
2020-09-29 08:59:23 -07:00
|
|
|
|
|
|
|
import namesRaw from '../data/names.tsv';
|
|
|
|
export const names = buildDict(function* () {
|
|
|
|
for (let n of namesRaw) {
|
|
|
|
yield [n.name, new Name(
|
|
|
|
n.name,
|
|
|
|
n.origin,
|
|
|
|
n.meaning,
|
|
|
|
n.usage,
|
|
|
|
n.legally,
|
|
|
|
n.pros ? n.pros.split(',') : [],
|
|
|
|
n.cons ? n.cons.split(',') : [],
|
|
|
|
n.notablePeople ? n.notablePeople.split(',') : [],
|
|
|
|
n.count,
|
|
|
|
n.links ? n.links.split(' ') : [],
|
|
|
|
)];
|
|
|
|
}
|
|
|
|
});
|
2020-09-29 10:11:46 -07:00
|
|
|
|
|
|
|
import peopleRaw from '../data/people.tsv';
|
|
|
|
export const people = buildList(function* () {
|
|
|
|
for (let p of peopleRaw) {
|
|
|
|
yield new Person(
|
|
|
|
p.name,
|
|
|
|
p.description,
|
|
|
|
p.pronouns.split(','),
|
|
|
|
p.sources ? p.sources.split(',') : [],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|