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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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


// 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')
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)


// 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
}
@@ -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
}
@@ -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á'
47 changes: 47 additions & 0 deletions packages/playground-examples/copy/pt/sections.json
@@ -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."
}
],
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


"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"
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: "Verificação de linter"
---

Uma coleção de verificações extras, que ultrapassam um pouco os limites do compiler versus linter
@@ -0,0 +1,5 @@
---
display: "Avançada"
---

Opções que ajudam com
@@ -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.
@@ -0,0 +1,3 @@
---
display: "Linha de comando"
---
@@ -0,0 +1,5 @@
---
display: "Experimental"
---

O TypeScript se esforça para incluir apenas os recursos que foram confirmados para serem adicionados à linguagem JavaScript.
@@ -0,0 +1,3 @@
---
display: "Module Resolution"
---
@@ -0,0 +1,5 @@
---
display: "Inclusão de projeto"
---

Essas configurações ajudam a garantir que o TypeScript escolha os arquivos certos.
@@ -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
@@ -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.
26 changes: 26 additions & 0 deletions packages/tsconfig-reference/copy/pt/options/files.md
@@ -0,0 +1,26 @@
---
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.


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).
9 changes: 9 additions & 0 deletions packages/typescriptlang-org/src/copy/pt.ts
@@ -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,
})
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"

16 changes: 16 additions & 0 deletions packages/typescriptlang-org/src/copy/pt/nav.ts
@@ -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>",
}
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.