Skip to content

Commit b9a63c9

Browse files
authored
Merge branch 'mayconblopes:ptbr-translation' into ptbr-translation
2 parents c70daeb + f22fc71 commit b9a63c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5888
-237
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,6 @@ yarn-error.log
7070
.yarn-integrity
7171

7272

73-
.nvmrc
73+
.nvmrc
74+
.vscode/settings.json
75+
package-lock.json

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
1. Prettify your code with `npm run format`
1313
2. Create a new branch for your changes
1414
3. Create the PR from that branch to the source branch
15+
16+
# Contributing with translations
17+
When translation of a whole new part is completed, remember to update the file src/utils/translationProgress.json

src/components/PartBanner/PartBanner.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import translationProgress from '../../utils/translationProgress'
12
import { Banner } from '../Banner/Banner';
23
import { ContentLiftup } from '../ContentLiftup/ContentLiftup';
34
import React from 'react';
@@ -92,14 +93,8 @@ export const PartBanner = ({ lang }) => {
9293
const parts = Object.keys(navigation[lang]);
9394

9495
function partName(lang) {
95-
return lang === 'fi' ? 'Osa' : lang==='ptbr' ? 'Parte' : 'Part'
96-
// if (lang === 'fi') {
97-
// return 'Osa'
98-
// } else if (lang === 'ptbr') {
99-
// return 'Parte'
100-
// } else {
101-
// return 'Part'
102-
}
96+
return lang === 'fi' ? 'Osa' : lang === 'ptbr' ? 'Parte' : 'Part';
97+
}
10398

