2020-09-13 13:15:44 -07:00
|
|
|
<template>
|
|
|
|
<span>
|
2020-11-10 15:47:44 -08:00
|
|
|
<span v-for="part in example[(example.isHonorific ? pronoun.isPluralHonorific(counter) : pronoun.isPlural(counter)) ? 'pluralParts' : 'singularParts']">
|
|
|
|
<strong v-if="part.variable">{{pronoun.getMorpheme(part.str, counter)}}</strong>
|
2020-09-13 13:15:44 -07:00
|
|
|
<span v-else>{{part.str}}</span>
|
|
|
|
</span>
|
|
|
|
<small v-if="link">
|
2020-11-10 15:47:44 -08:00
|
|
|
(<nuxt-link :to="'/' + pronoun.canonicalName">{{ pronoun.canonicalName }}</nuxt-link>)
|
2020-09-13 13:15:44 -07:00
|
|
|
</small>
|
2020-11-28 07:52:48 -08:00
|
|
|
<a v-if="config.pronunciation.enabled && pronounce && pronoun.pronounceable && example.pronounce(pronoun)"
|
|
|
|
:href="pronunciationLink"
|
|
|
|
@click.prevent="pronounce">
|
|
|
|
<Icon v="volume"/>
|
|
|
|
</a>
|
2020-09-13 13:15:44 -07:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-11-28 07:52:48 -08:00
|
|
|
import { pronouns } from "~/src/data";
|
|
|
|
|
2020-09-13 13:15:44 -07:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
example: { required: true },
|
2020-11-10 15:47:44 -08:00
|
|
|
pronoun: { required: true },
|
2020-09-13 13:15:44 -07:00
|
|
|
counter: { default: 0 },
|
|
|
|
link: { type: Boolean },
|
2020-11-28 07:52:48 -08:00
|
|
|
pronunciation: { type: Boolean },
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
pronounce() {
|
|
|
|
const sound = new Audio(this.pronunciationLink);
|
|
|
|
sound.play();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
pronounBase() {
|
|
|
|
const name = this.pronoun.name();
|
|
|
|
for (let key in pronouns) {
|
|
|
|
if (!pronouns.hasOwnProperty(key)) { continue; }
|
|
|
|
if (key === name) {
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
for (let alias of pronouns[key].aliases) {
|
|
|
|
if (alias === name) {
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
pronounToString() {
|
|
|
|
return this.pronounBase && pronouns[this.pronounBase].equals(this.pronoun) ? this.pronounBase : this.pronoun.toString();
|
|
|
|
},
|
|
|
|
pronunciationLink() {
|
|
|
|
return `/api/pronounce/${this.pronounToString}?example=${encodeURIComponent(this.example.toString())}`;
|
|
|
|
}
|
2020-09-13 13:15:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|