-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add translation switcher to website #284
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
71dae96
feat: add translation switcher to website
3w36zj6 14d0c9c
Update website/src/translation/en-US.tsx
3w36zj6 dc5c2cf
Update website/src/translation/en-US.tsx
3w36zj6 50c459f
Update website/src/translation/en-US.tsx
3w36zj6 c7a598a
Update website/src/translation/en-US.tsx
3w36zj6 7e8de2c
docs: apply suggestions
3w36zj6 f44f181
docs: add footer to translation
3w36zj6 fdee3d0
Update website/src/translation/en-US.tsx
3w36zj6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,205 @@ | ||
| import type { TooltipProps } from "../components/ui/Tooltip"; | ||
| import { githubOrganizationUrl } from "../metadata"; | ||
| import type { TranslationComponent, TranslationObject } from "./"; | ||
|
|
||
| export const translation: TranslationObject = { | ||
| htmlLang: () => "en", | ||
| documentationTitle: () => "Typst Documentation (English)", | ||
| close: () => "Close", | ||
| closeMenu: () => "Close menu", | ||
| closeSearch: () => "Close search", | ||
| openMenu: () => "Open menu", | ||
| openSearch: () => "Open search", | ||
| showInformation: (props: { name: string }) => | ||
| `Show details for ${props.name}`, | ||
| tooltipKind: (props: { kind: TooltipProps["kind"] }) => { | ||
| switch (props.kind) { | ||
| case "element": | ||
| return "Element"; | ||
| case "contextual": | ||
| return "Contextual"; | ||
| case "definitions": | ||
| return "Definition"; | ||
| case "parameters": | ||
| return "Parameter"; | ||
| case "variadic": | ||
| return "Variadic"; | ||
| case "settable": | ||
| return "Settable"; | ||
| case "positional": | ||
| return "Positional"; | ||
| case "required": | ||
| return "Required"; | ||
| default: | ||
| return props.kind; | ||
| } | ||
| }, | ||
| } as const; | ||
|
|
||
| export const Translation: TranslationComponent = (props) => { | ||
| switch (props.translationKey) { | ||
| case "definition": | ||
| return <>Definition</>; | ||
| case "constructor": | ||
| return <>Constructor</>; | ||
| case "definitionOf": | ||
| return ( | ||
| <> | ||
| <code>{props.name}</code> Definition | ||
| </> | ||
| ); | ||
| case "search": | ||
| return <>Search</>; | ||
| case "defaultValue": | ||
| return <>Default value:</>; | ||
| case "stringValues": | ||
| return <>Available string values:</>; | ||
| case "showExample": | ||
| return <>Show example</>; | ||
| case "tableOfContents": | ||
| return <>On this page</>; | ||
| case "nextPage": | ||
| return <>Next page</>; | ||
| case "previousPage": | ||
| return <>Previous page</>; | ||
| case "referenceDescription": | ||
| return ( | ||
| <> | ||
| Detailed reference for all Typst syntax, concepts, types, and | ||
| functions. | ||
| </> | ||
| ); | ||
| case "tutorialDescription": | ||
| return <>Learn how to use Typst step by step.</>; | ||
| case "tutorial": | ||
| return <>Tutorial</>; | ||
| case "openOfficialDocs": | ||
| return <>Open official docs</>; | ||
| case "reference": | ||
| return <>Reference</>; | ||
| case "typstOfficialDocs": | ||
| return <>Typst official docs</>; | ||
| case "typstOfficialWebsite": | ||
| return <>Typst official website</>; | ||
| case "untranslated": | ||
| return <>Untranslated</>; | ||
| case "untranslatedMessage": | ||
| return ( | ||
| <> | ||
| This page has not been translated yet. The original content is shown. | ||
| </> | ||
| ); | ||
| case "communityContent": | ||
| return <>Community original content</>; | ||
| case "contentAddedByCommunity": | ||
| return ( | ||
| <> | ||
| This page contains content that is not part of the official | ||
| documentation, added independently by the community. | ||
| </> | ||
| ); | ||
| case "partiallyTranslated": | ||
| return <>Partially translated</>; | ||
| case "partiallyTranslatedMessage": | ||
| return ( | ||
| <> | ||
| This page is partially translated. Some original content is included. | ||
| </> | ||
| ); | ||
| case "translated": | ||
| return <>Translated</>; | ||
| case "translatedMessage": | ||
| return <>This page has been translated into English.</>; | ||
| case "elementFunction": | ||
| return <>Element</>; | ||
| case "elementFunctionDescription": | ||
| return ( | ||
| <> | ||
| Element functions can be customized with <code>set</code> and{" "} | ||
| <code>show</code> rules. | ||
| </> | ||
| ); | ||
| case "contextFunction": | ||
| return <>Context</>; | ||
| case "contextFunctionDescription": | ||
| return <>Context functions can only be used when the context is known.</>; | ||
| case "definitionTooltip": | ||
| return <>Definition</>; | ||
| case "definitionTooltipDescription": | ||
| return ( | ||
| <> | ||
| These functions and types can have related definitions. To access a | ||
| definition, specify the name of the function or type, followed by the | ||
| definition name separated by a period. | ||
| </> | ||
| ); | ||
| case "argument": | ||
| return <>Parameter</>; | ||
| case "argumentDescription": | ||
| return ( | ||
| <> | ||
| Parameters are input values for functions. Specify them in parentheses | ||
| after the function name. | ||
| </> | ||
| ); | ||
| case "variadic": | ||
| return <>Variadic</>; | ||
| case "variadicDescription": | ||
| return <>Variadic parameters can be specified multiple times.</>; | ||
| case "positional": | ||
| return <>Positional</>; | ||
| case "positionalDescription": | ||
| return ( | ||
| <> | ||
| Positional parameters can be set by specifying them in order, omitting | ||
| the parameter name. | ||
| </> | ||
| ); | ||
| case "required": | ||
| return <>Required</>; | ||
| case "requiredDescription": | ||
| return ( | ||
| <>Required parameters must be specified when calling the function.</> | ||
| ); | ||
| case "document": | ||
| return <>Document</>; | ||
| case "langVersion": | ||
| return <>English</>; | ||
| case "translationRate": | ||
| return <>Translated</>; | ||
| case "settable": | ||
| return <>Settable</>; | ||
| case "settableDescription": | ||
| return ( | ||
| <> | ||
| Settable parameters can be set using the <code>set</code> rule, | ||
| changing the default value used thereafter. | ||
| </> | ||
| ); | ||
| case "siteNoticeBannerTitle": | ||
| return <>Info</>; | ||
| case "siteNoticeBannerDescription": | ||
| return ( | ||
| <> | ||
| This site is generated using the static site generator developed by | ||
| the <a href="https://github.com/typst-community">Typst Community</a>. | ||
| Please adjust the text content of this banner according to your usage | ||
| requirements. At Typst GmbH's request, when publishing documentation, | ||
| you must clearly indicate that it is non-official and display the | ||
| version of Typst being documented. For details, refer to{" "} | ||
| <a href="https://github.com/typst/typst/issues/874#issuecomment-2273854138"> | ||
| Issue #874 on typst/typst | ||
| </a> | ||
| . | ||
| </> | ||
| ); | ||
| case "footer": | ||
| return ( | ||
| <> | ||
| Translated by <a href={githubOrganizationUrl}>Typst Community</a> | ||
| </> | ||
| ); | ||
| default: | ||
| return null; | ||
| } | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The message 'This page has been translated into English' is misleading for an English translation file. Since this is the English version, it should indicate the page is in English or original content, not that it was translated into English.
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.
I also find this a bit odd, but in the first place, the original (English) version shouldn’t need to display translation status, nor should it. Since
en-US.tsxis just a sample for i18n support, I think it’s fine to leave it as is.