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

Create an example PR which shows how to add a language #181

Closed
wants to merge 1 commit into from

Conversation

orta
Copy link
Contributor

@orta orta commented Jan 15, 2020

I'm not going to merge this PR (most of the translation was done via Google Translate) but this PR exists to show you a working example of adding a language to the TypeScript website:

I added the beginnings of Portuguese, click the images to go through to the PR deploy:

Screen Shot 2020-01-15 at 6 03 46 PM

Screen Shot 2020-01-15 at 6 04 10 PM

Will leave a review with inline info now

Copy link
Contributor Author

@orta orta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what some of these files are and how they interact

@@ -0,0 +1,23 @@
//// { title: "Fluxo de código", order: 3, compiler: { strictNullChecks: true } }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Playground support

The original file is "Code Flow.ts" which will override this file - in English the filename is the title, but you can change it to your own language

const users = [{ name: 'Ahmed' }, { name: 'Gemma' }, { name: 'João' }]

// Vamos ver se conseguimos encontrar um usuário chamado "João".
const joao = users.find(u => u.name === 'João')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched the code from "Jon" to "João" to fit the audience. I think some of this is good, but I would ask that you please keep a diverse set of names in the examples (gender / nationality is mainly what I strive for)

"id": "Playground",
"subtitle": "Saiba o que mudou neste site."
}
],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file dictates the name and metadata - given that the names were so small, it didn't really need changing

"Fixits",
// Playground
"Config",
"Tooling"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This uses filenames, so it might be redundant. In the future I might remove this from non-english to simplify translator's jobs.

@@ -0,0 +1,5 @@
---
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TSConfig Support

These are the names of the category of compiler options, as well as an overview of the grouping.

---
display: "Arquivos"
oneline: "Incluir uma lista definida de arquivos, não suporta globs"
---
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the docs for an individual tsconfig option: "files" - you can change the name here, but it will only change the header.

At the top it will still say files:

Screen Shot 2020-01-15 at 6 17 44 PM

Then further down it will show both this display, and the compiler flag name:
Screen Shot 2020-01-15 at 6 18 21 PM

oneline is used in the playground TSConfig reference, you should have one for every option though.

export const lang: Copy = defineMessages({
...navCopy,
...docCopy,
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we do language translation in the React side, you have an object which returns keys and values and you incrementally add new references. In this case only the navCopy comes from the pt subfolder instead of English.

import { navCopy } from "./pt/nav"

nav_beta: "Pesquise no site TypeScript",
nav_beta_notification:
"Nota: esta página é uma página beta, não confie nos problemas de URL e de arquivos <a>no microsoft/TypeScript-Website</a>",
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This object first fills with the English copy, then adds the Portuguese copy.

@github-actions

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant