Skip to content

Commit 2202cee

Browse files
authored
Merge pull request #3 from Xapuu/translate/hello-world
Hello, world!
2 parents 0c55fdd + 8f36269 commit 2202cee

File tree

4 files changed

+54
-50
lines changed

4 files changed

+54
-50
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
importance: 5
1+
важност: 5
22

33
---
44

5-
# Show an alert
5+
# Покажи извсестие
66

7-
Create a page that shows a message "I'm JavaScript!".
7+
Създайте страница, която показва съобщение "I'm JavaScript!".
88

9-
Do it in a sandbox, or on your hard drive, doesn't matter, just ensure that it works.
9+
Направете го в sandbox или на вашият твърд диск, няма значение, просто се уверете че работи.
1010

1111
[demo src="solution"]
1212

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
The HTML code:
1+
HTML кодът:
22

33
[html src="index.html"]
44

5-
For the file `alert.js` in the same folder:
5+
За файла `alert.js`, намиращ се в същата директория:
66

77
[js src="alert.js"]
88

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
importance: 5
1+
важност: 5
22

33
---
44

5-
# Show an alert with an external script
5+
# Покажи нотификация чрез външен скрипт
66

7-
Take the solution of the previous task <info:task/hello-alert>. Modify it by extracting the script content into an external file `alert.js`, residing in the same folder.
7+
Вземете решението от предходната задача <info:task/hello-alert>. Модифицирайте го, като извлечете скрипта от съдържанието и го поставите в отделен, външен файл `alert.js`, намиращ се в същата директория.
88

9-
Open the page, ensure that the alert works.
9+
Отворете страницата и се уверете че работи.

1-js/02-first-steps/01-hello-world/article.md

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,89 @@
11
# Hello, world!
22

3-
This part of the tutorial is about core JavaScript, the language itself.
3+
В тази част от урока ще разглеждаме езика JavaScript в неговия чист вид.
44

5-
But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum so that you don't spend time on them if you plan to concentrate on another environment (like Node.js). We'll focus on JavaScript in the browser in the [next part](/ui) of the tutorial.
5+
За целта ще ни е необходима среда, в която да изпълняваме нашите скриптове, тъй като това е онлайн книга, браузъра е добър избор като среда. Ще се стремим да използваме минимално количество браузър-специфични команди (като `alert`), за да не губите време, ако сте планувате да се занимавате с разработка в друга среда (като Node.js). Ще се фокусираме върху разработката на JavaScript за браузър в [друга част](/ui) от уроците.
66

7-
So first, let's see how we attach a script to a webpage. For server-side environments (like Node.js), you can execute the script with a command like `"node my.js"`.
7+
Първо нека видим как можем да закачим скрипт към уеб страница. За разработка в сървърна среда (като Node.js), може да изпълни скрипта с командата `"node my.js"`.
88

99

10-
## The "script" tag
10+
## "script" таг
1111

12-
JavaScript programs can be inserted into any part of an HTML document with the help of the `<script>` tag.
12+
JavaScript програми могат да бъдат поставяни в всяка част от HTML документ, с помощта на `<script>` таг.
1313

14-
For instance:
14+
Пример:
1515

1616
```html run height=100
1717
<!DOCTYPE HTML>
1818
<html>
1919

2020
<body>
2121

22-
<p>Before the script...</p>
22+
<p>Преди script...</p>
2323

2424
*!*
2525
<script>
2626
alert( 'Hello, world!' );
2727
</script>
2828
*/!*
2929

30-
<p>...After the script.</p>
30+
<p>... След script.</p>
3131

3232
</body>
3333

3434
</html>
3535
```
3636

3737
```online
38-
You can run the example by clicking the "Play" button in the right-top corner of the box above.
38+
Можете да изпълните този примерен код като натиснете бутона "Play" (пусни) в горният десен ъгъл, на горната кутия.
3939
```
4040

41-
The `<script>` tag contains JavaScript code which is automatically executed when the browser processes the tag.
41+
`<script>` тагът съдържа JavaSript код, който ще се изпълни автоматично, при обработка на тага от браузъра.
4242

4343

44-
## Modern markup
44+
## Модерно оформление
4545

46-
The `<script>` tag has a few attributes that are rarely used nowadays but can still be found in old code:
46+
`<script>` таговете имат няколко вече рядко използвани атрибути, които все още могат да бъдат намерени в стар код.
4747

48-
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
49-
: The old HTML standard, HTML4, required a script to have a `type`. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic; we'll talk about modules in another part of the tutorial.
48+
Атрибутът `type`: <code>&lt;script <u>type</u>=...&gt;</code>
49+
: Според старият HTML стандарт, HTML4, `script` тагът се е изисквало да съдържа атрибут `type`. Като обикновено е бил `type="text/javascript"`. Този атрибут вече не е задължителен. Ноивят HTML стандарт тотално изменя значението на този атрибут, сега този атрибут може да се използва за JavaScript модули, но това е тема за по-напреднали, която ще разгледаме в следващ урок.
5050

51-
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
52-
: This attribute was meant to show the language of the script. This attribute no longer makes sense because JavaScript is the default language. There is no need to use it.
51+
Атрибутът `language`: <code>&lt;script <u>language</u>=...&gt;</code>
52+
: Този атрибут е бил използван да обозначава езикът на скрипта. Той вече е загубил значението си, тъй като JavaScript e езикa по подразбиране.
5353

