-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// { title: "Fluxo de código", order: 3, compiler: { strictNullChecks: true } } | ||
|
||
// Como o código flui dentro de nossos arquivos JavaScript pode afetar | ||
// os tipos em nossos programas. | ||
|
||
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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
|
||
// No caso acima, 'find' pode falhar. Nesse caso, nós | ||
// não tem um objeto. Isso cria o tipo: | ||
// | ||
// { name: string } | undefined | ||
// | ||
// Se você passar o mouse sobre os três usos a seguir de 'joao' abaixo, | ||
// você verá como os tipos mudam dependendo de onde a palavra está localizada: | ||
|
||
if (joao) { | ||
joao | ||
} else { | ||
joao | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//// { title: 'Funções', order: 2, compiler: { noImplicitAny: false } } | ||
|
||
// Existem algumas maneiras de declarar uma função em | ||
// JavaScript. Vejamos uma função que adiciona dois | ||
// números juntos: | ||
|
||
// Cria a função @ no escopo global chamada modaAntiga | ||
function modaAntiga(x, y) { | ||
return x + y | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//// { title: 'Olá Mundo', order: 0, compiler: { target: 1 } } | ||
|
||
// Bem-vindo ao playground TypeScript. Este site é muito | ||
// como executar um projeto TypeScript dentro de um navegador da web. | ||
|
||
// O playground facilita para você experimentar com segurança | ||
// com idéias no TypeScript, facilitando o compartilhamento | ||
// esses projetos. O URL desta página é tudo | ||
// necessário para carregar o projeto para outra pessoa. | ||
|
||
const ola = 'Olá' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"sections": [ | ||
{ | ||
"name": "JavaScript", | ||
"id": "JavaScript", | ||
"subtitle": "Veja como o TypeScript aprimora o dia a dia trabalhando com JavaScript com uma sintaxe adicional mínima." | ||
}, | ||
{ | ||
"name": "TypeScript", | ||
"id": "TypeScript", | ||
"subtitle": "Explore como o TypeScript estende o JavaScript para adicionar mais segurança e ferramentas." | ||
}, | ||
{ | ||
"name": "3.7", | ||
"id": "3.7", | ||
"subtitle": "Consulte <a href='https://devblogs.microsoft.com/typescript/announcing-typescript-3-7/'>Notas da versão</a>." | ||
}, | ||
{ | ||
"name": "Playground", | ||
"id": "Playground", | ||
"subtitle": "Saiba o que mudou neste site." | ||
} | ||
], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
"sortedSubSections": [ | ||
// JS | ||
"JavaScript Essentials", | ||
"Functions with JavaScript", | ||
"Working With Classes", | ||
"Modern JavaScript", | ||
"External APIs", | ||
"Helping with JavaScript", | ||
// TS | ||
"Primitives", | ||
"Type Primitives", | ||
"Meta-Types", | ||
"Language", | ||
"Language Extensions", | ||
// Examples | ||
"Syntax and Messaging", | ||
"Types and Code Flow", | ||
"Fixits", | ||
// Playground | ||
"Config", | ||
"Tooling" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TSConfig SupportThese are the names of the category of compiler options, as well as an overview of the grouping. |
||
display: "Verificação de linter" | ||
--- | ||
|
||
Uma coleção de verificações extras, que ultrapassam um pouco os limites do compiler versus linter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
display: "Avançada" | ||
--- | ||
|
||
Opções que ajudam com |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
display: "Opções de projeto" | ||
--- | ||
|
||
Essas configurações são usadas para definir as expectativas de tempo de execução do seu projeto, como e onde você deseja que o JavaScript seja emitido e o nível de integração desejado com o código JavaScript existente. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
display: "Linha de comando" | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
display: "Experimental" | ||
--- | ||
|
||
O TypeScript se esforça para incluir apenas os recursos que foram confirmados para serem adicionados à linguagem JavaScript. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
display: "Module Resolution" | ||
--- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
display: "Inclusão de projeto" | ||
--- | ||
|
||
Essas configurações ajudam a garantir que o TypeScript escolha os arquivos certos. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
display: "Source Maps" | ||
--- | ||
|
||
Para fornecer ferramentas avançadas de depuração e relatórios de falhas que fazem sentido para os desenvolvedores, o TypeScript suporta a emissão de arquivos adicionais que estão em conformidade com os padrões do JavaScript Source Map |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
display: "Strict Checks" | ||
--- | ||
|
||
Recomendamos usar a opção [`strict`](#strict) para aceitar todas as melhorias possíveis à medida que elas são construídas. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
display: "Arquivos" | ||
oneline: "Incluir uma lista definida de arquivos, não suporta globs" | ||
--- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the docs for an individual tsconfig option: At the top it will still say files: Then further down it will show both this
|
||
|
||
Especifica uma lista de permissão de arquivos para incluir no programa. Ocorre um erro se algum dos arquivos não puder ser encontrado. | ||
|
||
```json | ||
{ | ||
"compilerOptions": {}, | ||
"files": [ | ||
"core.ts", | ||
"sys.ts", | ||
"types.ts", | ||
"scanner.ts", | ||
"parser.ts", | ||
"utilities.ts", | ||
"binder.ts", | ||
"checker.ts", | ||
"tsc.ts" | ||
] | ||
} | ||
``` | ||
|
||
Isso é útil quando você possui apenas um pequeno número de arquivos e não precisa usar um glob para fazer referência | ||
a muitos arquivos. Se você precisar, use [`include`](#include). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineMessages } from "react-intl" | ||
import { navCopy } from "./pt/nav" | ||
import { docCopy } from "./en/documentation" | ||
import { Copy } from "./en" | ||
|
||
export const lang: Copy = defineMessages({ | ||
...navCopy, | ||
...docCopy, | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 import { navCopy } from "./pt/nav" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { navCopy as enNavCopy } from "../en/nav" | ||
|
||
export const navCopy = { | ||
...enNavCopy, | ||
skip_to_content: "Pular para o conteúdo principal", | ||
nav_documentation: "Documentação", | ||
nav_documentation_short: "Documentos", | ||
nav_download: "Download", | ||
nav_connect: "Conectar", | ||
nav_playground: "Parque infantil", | ||
nav_search_placeholder: "Documentos de pesquisa", | ||
nav_search_aria: "Pesquise no site TypeScript", | ||
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>", | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
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.
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