Skip to content

Instantly share code, notes, and snippets.

@codesue
Last active April 6, 2019 16:22
Show Gist options
  • Save codesue/85e6bd6f4fb35d06e60c6e6d09bbe788 to your computer and use it in GitHub Desktop.
Save codesue/85e6bd6f4fb35d06e60c6e6d09bbe788 to your computer and use it in GitHub Desktop.
Localizing the open graph description tag in voice-web (Common Voice)

voice-web/web/index_template.html

<meta property="og:locale" content="en" />
<meta property="og:locale:alternate" content="sv-SE" />

voice-web/web/src/components/app.tsx

document.querySelector('meta[property="og:locale"]').setAttribute('content', mainLocale);
document.querySelector('meta[name="description"]').setAttribute('content', 'Hello!');
document.querySelector('meta[property="og:description"]').setAttribute('content', 'Hello, OG!');

voice-web/web/locale/en/messages.ftl

site-description = This is the English version of the site description.

voice-web/web/locale/sv-SE/messages.ftl

site-description = This is the Swedish version of the site description.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment