-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
base: master
Are you sure you want to change the base?
Conversation
for "Welcome Message" in MenuTabs.tsx and "Tips for getting started" in homescreen.html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start! I need to make some changes first before these contributions can be accommodated though.
@@ -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> |
There was a problem hiding this comment.
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.
@@ -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', |
There was a problem hiding this comment.
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:
- Lines that were broken into several lines can be merged into one string. CSS's layout engine will handle line wrapping for us.
- It might be best for semantics to describe the locale keys without using numbers. For example:
tipsGettingStarted1: 'Tips for getting started', | |
tipsGettingStartedHeader: 'Tips for getting started', |
{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')} |
There was a problem hiding this comment.
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:
metastream/packages/metastream-app/src/components/Popup.tsx
Lines 366 to 369 in 1cd9f13
<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:
metastream/packages/metastream-app/src/locale/en-US.ts
Lines 48 to 49 in 1cd9f13
embedBlocked: | |
'To enable playback with <1>{{host}}</1>, Metastream must open the website in a popup.', |
for "Welcome Message" in MenuTabs.tsx
and "Tips for getting started" in homescreen.html.