Localize title of page after strings load

This doesn't solve the issue of making it crawlable in other languages, but it does allow the title to be translatable for user parsing (and accessibility)
This commit is contained in:
Matthew Taylor 2016-05-16 10:55:51 -04:00
parent 4abebd8194
commit 82942b988d

View file

@ -75,5 +75,21 @@
});
ga('send', 'pageview');
</script>
<!-- translate title element -->
<script>
var loc = window._locale || 'en';
if (typeof window._messages !== 'undefined' && loc !== 'en') {
if (typeof window._messages[loc] === 'undefined') {
loc = loc.split('-')[0];
}
if (typeof window._messages[loc] !== 'undefined') {
var localizedTitle = window._messages[loc]['general.' + '{{title}}'.toLowerCase()] || '';
if (localizedTitle.length > 0) {
document.title = 'Scratch - ' + localizedTitle;
}
}
}
</script>
</body>
</html>