Skip to content

Conversation

perepichai
Copy link
Contributor

Перевод страницы 6-data-storage/02-localstorage/article.md
localStorage и sessionStorage

@javascript-translate-bot javascript-translate-bot added the review needed Review needed, please approve or request changes label May 1, 2019
@CLAassistant
Copy link

CLAassistant commented May 1, 2019

CLA assistant check
All committers have signed the CLA.

@perepichai perepichai changed the title 6-data-storage/02-localstorage/article.md /1-js/06-data-storage/02-localstorage May 1, 2019
Copy link
Member

@lex111 lex111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Первые предложения для улучшения перевода.

@javascript-translate-bot javascript-translate-bot added changes requested Waiting for changes and /done from PR author and removed review needed Review needed, please approve or request changes labels May 1, 2019
@javascript-translate-bot
Copy link
Contributor

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@perepichai
Copy link
Contributor Author

/done

@javascript-translate-bot javascript-translate-bot added review needed Review needed, please approve or request changes and removed changes requested Waiting for changes and /done from PR author labels May 2, 2019
Copy link
Member

@lex111 lex111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ещё изменения + не все правки внесены с предыдущего ревью.

@javascript-translate-bot javascript-translate-bot added changes requested Waiting for changes and /done from PR author and removed review needed Review needed, please approve or request changes labels May 4, 2019
@javascript-translate-bot
Copy link
Contributor

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@perepichai
Copy link
Contributor Author

/done

@javascript-translate-bot javascript-translate-bot added review needed Review needed, please approve or request changes and removed changes requested Waiting for changes and /done from PR author labels May 16, 2019
@javascript-translate-bot javascript-translate-bot requested a review from a team May 16, 2019 07:30
@javascript-translate-bot javascript-translate-bot added needs +1 One more review needed and removed review needed Review needed, please approve or request changes labels May 19, 2019
Copy link
Member

@iliakan iliakan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пожалуйста, внеси изменения. По большей части улучшения изложения. Спасибо!

# LocalStorage, sessionStorage

Web storage objects `localStorage` and `sessionStorage` allow to save key/value pairs in the browser.
объекты веб-хранилища `localStorage` и `sessionStorage` позволяют хранить пары ключ/значение в браузере.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Объекты

объекты веб-хранилища `localStorage` и `sessionStorage` позволяют хранить пары ключ/значение в браузере.

What's interesting about them is that the data survives a page refresh (for `sessionStorage`) and even a full browser restart (for `localStorage`). We'll see that very soon.
И что самое интересное: данные сохраняются после обновления страницы (в случае `sessionStorage`) и даже при перезагрузки браузера (при использовании `localStorage`). Скоро мы это увидим.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что в них важно - данные, которые в них записаны, сохраняются после обновления страницы (в случае sessionStorage) и даже после перезагрузки браузера (при использовании localStorage). Скоро мы это увидим.

И что самое интересное: данные сохраняются после обновления страницы (в случае `sessionStorage`) и даже при перезагрузки браузера (при использовании `localStorage`). Скоро мы это увидим.

We already have cookies. Why additional objects?
Но у нас также есть куки. Зачем тогда эти объекты?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Но ведь у нас уже есть куки.

- Unlike cookies, web storage objects are not sent to server with each request. Because of that, we can store much more. Most browsers allow at least 2 megabytes of data (or more) and have settings to configure that.
- The server can't manipulate storage objects via HTTP headers, everything's done in JavaScript.
- The storage is bound to the origin (domain/protocol/port triplet). That is, different protocols or subdomains infer different storage objects, they can't access data from each other.
- В отличие от кук, объекты веб-хранилища не отправляются на сервер при каждом запросе. Поэтому мы можем хранить гораздо больше данных. Большинство браузеров могут сохранить как минимум 2 мегабайта данных (или больше), и этот размер можно изменить.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, и этот размер можно поменять в настройках.

- The server can't manipulate storage objects via HTTP headers, everything's done in JavaScript.
- The storage is bound to the origin (domain/protocol/port triplet). That is, different protocols or subdomains infer different storage objects, they can't access data from each other.
- В отличие от кук, объекты веб-хранилища не отправляются на сервер при каждом запросе. Поэтому мы можем хранить гораздо больше данных. Большинство браузеров могут сохранить как минимум 2 мегабайта данных (или больше), и этот размер можно изменить.
- Сервер не может манипулировать объектами хранилища через HTTP-заголовки, все делается при помощи JavaScript.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ещё одно отличие от куки - сервер не может манипулировать объектами хранилища через HTTP-заголовки. Все делается при помощи JavaScript.

- `getItem(key)` -- получить данные используя ключ (key).
- `removeItem(key)` -- удалить пару ключ/значение используя ключ (key).
- `clear()` -- удалить всё.
- `key(index)` -- получить ключ заданной позиции (index).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на заданной позиции

