fix: plural regex

pull/3205/head
Ryan Miller 7 months ago
parent 0900138d57
commit 3204211dbe
No known key found for this signature in database
GPG Key ID: 128C6E0A1246C6B3

@ -89,13 +89,13 @@ export type StringArgsRecord<T extends string> = Record<StringArgs<T>, string |
// Above is testing stuff
function getPluralKey<R extends PluralKey>(string: PluralString): R {
const match = /{(\w+), plural, one \[.+\] other \[.+\]}/g.exec(string);
const match = /{(\w+), plural, (zero|one|two|few|many|other) \[.+\]}/g.exec(string);
return match?.[1] as R;
}
// TODO This regex is only going to work for the one/other case what about other langs where we can have one/two/other for example
const isPluralForm = (localizedString: string): localizedString is PluralString =>
/{\w+, plural, one \[.+\] other \[.+\]}/g.test(localizedString);
/{(\w+), plural, (zero|one|two|few|many|other) \[.+\]}/g.test(localizedString);
/**
* Checks if a string contains a dynamic variable.

Loading…
Cancel
Save