10499
return (
105100
<Banner
@@ -108,9 +103,10 @@ export const PartBanner = ({ lang }) => {
108103
>
109104
<div className="container spacing flex-fix-aligning col-7--mobile">
110105
{parts.map(part => {
111-
const partNames =
112-
partNameTranslations[lang] || partNameTranslations.en;
106+
const partNames =
107+
partNameTranslations[lang] || partNameTranslations.en
113108

109+
const summary = translationProgress[lang] < part ? partNames[part] + ' (english only)' : partNames[part]
114110
return (
115111
<ContentLiftup
116112
key={partNames[part]}
@@ -120,9 +116,8 @@ export const PartBanner = ({ lang }) => {
120116
alt: partNames[part],
121117
}}
122118
hoverImageSrc={require(`../../images/thumbnails/part-${part}_ovr.svg`)}
123-
// name={`${lang === 'fi' ? 'Osa' : 'Part'} ${part}`}
124119
name={`${partName(lang)} ${part}`}
125-
summary={partNames[part]}
120+
summary={summary}
126121
path={getPartTranslationPath(lang, part)}
127122
/>
128123
);

src/components/PrevNext/PrevNext.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import './PrevNext.scss';
22

3+
import translationProgress from '../../utils/translationProgress'
34
import Element from '../Element/Element';
45
import { Link } from 'gatsby';
56
import { PropTypes } from 'prop-types';
@@ -106,7 +107,9 @@ const PrevNext = ({ part, letter, lang }) => {
106107

107108
const getNext = () => {
108109
if (!letter && hasPart(part + 1, lang)) {
109-
console.log('a', hasPart(part + 1, lang))
110+
if (translationProgress[lang] <= part) {
111+
lang = 'en'
112+
}
110113
return (
111114
<Link
112115
to={`${langUrl(lang)}${part + 1}`}

src/content/0/en/part0a.md

Lines changed: 30 additions & 30 deletions
Large diffs are not rendered by default.

src/content/0/en/part0b.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Open the [example application](https://studies.cs.helsinki.fi/exampleapp) in you
1717

1818
The course material is done with the Chrome browser.
1919

20-
**The 1st rule of web development**: Always keep the Developer Console open on your web browser. On macOS, open the console by pressing _F12_ or _option-cmd-i_ simultaneously. On Windows or Linux, open the console by pressing _F12_ or _ctrl-shift-i_ simultaneously. The console can also be opened via the [context menu](https://en.wikipedia.org/wiki/Menu_key).
20+
**The 1st rule of web development**: Always keep the Developer Console open on your web browser. On macOS, open the console by pressing _fn_-_F12_ or _option-cmd-i_ simultaneously. On Windows or Linux, open the console by pressing _Fn_-_F12_ or _ctrl-shift-i_ simultaneously. The console can also be opened via the [context menu](https://en.wikipedia.org/wiki/Menu_key).
2121

2222
Remember to <i>always</i> keep the Developer Console open when developing web applications.
2323

@@ -33,7 +33,7 @@ Make sure that the <i>Network</i> tab is open, and check the <i>Disable cache</i
3333

3434
The server and the web browser communicate with each other using the [HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP) protocol. The <i>Network</i> tab shows how the browser and the server communicate.
3535

36-
When you reload the page (press the F5 key or the &#8635; symbol on your browser), the console will show that two events have happened:
36+
When you reload the page (To refresh a webpage, on windows, press the _Fn_-_F5_ keys. On macOS, press _command_-_R_. Or press the &#8635; symbol on your browser), the console will show that two events have happened:
3737

3838
- The browser has fetched the contents of the page <i>studies.cs.helsinki.fi/exampleapp</i> from the server
3939
- And has downloaded the image <i>kuva.png</i>
@@ -66,7 +66,7 @@ Because of the img tag, the browser does a second <i>HTTP request</i> to fetch t
6666

6767
The request was made to the address <https://studies.cs.helsinki.fi/exampleapp/kuva.png> and its type is HTTP GET. The response headers tell us that the response size is 89350 bytes, and its [Content-type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) is <i>image/png</i>, so it is a png image. The browser uses this information to render the image correctly to the screen.
6868

69-
The chain of events caused by opening the page <https://studies.cs.helsinki.fi/exampleapp> on a browser form the following [sequence diagram](https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/):
69+
The chain of events caused by opening the page <https://studies.cs.helsinki.fi/exampleapp> on a browser forms the following [sequence diagram](https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/):
7070

7171
![Sequence diagram of the flow covered above](../../images/0/7m.png)
7272

@@ -112,13 +112,13 @@ app.get('/', (req, res) => {
112112

113113
You don't have to understand the code just yet.
114114

115-
The content of the HTML page has been saved as a template string or a string that allows for evaluating, for example, variables in the midst of it. The dynamically changing part of the homepage, the number of saved notes (in the code <em>noteCount</em>), is replaced by the current number of notes (in the code <em>notes.length</em>) in the template string.
115+
The content of the HTML page has been saved as a template string or a string that allows for evaluating, for example, variables, like <em>noteCount</em>, in the midst of it. The dynamically changing part of the homepage, the number of saved notes (in the code <em>noteCount</em>), is replaced by the current number of notes (in the code <em>notes.length</em>) in the template string.
116116

117117
Writing HTML amid the code is of course not smart, but for old-school PHP programmers, it was a normal practice.
118118

119119
In traditional web applications, the browser is "dumb". It only fetches HTML data from the server, and all application logic is on the server. A server can be created using [Java Spring](https://spring.io/projects/spring-framework) , [Python Flask](https://flask.palletsprojects.com/en/2.2.x/) or [Ruby on Rails](http://rubyonrails.org/) to name just a few examples.
120120

121-
The example uses [Express](https://expressjs.com/) library with the Node.js. This course will use Node.js and Express to create web servers.
121+
The example uses [Express](https://expressjs.com/) library with Node.js. This course will use Node.js and Express to create web servers.
122122

123123
### Running application logic in the browser
124124

@@ -164,7 +164,7 @@ xhttp.send()
164164

165165
The details of the code are not important right now, but some code has been included to spice up the images and the text. We will properly start coding in [part 1](/en/part1). The sample code in this part is actually not relevant at all to the coding techniques of this course.
166166

167-
> Some might wonder why xhttp-object is used instead of the modern fetch. This is due to not wanting to go into promises at all yet, and the code having a secondary role in this part. We will return to modern ways to make requests to the server in part 2.
167+
> Some might wonder why xhttp-object is used instead of the modern fetch. This is due to not wanting to go into promises at all yet, and the code having a secondary role in this part. We will return to modern ways to make requests to the server in [part 2](/en/part2).
168168
169169
Immediately after fetching the <i>script</i> tag, the browser begins to execute the code.
170170

@@ -381,7 +381,7 @@ The file defines two [class selectors](https://developer.mozilla.org/en-US/docs/
381381
382382
A class selector definition always starts with a period and contains the name of the class.
383383
384-
The classes are [attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class), which can be added to HTML elements.
384+
Classes are [attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class), which can be added to HTML elements.
385385
386386
CSS attributes can be examined on the <i>elements</i> tab of the console:
387387
@@ -391,7 +391,7 @@ The outermost <i>div</i> element has the class <i>container</i>. The <i>ul</i> e
391391
392392
The CSS rule defines that elements with the <i>container</i> class will be outlined with a one-pixel wide [border](https://developer.mozilla.org/en-US/docs/Web/CSS/border). It also sets 10-pixel [padding](https://developer.mozilla.org/en-US/docs/Web/CSS/padding) on the element. This adds some empty space between the element's content and the border.
393393
394-
The second CSS rule sets the text color of the notes as blue.
394+
The second CSS rule sets the text color of the <i>notes</i> class as blue.
395395
396396
HTML elements can also have other attributes apart from classes. The <i>div</i> element containing the notes has an [id](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id) attribute. JavaScript code uses the id to find the element.
397397
@@ -409,7 +409,7 @@ Let's review what happens when the page <https://studies.cs.helsinki.fi/examplea
409409
410410
- The browser fetches the HTML code defining the content and the structure of the page from the server using an HTTP GET request.
411411
- Links in the HTML code cause the browser to also fetch the CSS style sheet <i>main.css</i>...
412-
- ...and a JavaScript code file <i>main.js</i>
412+
- ...and the JavaScript code file <i>main.js</i>
413413
- The browser executes the JavaScript code. The code makes an HTTP GET request to the address <https://studies.cs.helsinki.fi/exampleapp/data.json>, which
414414
returns the notes as JSON data.
415415
- When the data has been fetched, the browser executes an <i>event handler</i>, which renders the notes to the page using the DOM-API.
@@ -471,7 +471,7 @@ notes.push({
471471
})
472472
```
473473
474-
The Note objects have two fields: <i>content</i> containing the actual content of the note, and <i>date</i> containing the date and time the note was created.
474+
Each note object has two fields: <i>content</i> containing the actual content of the note, and <i>date</i> containing the date and time the note was created.
475475
476476
The server does not save new notes to a database, so new notes disappear when the server is restarted.
477477
@@ -486,7 +486,7 @@ All of the data shown on the page was fetched with the HTML code generated by th
486486
487487
The Notes page uses AJAX to fetch the notes data. Submitting the form still uses the traditional mechanism of submitting web forms.
488488
489-
The application URLs reflect the old, carefree times. JSON data is fetched from the URL <https://studies.cs.helsinki.fi/exampleapp/data.json> and new notes are sent to the URL <https://studies.cs.helsinki.fi/exampleapp/new_note>.
489+
The application URLs reflect the old, carefree times. JSON data is fetched from the URL <https://studies.cs.helsinki.fi/exampleapp/data.json> and new notes are sent to the URL <https://studies.cs.helsinki.fi/exampleapp/new_note>.
490490
Nowadays URLs like these would not be considered acceptable, as they don't follow the generally acknowledged conventions of [RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_web_services) APIs, which we'll look into more in [part 3](/en/part3).
491491
492492
The thing termed AJAX is now so commonplace that it's taken for granted. The term has faded into oblivion, and the new generation has not even heard of it.
@@ -593,7 +593,7 @@ The status of React seems strong, but the world of JavaScript is ever-changing.
593593
594594
What does the name of the course, <i>Full stack web development</i>, mean? Full stack is a buzzword that everyone talks about, but no one knows what it means. Or at least, there is no agreed-upon definition for the term.
595595
596-
Practically all web applications have (at least) two "layers": the browser, being closer to the end-user, is the top layer, and the server the bottom one. There is often also a database layer below the server. We can therefore think of the <i>architecture</i> of a web application as a kind of <i>stack</i> of layers.
596+
Practically all web applications have (at least) two "layers": the browser, being closer to the end-user, is the top layer, and the server the bottom one. There is often also a database layer below the server. We can therefore think of the <i>architecture</i> of a web application as a <i>stack</i> of layers.
597597
598598
Often, we also talk about the [frontend and the backend](https://en.wikipedia.org/wiki/Front_and_back_ends). The browser is the frontend, and JavaScript that runs on the browser is frontend code. The server on the other hand is the backend.
599599
@@ -666,24 +666,24 @@ The diagram was made as a GitHub Markdown-file using the [Mermaid](https://docs.
666666
sequenceDiagram
667667
participant browser
668668
participant server
669-
669+
670670
browser->>server: GET https://studies.cs.helsinki.fi/exampleapp/notes
671671
activate server
672672
server-->>browser: HTML document
673673
deactivate server
674-
674+
675675
browser->>server: GET https://studies.cs.helsinki.fi/exampleapp/main.css
676676
activate server
677677
server-->>browser: the css file
678678
deactivate server
679-
679+
680680
browser->>server: GET https://studies.cs.helsinki.fi/exampleapp/main.js
681681
activate server
682682
server-->>browser: the JavaScript file
683683
deactivate server
684-
684+
685685
Note right of browser: The browser starts executing the JavaScript code that fetches the JSON from the server
686-
686+
687687
browser->>server: GET https://studies.cs.helsinki.fi/exampleapp/data.json
688688
activate server
689689
server-->>browser: [{ "content": "HTML is easy", "date": "2023-1-1" }, ... ]

0 commit comments

Comments
 (0)