Repository navigation
Class inheritance - #472
Conversation
…inheritance-rabbit-animal.svg
| "I love": | ||
| "text": "Eu amo" | ||
| "position": "center" | ||
| class-inheritance-rabbit-animal.svg: |
There was a problem hiding this comment.
O SVG class-inheritance-rabbit-animal.svg foi traduzido duas vezes: o texto foi editado direto no arquivo .svg e também foi adicionada esta entrada no images.yml. Como o SVG já não contém mais "methods of Animal", "methods of Rabbit" nem "properties of rabbit", as chaves desta entrada não batem com nada no arquivo, e a edição direta do SVG vai gerar conflito na próxima sincronização com o repositório original em inglês. O CLAUDE.md do projeto diz: "SVG text translations are defined in images.yml at repository root." Sugestão: reverter a alteração no .svg e manter só esta entrada no images.yml.
| @@ -1 +1 @@ | |||
| <svg xmlns="http://www.w3.org/2000/svg" width="198" height="258" viewBox="0 0 198 258"><defs><style>@import url(https://fonts.googleapis.com/css?family=Open+Sans:bold,italic,bolditalic%7CPT+Mono);@font-face{font-family:'PT Mono';font-weight:700;font-style:normal;src:local('PT MonoBold'),url(/font/PTMonoBold.woff2) format('woff2'),url(/font/PTMonoBold.woff) format('woff'),url(/font/PTMonoBold.ttf) format('truetype')}</style></defs><g id="inheritance" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="class-inheritance-rabbit-animal.svg"><path id="Rectangle-1" fill="#FBF2EC" stroke="#DBAF88" stroke-width="2" d="M11 128h179v28H11z"/><text id="methods-of-Rabbit" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="19" y="146">methods of Rabbit</tspan></text><text id="Rabbit.prototype" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="10" y="120">Rabbit.prototype</tspan></text><text id="rabbit" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="10" y="213">rabbit</tspan></text><path id="Rectangle-1" fill="#FBF2EC" stroke="#DBAF88" stroke-width="2" d="M11 21h179v28H11z"/><text id="methods-of-Animal" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="19" y="38">methods of Animal</tspan></text><text id="Animal.prototype" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="10" y="13">Animal.prototype</tspan></text><path id="Rectangle-1" fill="#FBF2EC" stroke="#DBAF88" stroke-width="2" d="M11 222h179v28H11z"/><path id="Line" fill="#C06334" fill-rule="nonzero" d="M70.5 167.5l7 14h-6v28h-2v-28h-6l7-14z"/><path id="Line-2" fill="#C06334" fill-rule="nonzero" d="M70.5 62.5l7 14h-6v28h-2v-28h-6l7-14z"/><text id="[[Prototype]]" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="80" y="86">[[Prototype]]</tspan></text><text id="[[Prototype]]-Copy" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="80" y="190">[[Prototype]]</tspan></text><text id="properties-of-rabbit" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="19" y="239">properties of rabbit</tspan></text></g></g></svg> No newline at end of file | |||
| <svg xmlns="http://www.w3.org/2000/svg" width="198" height="258" viewBox="0 0 198 258"><defs><style>@import url(https://fonts.googleapis.com/css?family=Open+Sans:bold,italic,bolditalic%7CPT+Mono);@font-face{font-family:'PT Mono';font-weight:700;font-style:normal;src:local('PT MonoBold'),url(/font/PTMonoBold.woff2) format('woff2'),url(/font/PTMonoBold.woff) format('woff'),url(/font/PTMonoBold.ttf) format('truetype')}</style></defs><g id="inheritance" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="class-inheritance-rabbit-animal.svg"><path id="Rectangle-1" fill="#FBF2EC" stroke="#DBAF88" stroke-width="2" d="M11 128h179v28H11z"/><text id="methods-of-Rabbit" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="19" y="146">métodos de Rabbit</tspan></text><text id="Rabbit.prototype" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="10" y="120">Rabbit.prototype</tspan></text><text id="rabbit" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="10" y="213">rabbit</tspan></text><path id="Rectangle-1" fill="#FBF2EC" stroke="#DBAF88" stroke-width="2" d="M11 21h179v28H11z"/><text id="methods-of-Animal" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="19" y="38">métodos de Animal</tspan></text><text id="Animal.prototype" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="10" y="13">Animal.prototype</tspan></text><path id="Rectangle-1" fill="#FBF2EC" stroke="#DBAF88" stroke-width="2" d="M11 222h179v28H11z"/><path id="Line" fill="#C06334" fill-rule="nonzero" d="M70.5 167.5l7 14h-6v28h-2v-28h-6l7-14z"/><path id="Line-2" fill="#C06334" fill-rule="nonzero" d="M70.5 62.5l7 14h-6v28h-2v-28h-6l7-14z"/><text id="[[Prototype]]" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="80" y="86">[[Prototype]]</tspan></text><text id="[[Prototype]]-Copy" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="80" y="190">[[Prototype]]</tspan></text><text id="properties-of-rabbit" fill="#AF6E24" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="11" y="239">propriedades de rabbit</tspan></text></g></g></svg> No newline at end of file | |||
There was a problem hiding this comment.
O texto "propriedades de rabbit" (22 caracteres em PT Mono 14px, ~8,4px por caractere, cerca de 185px) foi movido para x="11", mas o retângulo vai de x=11 a x=190. O texto começa em cima da borda esquerda e termina por volta de x=196, passando da borda direita. "métodos de Animal/Rabbit" cabem; este não. Além disso, nenhum artigo referencia este SVG (grep por class-inheritance-rabbit-animal.svg só encontra o próprio arquivo), então a tradução não aparece em lugar nenhum. Os SVGs que o artigo usa (rabbit-animal-independent-animal.svg, animal-rabbit-extends.svg, this-super-loop.svg, super-homeobject-wrong.svg) só têm código. Dá para reverter este arquivo.
| Como coelhos são animais, a classe `Rabbit` deveria ser baseada em `Animal`, ter acesso aos métodos de animal, para que coelhos possam fazer o que animais "genéricos" conseguem fazer. | ||
|
|
||
| The syntax to extend another class is: `class Child extends Parent`. | ||
| A sintaxe para estender outra classe é: `class Filha extends Pai`. |
There was a problem hiding this comment.
class Child extends Parent virou class Filha extends Pai, e o mesmo aconteceu no Resumo (linhas 688-693: Filha.prototype.__proto__, Pai.prototype, "construtor de Filha", "método de Pai"). Isso traduz nomes de classe dentro de código, e o CLAUDE.md do projeto diz: "Don't translate code: You should not translate variable or function names". Os gêneros também não combinam ("Filha" é feminino e "Pai" é masculino). Sugestão: manter Child/Parent dentro dos trechos de código e traduzir só o texto ao redor.
|
|
||
| ````smart header="Arrow functions have no `super`" | ||
| As was mentioned in the chapter <info:arrow-functions>, arrow functions do not have `super`. | ||
| ````smart header="Funções arrow não têm `super`" |
There was a problem hiding this comment.
"Funções arrow" (aqui, nas linhas 160 e 242 e no Resumo, linha 701) não segue o termo que o resto do tutorial já usa: 1-js/02-first-steps/17-arrow-functions-basics tem o título "Funções seta, o básico" e 1-js/06-advanced-functions/12-arrow-functions usa "Arrow Functions (funções seta)". O CLAUDE.md também pede "avoid using foreign words". Sugestão: usar "funções seta" em todo o artigo.
| @@ -611,17 +611,17 @@ rabbit.eat(); // Error calling super (because there's no [[HomeObject]]) | |||
| */!* | |||
There was a problem hiding this comment.
Na linha 610, logo acima, o comentário // Error calling super (because there's no [[HomeObject]]) ficou em inglês. Diferente de // Unexpected super, que é a mensagem real do motor, a parte entre parênteses é uma explicação e deveria ser traduzida, por exemplo: // Erro ao chamar super (porque não existe [[HomeObject]]).
| # Relógio estendido | ||
|
|
||
| We've got a `Clock` class. As of now, it prints the time every second. | ||
| Temos uma classe `Clock`. Até agora, ela imprime a hora a cada segundo. |
There was a problem hiding this comment.
"As of now" quer dizer "atualmente/por enquanto". "Até agora" passa a ideia de que algo vai mudar ou já mudou.
| Temos uma classe `Clock`. Até agora, ela imprime a hora a cada segundo. | |
| Temos uma classe `Clock`. Por enquanto, ela imprime a hora a cada segundo. |
| [js src="source.view/clock.js"] | ||
|
|
||
| Create a new class `ExtendedClock` that inherits from `Clock` and adds the parameter `precision` -- the number of `ms` between "ticks". Should be `1000` (1 second) by default. | ||
| Crie uma nova classe `ExtendedClock` que herda de `Clock` e adiciona o parâmetro `precision` -- o número de `ms` entre os "ticks". Deve ser `1000` (1 segundo) por padrão. |
There was a problem hiding this comment.
"ticks" ficou em inglês. O CLAUDE.md do projeto pede "avoid using foreign words". Sugestão: "tiques" (ou "batidas").
| class Rabbit extends Animal { | ||
| stop() { | ||
| setTimeout(() => super.stop(), 1000); // call parent stop after 1sec | ||
| setTimeout(() => super.stop(), 1000); // chama o stop do pai depois de 1seg |
There was a problem hiding this comment.
"1seg" não é uma abreviação padrão (o símbolo do SI é "s").
| setTimeout(() => super.stop(), 1000); // chama o stop do pai depois de 1seg | |
| setTimeout(() => super.stop(), 1000); // chama o stop do pai depois de 1 segundo |
…ild/Parent untranslated
|
Obrigado pela revisão detalhada, @gabifs! Revertei o SVG editado à mão e removi a entrada órfã do |
Tradução do artigo "Class inheritance" para o português, incluindo os 2 exercícios e a tradução do diagrama class-inheritance-rabbit-animal.svg.
Conforme comentado na #1.