mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
fix(rewrite): Use Math.min
instead of max
, remove logs
This commit is contained in:
parent
bc2abe50fa
commit
e854a89303
@ -363,24 +363,31 @@ export class Locale {
|
|||||||
thirdMorphemeThreeForms = thirdMorpheme.map((x) => `[-${x}]`);
|
thirdMorphemeThreeForms = thirdMorpheme.map((x) => `[-${x}]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let istr in firstMorpheme) {
|
for (let i = 0; i < firstMorpheme.length; i++) {
|
||||||
const i = istr as unknown as number;
|
|
||||||
let firstPart = firstMorpheme[i];
|
let firstPart = firstMorpheme[i];
|
||||||
let secondPart =
|
let secondPart =
|
||||||
secondMorpheme[Math.max(i, secondMorpheme.length - 1)];
|
secondMorpheme[Math.min(i, secondMorpheme.length - 1)];
|
||||||
if (
|
if (
|
||||||
firstPart === secondPart &&
|
firstPart === secondPart &&
|
||||||
thirdMorpheme.length &&
|
thirdMorpheme.length &&
|
||||||
!this.config.pronouns.threeForms
|
!this.config.pronouns.threeForms
|
||||||
) {
|
) {
|
||||||
secondPart =
|
secondPart =
|
||||||
thirdMorpheme[Math.max(i, thirdMorpheme.length - 1)];
|
thirdMorpheme[Math.min(i, thirdMorpheme.length - 1)];
|
||||||
}
|
}
|
||||||
let variant = firstPart + "/" + secondPart;
|
let variant = firstPart + "/" + secondPart;
|
||||||
if (this.config.pronouns.threeForms) {
|
if (this.config.pronouns.threeForms) {
|
||||||
variant += "/" + thirdMorphemeThreeForms[i];
|
variant +=
|
||||||
|
"/" +
|
||||||
|
thirdMorphemeThreeForms[
|
||||||
|
Math.min(i, thirdMorphemeThreeForms.length - 1)
|
||||||
|
];
|
||||||
} else if (pronoun.thirdForm) {
|
} else if (pronoun.thirdForm) {
|
||||||
variant += "/" + thirdFormMorpheme[i];
|
variant +=
|
||||||
|
"/" +
|
||||||
|
thirdFormMorpheme[
|
||||||
|
Math.min(i, thirdFormMorpheme.length - 1)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
variants.add(variant);
|
variants.add(variant);
|
||||||
|
@ -77,7 +77,7 @@ export const plugin = async function (app: AppInstance) {
|
|||||||
let found = locale.pronoun(key);
|
let found = locale.pronoun(key);
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
found = parsePronounFromParts(keyParts, locale.morphemes);
|
found = parsePronounFromParts(keyParts, locale.morphemes);
|
||||||
req.log.info(`${JSON.stringify(keyParts)} - ${found}`);
|
// req.log.info(`${JSON.stringify(keyParts)} - ${found}`);
|
||||||
}
|
}
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
return replyError(reply, ApiError.UNKNOWN_PRONOUN);
|
return replyError(reply, ApiError.UNKNOWN_PRONOUN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user