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']">
|
2021-03-06 10:54:40 -08:00
|
|
|
<strong v-if="part.variable"><Spelling :text="pronoun.getMorpheme(part.str, counter)"/></strong>
|
2021-03-19 12:34:34 -07:00
|
|
|
<span v-else><Spelling :text="part.str"/></span>
|
2020-09-13 13:15:44 -07:00
|
|
|
</span>
|
|
|
|
<small v-if="link">
|
2021-03-09 07:36:17 -08:00
|
|
|
(<nuxt-link :to="'/' + pronoun.canonicalName"><Spelling :text="pronoun.canonicalName"/></nuxt-link>)
|
2020-09-13 13:15:44 -07:00
|
|
|
</small>
|
2020-12-21 05:04:12 -08:00
|
|
|
<template v-if="config.pronunciation.enabled && pronounce && pronoun.pronounceable && example.pronounce(pronoun)">
|
|
|
|
<a v-for="(link, name) in pronunciationLinks"
|
|
|
|
class="mr-2"
|
|
|
|
:href="link"
|
|
|
|
@click.prevent="pronounce(link)">
|
|
|
|
<Icon v="volume"/><sub v-if="name">{{name}}</sub>
|
|
|
|
</a>
|
|
|
|
</template>
|
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: {
|
2020-12-21 05:04:12 -08:00
|
|
|
pronounce(link) {
|
|
|
|
const sound = new Audio(link);
|
2020-11-28 07:52:48 -08:00
|
|
|
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();
|
|
|
|
},
|
2020-12-21 05:04:12 -08:00
|
|
|
pronunciationLinks() {
|
|
|
|
const justOne = Object.keys(this.config.pronunciation.voices).length === 1;
|
|
|
|
|
|
|
|
const links = {};
|
|
|
|
for (let country in this.config.pronunciation.voices) {
|
|
|
|
if (!this.config.pronunciation.voices.hasOwnProperty(country)) { continue; }
|
|
|
|
links[justOne ? '' : country] = `/api/pronounce/${country}/${this.pronounToString}?example=${encodeURIComponent(this.example.toString())}`;
|
|
|
|
}
|
|
|
|
return links;
|
2020-11-28 07:52:48 -08:00
|
|
|
}
|
2020-09-13 13:15:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|