mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Don't throw if translating before loading
Just return the passed string. This makes initialisation simpler, as a promise is unnecessary.
This commit is contained in:
@@ -67,6 +67,9 @@
|
||||
if (text === undefined) {
|
||||
return '';
|
||||
}
|
||||
if (this.jed === undefined) {
|
||||
return text;
|
||||
}
|
||||
const func = this.jed.translate(text);
|
||||
return func.fetch.apply(func, substitutions);
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ describe('Translator', () => {
|
||||
l10n = new loot.Translator();
|
||||
});
|
||||
|
||||
it('should throw if the translator has not been loaded', () => {
|
||||
(() => { l10n.translate('foo'); }).should.throw();
|
||||
it('should return original string if the translator has not been loaded', () => {
|
||||
l10n.translate('foo').should.equal('foo');
|
||||
});
|
||||
|
||||
it('should return an empty string if nothing is passed', () => {
|
||||
|
||||
Reference in New Issue
Block a user