Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app-localize-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
return function() {
var key = arguments[0];
if (!key || !resources || !language || !resources[language])
return;
return (key && this.useKeyIfMissing) ? key : undefined;

// Cache the key/value pairs for the same language, so that we don't
// do extra work if we're just reusing strings across an application.
Expand Down
16 changes: 16 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
</template>
</test-fixture>

<test-fixture id="missing-locale">
<template>
<x-translate use-key-if-missing></x-translate>
</template>
</test-fixture>
<script>
function getRequestsCache(elem) {
return elem.constructor.prototype.__localizationCache.requests;
Expand Down Expand Up @@ -167,6 +172,17 @@

assert.equal(app.localize('greeting'), undefined);
});

test('can handle missing keys and missing locale', function() {
var app = fixture('missing-locale');

assert.equal(app.language, 'en');
assert.equal(app.$.missing.innerHTML, 'missing');

app.language = 'bg';
assert.equal(app.language, 'bg');
assert.equal(app.$.missing.innerHTML, 'missing');
});
});

suite('external resources', function() {
Expand Down