Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create definition for Translate #372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
15 changes: 7 additions & 8 deletions packages/metastream-app/src/assets/homescreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<header id="tips" class="tips">
<button id="tipsbtn" class="tips-button">
<div class="column">
<b>📝 Tips for getting started</b>
<b>📝 {t('tipsGettingStarted1')}</b>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular file will be tricky. It didn't have translations because it's using plain HTML. Before translations can be easily supported, it will need to be converted to a React component with JSX markup.

This is possible, but I might not be able to get around to refactoring this during the week.

<svg
width="24"
viewBox="0 0 24 24"
Expand All @@ -102,24 +102,23 @@
</button>
<div class="tips-content">
<p class="column">
From here you can browse the web to find media to share in the session.
{t('tipsGettingStarted2')}
</p>

<ul class="column emoji-list">
<li>
<span class="emoji-bullet">🌐</span> Metastream supports many websites! Don't see one in
the list? Try adding the link anyway!
<span class="emoji-bullet">🌐</span> {t('tipsGettingStarted3')}
</li>
<li>
<span class="emoji-bullet">👥</span> Everyone in the session will need an account or subscription if required by a website.
<span class="emoji-bullet">👥</span> {t('tipsGettingStarted4')}
</li>
<li>
<span class="emoji-bullet">🐛</span> Is a website not working how you'd expect? Help us out by
<span class="emoji-bullet">🐛</span> {t('tipsGettingStarted5')}
<a
class="link"
href="https://github.com/samuelmaddock/metastream/issues"
target="_blank"
>reporting the issue on GitHub.</a
>{t('tipsGettingStarted6')}</a
>
</li>
</ul>
Expand Down Expand Up @@ -149,7 +148,7 @@
autocomplete="url"
spellcheck="false"
/>
<button id="addbtn" class="button uppercase">Add to Session</button>
<button id="addbtn" class="button uppercase">{t('homescreenRequestURL')}</button>
</div>
</section>
</main>
Expand Down
14 changes: 6 additions & 8 deletions packages/metastream-app/src/components/menu/MenuTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,20 @@ const WelcomeMessage: React.SFC = () => (
<>
<p>{t('welcomeMessage1')}</p>
<p>
This release is still in beta, so expect there to be some issues. If you come across any,
please{' '}
{t('welcomeMessage2')}{' '}
<ExternalLink href="https://github.com/samuelmaddock/metastream/issues">
submit a GitHub issue.
{t('welcomeMessage3')}
</ExternalLink>
</p>
<p>
If you&rsquo;d like to join in on the discussion, feel free to join the Discord community
using the link at the bottom of the screen.
{t('welcomeMessage4')}
</p>
<p>
And if you&rsquo;re coming from Rabbit,{' '}
{t('welcomeMessage5')}{' '}
<ExternalLink href="https://github.com/samuelmaddock/metastream/wiki/FAQ">
check out the FAQ
{t('welcomeMessage6')}
</ExternalLink>{' '}
to learn how Metastream differs.
{t('welcomeMessage7')}
Comment on lines +66 to +70
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For special cases like this where the markup is mixed in with the string, I use a special React component called <Trans>. Here's an example:

<Trans i18nKey="embedBlocked" values={{ host: mediaHostname }}>
To enable playback with <strong>this website</strong>, Metastream must open the
website in a popup.
</Trans>

And the actual translation string looks like this:

embedBlocked:
'To enable playback with <1>{{host}}</1>, Metastream must open the website in a popup.',

</p>
<p>💖 Sam</p>
</>
Expand Down
14 changes: 13 additions & 1 deletion packages/metastream-app/src/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default {
friendCode: 'Friend code',
getStarted: 'Get Started',
help: 'Help',
homescreenRequestURL: 'Add to Session',
info: 'Info',
installToDesktop: 'Install to desktop',
interact: 'Interact',
Expand Down Expand Up @@ -135,6 +136,12 @@ export default {
theaterModeDesc:
'Hide all non-video content on the webpage. Note that this might also hide soft subtitles.',
thirdPartyIntegrations: 'Third-party Integrations',
tipsGettingStarted1: 'Tips for getting started',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two things to note here:

  1. Lines that were broken into several lines can be merged into one string. CSS's layout engine will handle line wrapping for us.
  2. It might be best for semantics to describe the locale keys without using numbers. For example:
Suggested change
tipsGettingStarted1: 'Tips for getting started',
tipsGettingStartedHeader: 'Tips for getting started',

tipsGettingStarted2:'From here you can browse the web to find media to share in the session.',
tipsGettingStarted3: 'Metastream supports many websites! Don&#44;t see one in the list? Try adding the link anyway!',
tipsGettingStarted4: 'Everyone in the session will need an account or subscription if required by a website.',
tipsGettingStarted5: 'Is a website not working how you&#44;d expect? Help us out by',
tipsGettingStarted6: 'reporting the issue on GitHub.',
toggleDJ: 'Toggle DJ',
uiDockToRight: 'Dock to right side',
uiUndock: 'Undock into floating overlays',
Expand All @@ -153,5 +160,10 @@ export default {
welcome: 'Welcome',
welcomeToMetastream: 'Welcome to Metastream',
welcomeMessage1: 'Hi, thanks for trying out Metastream!',

welcomeMessage2: 'This release is still in beta, so expect there to be some issues. If you come across any, please',
welcomeMessage3: 'submit a GitHub issue.',
welcomeMessage4: 'If you&rsquo;d like to join in on the discussion, feel free to join the Discord community using the link at the bottom of the screen.',
welcomeMessage5: 'And if you&rsquo;re coming from Rabbit,',
welcomeMessage6: 'check out the FAQ',
welcomeMessage7: 'to learn how Metastream differs.'
}