- Triggers on all `window` objects that have access to the storage except the one that generated it (within a tab for `sessionStorage`, globally for `localStorage`).
- Срабатывает при вызове `setItem`, `removeItem`, `clear`.
- Содержит все данные об операции, `url` документа и объект хранилища.
- Срабатывает на всех `window` объектах которые имеют доступ к хранилищу, а также там, где оно было сгенерировано (на вкладке для `sessionStorage`, глобально для `localStorage`).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Срабатывает на всех объектах window, которые

- `key(index)` -- get the key on a given position.
- `length` -- the number of stored items.
- `setItem(key, value)` -- сохранить пару ключ/значение (key/value).
- `getItem(key)` -- получить данные используя ключ (key).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

получить данные по ключу key

- `length` -- the number of stored items.
- `setItem(key, value)` -- сохранить пару ключ/значение (key/value).
- `getItem(key)` -- получить данные используя ключ (key).
- `removeItem(key)` -- удалить пару ключ/значение используя ключ (key).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалить данные с ключом key

@javascript-translate-bot javascript-translate-bot added the changes requested Waiting for changes and /done from PR author label May 19, 2019
@javascript-translate-bot
Copy link
Contributor

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

```

We only have to be on the same domain/port/protocol, the url path can be different.
Нам достаточно находится на том же домен/протокол/порт, но при этом путь url может быть разным.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

находитЬся

Это возможно по историческим причинам и как правило работает, но обычно не рекомендуется по двум причинам:

1. If the key is user-generated, it can be anything, like `length` or `toString`, or another built-in method of `localStorage`. In that case `getItem/setItem` work fine, while object-like access fails:
1. Если ключ генерируется пользователем, то он может быть каким угодно, включая `length` или `toString`, а также другой встроенный метод `localStorage`. В этом случае `getItem/setItem` работает нормально, до тех пор, пока объектно-ориентированный доступ потерпит неудачу:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iliakan может "чтение/запись свойства объекта не пРойдут? а то не могу понять фразу

Обратите внимание, что событие также содержит: `event.url` - url-адрес документа, в котором данные обновились.

Also, `event.storageArea` contains the storage object -- the event is the same for both `sessionStorage` and `localStorage`, so `storageArea` references the one that was modified. We may event want to set something back in it, to "respond" to a change.
Также `event.storageArea` содержит объект хранилища - событие одинаковое для `sessionStorage` и `localStorage`, поэтому `storageArea` ссылается на тот который был изменен. Мы можем захотеть что-то вернуть обратно, "ответить" на изменения.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тот, который

**Это позволяет разным окнам одного источника обмениваться сообщениями.**

Modern browsers also support [Broadcast channel API](https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API), the special API for same-origin inter-window communication, it's more full featured, but less supported. There are libraries that polyfill that API, based on `localStorage`, that make it available everywhere.
Современные браузеры также поддерживают [Broadcast channel API](https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API) специальный API для связи между окнами одного источника, он более полнофункциональный, но менее поддерживаемый. Существуют библиотеки (полифилы), которые дополняют API на основе `localStorage`, и делают его доступным везде.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перед делают не надо , вроде

- Use `Object.keys` to get all keys.
- Can use the keys as object properties, in that case `storage` event doesn't trigger.
- `setItem(key, value)` -- сохранить пару ключ/значение (key/value).
- `getItem(key)` -- получить данные используя ключ (key).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, используя

- Can use the keys as object properties, in that case `storage` event doesn't trigger.
- `setItem(key, value)` -- сохранить пару ключ/значение (key/value).
- `getItem(key)` -- получить данные используя ключ (key).
- `removeItem(key)` -- удалить пару ключ/значение используя ключ (key).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, используя

@javascript-translate-bot
Copy link
Contributor

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@javascript-translate-bot
Copy link
Contributor

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@xcurveballx
Copy link
Member

как вариант, можно обновить форк и сделать новый PR, скопировав туда перевод главы.

@perepichai
Copy link
Contributor Author

perepichai commented Jul 7, 2019

А вот это мне нравиться больше) в какой то момент все пошло не так. И вместо перевода борюсь с гитом

@iliakan
Copy link
Member

iliakan commented Jul 8, 2019

Ждём =)

@perepichai
Copy link
Contributor Author

/done

@javascript-translate-bot javascript-translate-bot added review needed Review needed, please approve or request changes and removed changes requested Waiting for changes and /done from PR author labels Jul 9, 2019
@javascript-translate-bot javascript-translate-bot requested a review from a team July 9, 2019 21:08
@iliakan
Copy link
Member

iliakan commented Jul 9, 2019

В Files changed по-прежнему много файлов

@iliakan
Copy link
Member

iliakan commented Jul 9, 2019

И еще правки не учтены.

Copy link
Member

@iliakan iliakan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Правки не учтены, файлы лишние.

@javascript-translate-bot javascript-translate-bot removed the review needed Review needed, please approve or request changes label Jul 9, 2019
@javascript-translate-bot
Copy link
Contributor

Please make the requested changes. After it, add a comment "/done".
Then I'll ask for a new review 👻

@javascript-translate-bot javascript-translate-bot added the changes requested Waiting for changes and /done from PR author label Jul 9, 2019
@perepichai
Copy link
Contributor Author

Правки не учтены, файлы лишние.

Как можно от этих файлов избавиться? Склонировал форк в новую папку. Затем сделал git pull с основного репозитория в мастер. git pull upstream master. Далее git merge master. Затем сделал коммит только одного файла и запушил. Новый pull request мне поможет?

@iliakan
Copy link
Member

iliakan commented Jul 10, 2019

Реально ты менял только текст одного файла, да?

@iliakan
Copy link
Member

iliakan commented Jul 10, 2019

Я там видел - мои правки по тексту не все учтены, как минимум одна =)

@perepichai
Copy link
Contributor Author

Реально ты менял только текст 1го файла, да?

меняю только один файл и добавляю его в коммит. Не могу понять каким образом добавились еще 45 файлов.

@perepichai
Copy link
Contributor Author

Я там видел - мои правки по тексту не все учтены, как минимум одна =)

Пересмотрю)

@iliakan
Copy link
Member

iliakan commented Jul 10, 2019

Прими все правки по этому файлу и создай абсолютно новый PR только с ним. Можешь репу с нуля переклонировать или как проще =)

@perepichai
Copy link
Contributor Author

Прими все правки по этому файлу и создай абсолютно новый PR только с ним. Можешь репу с нуля переклонировать или как проще =)

Сейчас вот такая картина (если сделаю PR должно быть ок?):
PS C:\development\javascriptru\new\ru.javascript.info> git status
On branch translate
Changes to be committed:
(use "git reset HEAD ..." to unstage)

    modified:   6-data-storage/02-localstorage/article.md

Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

    modified:   1-js/09-classes/02-class-inheritance/3-class-extend-object/rabbit-extends-object.png
    modified:   1-js/09-classes/02-class-inheritance/3-class-extend-object/rabbit-extends-object@2x.png
    modified:   1-js/09-classes/02-class-inheritance/animal-rabbit-extends.png
    modified:   1-js/09-classes/02-class-inheritance/animal-rabbit-extends@2x.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-array-object.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-array-object@2x.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-rabbit-animal-2.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-rabbit-animal-2@2x.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-rabbit-animal.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-rabbit-animal@2x.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-rabbit-run-animal.png
    modified:   1-js/09-classes/02-class-inheritance/class-inheritance-rabbit-run-animal@2x.png
    modified:   1-js/09-classes/02-class-inheritance/rabbit-animal-independent-animal.png
    modified:   1-js/09-classes/02-class-inheritance/rabbit-animal-independent-animal@2x.png
    modified:   1-js/09-classes/02-class-inheritance/rabbit-animal-independent-rabbit.png
    modified:   1-js/09-classes/02-class-inheritance/rabbit-animal-independent-rabbit@2x.png
    modified:   1-js/09-classes/02-class-inheritance/super-homeobject-wrong.png
    modified:   1-js/09-classes/02-class-inheritance/super-homeobject-wrong@2x.png
    modified:   1-js/09-classes/02-class-inheritance/this-super-loop.png
    modified:   1-js/09-classes/02-class-inheritance/this-super-loop@2x.png
    modified:   1-js/09-classes/03-static-properties-methods/animal-rabbit-static.png
    modified:   1-js/09-classes/03-static-properties-methods/animal-rabbit-static@2x.png
    modified:   1-js/09-classes/04-private-protected-properties-methods/coffee-inside.jpg
    modified:   1-js/09-classes/04-private-protected-properties-methods/coffee.jpg
    modified:   1-js/09-classes/05-extend-natives/object-date-inheritance.png
    modified:   1-js/09-classes/05-extend-natives/object-date-inheritance@2x.png
    modified:   1-js/09-classes/06-instanceof/instanceof.png
    modified:   1-js/09-classes/06-instanceof/instanceof@2x.png
    modified:   1-js/09-classes/07-mixins/mixin-inheritance.png
    modified:   1-js/09-classes/07-mixins/mixin-inheritance@2x.png
    modified:   10-misc/01-proxy/proxy-inherit.png
    modified:   10-misc/01-proxy/proxy-inherit@2x.png
    modified:   10-misc/01-proxy/proxy.png
    modified:   10-misc/01-proxy/proxy@2x.png
    modified:   2-ui/3-event-details/5-keyboard-events/german-layout.png
    modified:   2-ui/3-event-details/5-keyboard-events/german-layout@2x.png
    modified:   2-ui/3-event-details/5-keyboard-events/us-layout.png
    modified:   2-ui/3-event-details/5-keyboard-events/us-layout@2x.png

@xcurveballx
Copy link
Member

Там теперь 61 файл, а было 45)) Может просто создать новый форк и новый PR и скопировать только статью с переводом?

@iliakan
Copy link
Member

iliakan commented Jul 10, 2019

да

@perepichai
Copy link
Contributor Author

perepichai commented Jul 11, 2019

да

Сделал новый форк и PR (#301 )

@xcurveballx
Copy link
Member

В связи с перепетиями с гитом этот PR зашел в тупик, продолжение в #301

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes requested Waiting for changes and /done from PR author needs +1 One more review needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants