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:
Oliver Hamlet
2016-01-06 18:27:01 +00:00
parent f0df5e707f
commit 3e51af2cc5
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -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);
}
+2 -2
View File
@@ -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', () => {