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

Add i18n support to all text #156

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
52 changes: 51 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,55 @@
"title": "Welcome, streamer",
"description": "Unlock the Ultimate Dota 2 Streaming Experience with Dotabod! Boost your stream's engagement, showcase real-time stats, and delight your audience with our all-in-one streaming toolkit. Elevate your game and become the streamer you were meant to be!"
},
"live": "Live"
"live": "Live",
"button": {
"getStarted": "Get started",
"goToDashboard": "Go to dashboard",
"joinDiscord": "Join Discord"
},
"languageCard": {
"title": "Language",
"subtitle": "The @dotabod Twitch chat bot will speak in this language.",
"usedBy": "Used by",
"dotabods": "dotabods",
"percentTranslated": "% translated",
"onlyOneUsing": "You're the only one using this language",
"helpComplete": "Help complete on Crowdin",
"fixLocaleIssues": "Fix locale issues on Crowdin"
},
"dashboard": {
"setup": {
"title": "Setup",
"subtitle": "Let's get Dotabod working for you right away",
"twitch": "Twitch",
"dota2": "Dota 2",
"obs": "OBS",
"allDone": "All done!",
"streamOfflineWarning": "Your stream is offline, and Dotabod will only work once you start streaming and go online.",
"thatsIt": "That's it! You're all set up.",
"hopIntoMatch": "You can either hop into a match right away, or you can test Dotabod first.",
"howToTest": "How to test Dotabod",
"demoHeroStep": "Demo any hero to get Dotabod to recognize your Steam account.",
"livePreviewStep": "While demoing, visit the Live Preview page to confirm the overlay is showing.",
"troubleshootingStep": "Having trouble? Visit the Troubleshooting page to get help."
},
"features": {
"main": {
"title": "Main features",
"subtitle": "Customize the options your stream receives."
},
"advanced": {
"title": "Advanced features",
"subtitle": "Looking for even more? They'll be here"
},
"chat": {
"title": "Chat features",
"subtitle": "The bot reacts with chat messages to your game events as you play your match."
},
"overlay": {
"title": "Overlay features",
"subtitle": "Enhance your stream with these overlay features"
}
}
}
}
10 changes: 8 additions & 2 deletions src/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import clsx from 'clsx'
import Link from 'next/link'
import { forwardRef } from 'react'
import { useTranslation } from 'next-i18next'

const baseStyles = {
solid:
Expand All @@ -25,15 +26,20 @@ export const Button = forwardRef(function Button(
{ variant = 'solid', color = 'gray', className, href, ...props },
ref
) {
const { t } = useTranslation('common')
className = clsx(
baseStyles[variant],
variantStyles[variant][color],
className
)

return href ? (
<Link ref={ref} href={href} className={className} {...props} />
<Link ref={ref} href={href} className={className} {...props}>
{t(props.children)}
</Link>
) : (
<button ref={ref} className={className} {...props} />
<button ref={ref} className={className} {...props}>
{t(props.children)}
</button>
)
})
5 changes: 4 additions & 1 deletion src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import clsx from 'clsx'
import { useTranslation } from 'next-i18next'

export const Card = ({ children = null, className = '', ...props }) => {
const { t } = useTranslation('common')

return (
<div
className={clsx(
Expand All @@ -9,7 +12,7 @@ export const Card = ({ children = null, className = '', ...props }) => {
)}
{...props}
>
{children}
{t(children)}
</div>
)
}
Loading