-
Notifications
You must be signed in to change notification settings - Fork 989
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): update translate library
- Loading branch information
Showing
53 changed files
with
645 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
"locales", | ||
"public/locales" | ||
], | ||
"i18n-ally.sourceLanguage": "en-US" | ||
"i18n-ally.sourceLanguage": "en" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { GetServerSideProps, GetStaticProps } from "next"; | ||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
|
||
const DefaultNamespaces = ["common", "nav"]; | ||
|
||
type GetTranslatedStaticProps = ( | ||
namespaces: string[], | ||
getStaticProps?: GetStaticProps<any> | ||
) => GetStaticProps; | ||
|
||
type GetTranslatedServerSideProps = ( | ||
namespaces: string[], | ||
getStaticProps?: GetServerSideProps<any> | ||
) => GetServerSideProps; | ||
|
||
export const getTranslatedStaticProps: GetTranslatedStaticProps = | ||
(namespaces, getStaticProps) => | ||
async ({ locale, ...context }) => { | ||
let staticProps = { props: {} }; | ||
if (typeof getStaticProps === "function") { | ||
staticProps = (await getStaticProps(context)) as any; | ||
} | ||
return { | ||
...staticProps, | ||
props: { | ||
...(await serverSideTranslations(locale ?? "en", [ | ||
...DefaultNamespaces, | ||
...namespaces, | ||
])), | ||
...staticProps.props, | ||
}, | ||
}; | ||
}; | ||
|
||
export const getTranslatedServerSideProps: GetTranslatedServerSideProps = | ||
(namespaces, getServerSideProps) => | ||
async ({ locale, ...context }) => { | ||
let staticProps = { props: {} }; | ||
if (typeof getServerSideProps === "function") { | ||
staticProps = (await getServerSideProps(context)) as any; | ||
} | ||
return { | ||
...staticProps, | ||
props: { | ||
...(await serverSideTranslations(locale ?? "en", [ | ||
...DefaultNamespaces, | ||
...namespaces, | ||
])), | ||
...staticProps.props, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.