Skip to content

Commit

Permalink
refactor: migrate components/translation.js to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
byhow committed Jun 3, 2022
1 parent 207b078 commit 4efc65e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react"
import { FormattedHTMLMessage } from "gatsby-plugin-intl"
import { getDefaultMessage } from "../utils/translations"
import { getDefaultMessage, TranslationKey } from "../utils/translations"

// Wrapper on <FormattedMessage /> to always fallback to English
// Use this component for any user-facing string
const Translation = ({ id }) => (
const Translation = ({ id }: { id: TranslationKey }) => (
<FormattedHTMLMessage id={id} defaultMessage={getDefaultMessage(id)} />
)

Expand Down
2 changes: 1 addition & 1 deletion src/utils/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Lang } from "./languages"

import defaultStrings from "../intl/en.json"

type TranslationKey = keyof typeof defaultStrings
export type TranslationKey = keyof typeof defaultStrings

const consoleError = (message: string): void => {
const { NODE_ENV } = process.env
Expand Down

0 comments on commit 4efc65e

Please sign in to comment.