Fix pluralization issues in translations

This commit is contained in:
Jamie Kyle 2023-04-04 12:05:50 -07:00 committed by GitHub
parent 808c0beae7
commit 9e28f4dbe0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 60 deletions

View file

@ -19,6 +19,7 @@ import noLegacyVariables from './rules/noLegacyVariables';
import noNestedChoice from './rules/noNestedChoice';
import noOffset from './rules/noOffset';
import noOrdinal from './rules/noOrdinal';
import pluralPound from './rules/pluralPound';
const RULES = [
icuPrefix,
@ -27,6 +28,7 @@ const RULES = [
noOffset,
noOrdinal,
onePlural,
pluralPound,
];
type Test = {
@ -65,6 +67,7 @@ type Report = {
id: string;
message: string;
location: Location | void;
locationOffset: number;
};
function lintMessage(
@ -76,8 +79,8 @@ function lintMessage(
for (const rule of rules) {
rule.run(elements, {
messageId,
report(message, location) {
reports.push({ id: rule.id, message, location });
report(message, location, locationOffset = 0) {
reports.push({ id: rule.id, message, location, locationOffset });
},
});
}
@ -151,11 +154,13 @@ async function lintMessages() {
const line =
icuMesssageLiteral.loc.start.line + (report.location.start.line - 1);
const column =
icuMesssageLiteral.loc.start.column + report.location.start.column;
icuMesssageLiteral.loc.start.column +
report.location.start.column +
report.locationOffset;
loc = `:${line}:${column}`;
} else if (icuMesssageLiteral.loc != null) {
const { line, column } = icuMesssageLiteral.loc.start;
loc = `:${line}:${column}`;
loc = `:${line}:${column + report.locationOffset}`;
}
// eslint-disable-next-line no-console