mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-24 22:51:23 +08:00
Comments: Fixed pointer display, Fixed translation test
Some checks failed
test-js / build (push) Has been cancelled
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-migrations / build (8.4) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
test-php / build (8.4) (push) Has been cancelled
Some checks failed
test-js / build (push) Has been cancelled
analyse-php / build (push) Has been cancelled
lint-php / build (push) Has been cancelled
test-migrations / build (8.2) (push) Has been cancelled
test-migrations / build (8.3) (push) Has been cancelled
test-migrations / build (8.4) (push) Has been cancelled
test-php / build (8.2) (push) Has been cancelled
test-php / build (8.3) (push) Has been cancelled
test-php / build (8.4) (push) Has been cancelled
This commit is contained in:
@ -58,6 +58,11 @@ describe('Translations Service', () => {
|
||||
expect(caseB).toEqual('an orange angry big dinosaur');
|
||||
});
|
||||
|
||||
test('it provides count as a replacement by default', () => {
|
||||
const caseA = $trans.choice(`:count cats|:count dogs`, 4);
|
||||
expect(caseA).toEqual('4 dogs');
|
||||
});
|
||||
|
||||
test('not provided replacements are left as-is', () => {
|
||||
const caseA = $trans.choice(`An :a dog`, 5, {});
|
||||
expect(caseA).toEqual('An :a dog');
|
||||
|
@ -10,7 +10,7 @@ export class Translator {
|
||||
* to use. Similar format at Laravel's 'trans_choice' helper.
|
||||
*/
|
||||
choice(translation: string, count: number, replacements: Record<string, string> = {}): string {
|
||||
replacements = Object.assign({}, replacements, {count: String(count)});
|
||||
replacements = Object.assign({}, {count: String(count)}, replacements);
|
||||
const splitText = translation.split('|');
|
||||
const exactCountRegex = /^{([0-9]+)}/;
|
||||
const rangeRegex = /^\[([0-9]+),([0-9*]+)]/;
|
||||
|
Reference in New Issue
Block a user