$translator =
new Translator('a', null,
$this->tmpDir
);
$translator->
setFallbackLocales(['b'
]);
$translator->
addLoader('array',
new ArrayLoader());
$translator->
addResource('array',
['foo' => 'foo (a)'
], 'a'
);
$translator->
addResource('array',
['foo' => 'foo (b)'
], 'b'
);
$translator->
addResource('array',
['bar' => 'bar (b)'
], 'b'
);
$translator->
addResource('array',
['baz' => 'baz (b)'
], 'b', 'messages+intl-icu'
);
$catalogue =
$translator->
getCatalogue('a'
);
$this->
assertFalse($catalogue->
defines('bar'
)); // Sure, the "a" catalogue does not contain that message.
$fallback =
$catalogue->
getFallbackCatalogue();
$this->
assertTrue($fallback->
defines('foo'
)); // "foo" is present in "a" and "b"
/*
* Now, repeat the same test.
* Behind the scenes, the cache is used. But that should not matter, right?
*/
$translator =
new Translator('a', null,
$this->tmpDir
);
$translator->
setFallbackLocales(['b'
]);