54-
Comments before and after scripts.
55-
: In really ancient books and guides, you may find comments inside `<script>` tags, like this:
54+
55+
Коментари преди и след скриптове
56+
: В някои наистина дрвени книги и уроци, може да намерите коментари в `<script>` тагове, като тези:
5657

5758
```html no-beautify
5859
<script type="text/javascript"><!--
5960
...
6061
//--></script>
6162
```
6263

63-
This trick isn't used in modern JavaScript. These comments hide JavaScript code from old browsers that didn't know how to process the `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
64+
65+
Този трик не се използва в модерния JavaScript. Тези коментраи могат да скрият JavaScript код от стари браузъри, които не могат да обработват `<script>` тагове. Тъй като браузърите, дистрибутирани през последните 15 години, нямат този проблем, този вид коментари могат да помогнат за индетифициране на наистина стари браузъри.
6466

6567

66-
## External scripts
68+
## Външни скриптове
6769

68-
If we have a lot of JavaScript code, we can put it into a separate file.
70+
Ако имаме много JavaScript код, може да го отделим в различн файл.
6971

70-
Script files are attached to HTML with the `src` attribute:
72+
Скрипт файловете се закачат към HTML файловете посредством `src` атрибута:
7173

7274
```html
7375
<script src="/path/to/script.js"></script>
7476
```
7577

76-
Here, `/path/to/script.js` is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"` would mean a file `"script.js"` in the current folder.
78+
Тук `/path/to/script.js` е абсолютният път до скрипта започващ от нивото от което се зарежда и сайта в файловата система. Също така може да се използва и релативен път, от текущата страница, пример за това е `src="script.js"`, което означава че ще бъде достъпен файла `"script.js"` от текущата директория.
7779

78-
We can give a full URL as well. For instance:
80+
Може да предоставим и пълен URL адрес. Пример за това е:
7981

8082
```html
8183
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.2.0/lodash.js"></script>
8284
```
8385

84-
To attach several scripts, use multiple tags:
86+
За да закачим няколко скрипта, трабва да използваме и няколко тага:
8587

8688
```html
8789
<script src="/js/script1.js"></script>
@@ -90,29 +92,30 @@ To attach several scripts, use multiple tags:
9092
```
9193

9294
```smart
93-
As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files.
95+
Като правило е прието, че само най-простите скриптове, се поставят в HTML файловете, като по сложните се поставят в отделни файлове.
9496
95-
The benefit of a separate file is that the browser will download it and store it in its [cache](https://en.wikipedia.org/wiki/Web_cache).
97+
Ползата от отделянето на файлове е, че браузъра ще свали този файл и ще го съхрани в своя [кеш](https://bg.wikipedia.org/wiki/%D0%9A%D0%B5%D1%88-%D0%BF%D0%B0%D0%BC%D0%B5%D1%82)
9698
97-
Other pages that reference the same script will take it from the cache instead of downloading it, so the file is actually downloaded only once.
99+
Други страници, които реферират същият скрипт, ще могат да го заредят от кеша вместо да правят нова заявка, което означава че файла ще бъде изтеглен само веднъж.
98100
99-
That reduces traffic and makes pages faster.
101+
Това намалява трафикът и прави страниците по-бързи.
100102
```
101103

102-
````warn header="If `src` is set, the script content is ignored."
103-
A single `<script>` tag can't have both the `src` attribute and code inside.
104+
````warn header="Ако на`src` атрибута е зададена стойност, то тогава съдържанието на скрипта бива игнорирано."
105+
Един `<script>` таг може да съдържа в себе си едноверемено код и `src` атрибут.
104106

105-
This won't work:
107+
108+
Това няма да проработи:
106109

107110
```html
108111
<script *!*src*/!*="file.js">
109-
alert(1); // the content is ignored, because src is set
112+
alert(1); // съдържанието е игнорирано, тъй като има задеден src атрибут
110113
</script>
111114
```
112115

113-
We must choose either an external `<script src="…">` or a regular `<script>` with code.
116+
Ние трябва да изберем или външен `<script src="…">` таг или обикновен `<script>` таг с код.
114117

115-
The example above can be split into two scripts to work:
118+
Горният пример може да бъде разделен на два скрипта за да проработи:
116119

117120
```html
118121
<script src="file.js"></script>
@@ -122,11 +125,12 @@ The example above can be split into two scripts to work:
122125
```
123126
````
124127
125-
## Summary
128+
## Обобщение
129+
130+
- Може да използваме `<script>` таг за да добавяме JavaScript код към страница.
131+
- Атрибутите `type` и `language` не са задължиетлни.
132+
- Скрипт от външен за страницата файл, може да бъде закачан посредством `<script src="path/to/script.js"></script>`.
126133
127-
- We can use a `<script>` tag to add JavaScript code to a page.
128-
- The `type` and `language` attributes are not required.
129-
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
130134
135+
Има още много, което може да се научи за скриптовете изпълнявани в браузъра и техите интеракции с уеб страниците, но нека незабравяме че тази част от урока е посветена на езика JavaScript, за това не трябва да се разсейваме, с браузър-специфични имплементации. Ние ще използваме браузъра, като средство да изпълняваме JavaScript код, което е много удобно, за това онлайн четиво.
131136
132-
There is much more to learn about browser scripts and their interaction with the webpage. But let's keep in mind that this part of the tutorial is devoted to the JavaScript language, so we shouldn't distract ourselves with browser-specific implementations of it. We'll be using the browser as a way to run JavaScript, which is very convenient for online reading, but only one of many.

0 commit comments

Comments
 (0)