mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
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:
parent
4abebd8194
commit
82942b988d
1 changed files with 16 additions and 0 deletions
|
@ -75,5 +75,21 @@
|
||||||
});
|
});
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
</script>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue