'JSON and serialization' 번역 초안#36
Conversation
BurningDroid
left a comment
There was a problem hiding this comment.
절반정도 리뷰하였습니다.
나머지는 추후 이어서 리뷰하겠습니다.
|
|
||
| This guide looks into ways of using JSON with Flutter. It covers which | ||
| JSON solution to use in different scenarios, and why. | ||
| 이 가이드에서는 Flutter 로 JSON 을 사용하는 방법에 대해 알아보려합니다. 각기 다른 |
| To avoid confusion, this doc uses "serialization" when referring to the | ||
| overall process, and "encoding" and "decoding" when specifically | ||
| referring to those processes. | ||
| **Terminology:** _인코딩_ 과 _직렬화_ 은 자료 구조를 문자열로 변환하는 서로 같은 일을 합니다. |
| overall process, and "encoding" and "decoding" when specifically | ||
| referring to those processes. | ||
| **Terminology:** _인코딩_ 과 _직렬화_ 은 자료 구조를 문자열로 변환하는 서로 같은 일을 합니다. | ||
| _디코딩_ 과 _역직렬화_ 은 문자열을 자료 구조로 변환하는 정반대 과정을 거칩니다. |
| referring to those processes. | ||
| **Terminology:** _인코딩_ 과 _직렬화_ 은 자료 구조를 문자열로 변환하는 서로 같은 일을 합니다. | ||
| _디코딩_ 과 _역직렬화_ 은 문자열을 자료 구조로 변환하는 정반대 과정을 거칩니다. | ||
| 하지만, _직렬화_ 는 일반적으로 자료 구조를 보다 읽기 쉬운 형식으로 변환하는 과정을 가르킵니다. |
There was a problem hiding this comment.
읽기 쉬운 형식보다는 읽기 쉬운 형태가 낫지 않을까요?
가르킵니다 -> 가리킵니다
| _디코딩_ 과 _역직렬화_ 은 문자열을 자료 구조로 변환하는 정반대 과정을 거칩니다. | ||
| 하지만, _직렬화_ 는 일반적으로 자료 구조를 보다 읽기 쉬운 형식으로 변환하는 과정을 가르킵니다. | ||
|
|
||
| 혼란을 피하기위해, 이 문서에서는 전반적인 과정을 가르킬 때 "직렬화"이라 합니다. |
There was a problem hiding this comment.
피하기위해 -> 피하기 위해
가르킬 때 -> 가리킬 때 (가리킨다는 의미보다는 언급한다는 표현은 어떨까요?)
| and it's good for a quick proof of concept. | ||
| 수동 JSON 디코딩은 `dart:convert` 에 탑재되어있는 JSON 디코더를 사용하는 것을 가르킵니다. | ||
| JSON 문자열을 `jsonDecode()` 함수에 전달한 후 결과값 `Map<String, dynamic>` 에서 | ||
| 필요한 값을 참조 하면 됩니다. |
| field, your code throws an error during runtime. | ||
| 수동 디코딩은 프로젝트가 커지면 적합하지 않습니다. 디코딩 로직을 손수 작성하는 것은 | ||
| 더 관리하기 어려워지고, 오류가 발생하기 쉬워집니다. | ||
| 만약 존재하지 않는 JSON 필드에 접근하는 실수가 있다면, 코드가 런타임 도중에 에러가 발생 할 수도 있습니다. |
There was a problem hiding this comment.
"실수가 있다면" 보다는 "실수를 한다면"이 더 자연스러울 것 같아요.
발생 할 수도 -> 발생할 수도
| code from your release builds. This optimizes the app's size significantly. | ||
| 이러한 라이브러리들은 런타임 [리플렉션][]을 요구하는데, Flutter 에서는 비활성화가 되어있습니다. | ||
| 런타임 리플렉션은 [트리 쉐이킹][]을 방해하는데, 다트가 꽤나 오랫동안 지원했던 기능입니다. | ||
| 트리 쉐이킹으로 릴리즈 빌드에서 사용하지 않는 코드를 "뿌리 칠 수 있습니다". 트리 쉐이킹을 통해 |
There was a problem hiding this comment.
Tree shaking은 사실 적합한 번역 문이 없는 것 같은데, 원문을 그대로 두는 건 어떨까요?
"shake off" 는 떨쳐내는 의미이고, 본문에서도 코드를 제거하는 의미로 사용됩니다.
꼭 "shake off"를 살리기 보다는 차라리 그냥 제거할 수 있다고 일반적으로 표현하는 것도 나을 것 같습니다.
| shaking difficult. The tools cannot know what parts are unused at runtime, so | ||
| the redundant code is hard to strip away. App sizes cannot be easily optimized | ||
| when using reflection. | ||
| 리플렉션은 기본적으로 코드를 암묵적으로 사용되게 만들기에 트리 쉐이킹을 어렵게 만듭니다. 그래서 런타임 상에서 |
| when using reflection. | ||
| 리플렉션은 기본적으로 코드를 암묵적으로 사용되게 만들기에 트리 쉐이킹을 어렵게 만듭니다. 그래서 런타임 상에서 | ||
| 어떤 부분이 쓰이는지 알 수 없어지고, 중복되는 코드를 뿌리치기 어렵게 만듭니다. 앱 크기는 | ||
| 리플렉션이 사용될 때 결코 쉽게 최적화 될 수 없습니다. |
There was a problem hiding this comment.
위에 언급한 것처럼 shake off에 초점을 맞추다 보니 "중복된 코드를 뿌리치기 어렵다"는 다소 어색한 표현이 됩니다.
차라리 그냥 "중복된 코드를 제거하기 어렵다" 식으로 번역하는 것이 나을 것 같습니다.
최적화 될 수 -> 최적화될 수
| web server or easily store structured data at some point. When making | ||
| network-connected apps, the chances are that it needs to consume some good old | ||
| JSON, sooner or later. | ||
| 어느 시점에서 부터 웹 서버랑 통신하지 않거나 구조화된 데이터를 쉽게 보관하는 모바일 앱을 |
There was a problem hiding this comment.
어느 시점에서 부터 -> 어느 시점에서부터
혹은 어느 시점부터라고 써도 괜찮다고 생각합니다.
| network-connected apps, the chances are that it needs to consume some good old | ||
| JSON, sooner or later. | ||
| 어느 시점에서 부터 웹 서버랑 통신하지 않거나 구조화된 데이터를 쉽게 보관하는 모바일 앱을 | ||
| 생각하기 어려워집니다. 네트워크와 연결된 앱을 제작할 때, 결국에는 제법 괜찮은 JSON 을 |
There was a problem hiding this comment.
~생각하기 어렵습니다 혹은 ~생각하기 어려워졌습니다.가 자연스러울 것 같습니다.
| when using reflection. | ||
| 리플렉션은 기본적으로 코드를 암묵적으로 사용되게 만들기에 트리 쉐이킹을 어렵게 만듭니다. 그래서 런타임 상에서 | ||
| 어떤 부분이 쓰이는지 알 수 없어지고, 중복되는 코드를 뿌리치기 어렵게 만듭니다. 앱 크기는 | ||
| 리플렉션이 사용될 때 결코 쉽게 최적화 될 수 없습니다. |
There was a problem hiding this comment.
피동 표현을 능동으로 바꾸면 더 좋을 것 같습니다.
리플렉션을 사용하면 앱 크기를 최적화하기가 어려워집니다.
| you similarly easy to use APIs but are based on code generation instead. This | ||
| approach is covered in more detail in the [code generation | ||
| libraries](#code-generation) section. | ||
| 비록 런타임 리플렉션을 Flutter 와 사용할 수 없더라도, 몇몇 라이브러리들은 |
| 정적 타입 언어의 기능인 타입 안전성, 자동완성, 그리고 가장 중요한 컴파일 타임 오류를 사용할 수 없게 됩니다. | ||
| 이로 인해 코드는 순식간에 오류가 발생하기 쉬운 환경에 처하게 됩니다. | ||
|
|
||
| 예를 들어 `name` 이나 `email` 필드를 접근하려 할 때, map 에 디코딩된 JSON 의 값이 있기에 |
There was a problem hiding this comment.
typo(오타)에 대한 부분이 안보이네요.
예를 들어
name이나
|
|
||
| ### Serializing JSON inside model classes | ||
| 일반적인 모델 클래스를 사용하여 앞서 말한 문제를 방지 할 수 있습니다. 이 예제에서는 `User` 를 사용합니다. | ||
| `User` 클래스 내에서는 |
There was a problem hiding this comment.
여기에 :을 쓰고 아래 * 있는 쪽에는 :을 안써야 하지 않나요?
User클래스 내에는:
*map 구조에서 새로운User객체를 생성하기 위한 생성자인User.fromJson()생성자
*User객체를 map 구조로 변환하기 위한 메서드인toJson()메서드가 있습니다.
|
|
||
| With this approach, the _calling code_ can have type safety, | ||
| autocompletion for the `name` and `email` fields, and compile-time exceptions. | ||
| If you make typos or treat the fields as `int`s instead of `String`s, |
There was a problem hiding this comment.
If you make typos or treat the fields as ints instead of Strings,
the app won't compile, instead of crashing at runtime.
이 부분에 대한 번역이 빠진 것 같습니다
| methods both need to have unit tests in place to verify correct behavior. | ||
| 이 방법을 통해 호출부에서는 JSON 직렬화를 전혀 걱정하지 않아도 됩니다. 하지만, | ||
| 모델 클래스는 아직 직렬화에 대해 확실해야합니다. 프로덕션 앱에서 직렬화가 제대로 동작하는지 | ||
| 보장되어야합니다. 이를 위해(실제론), `User.fromJson()` 과 `User.toJson()` 메서드 모두 |
There was a problem hiding this comment.
이를 위에는 없어도 될 것 같습니다.
이를 위해(실제론), -> 실제로는,
| It's unlikely that you would use such small JSON responses. | ||
| Nested JSON objects are also commonly used. | ||
| 하지만, 현실의 시나리오는 보통 그렇게 간단하지 않습니다. | ||
| 이런 간단한 JSON 응답은 거의 사용하지 않습니다. 보통, 중첩된 JSON 객체들이 일반적으로 사용됩니다. |
There was a problem hiding this comment.
commonly가 두 번 번역된 것 같습니다.
보통과 일반적으로 중 하나를 빼셔야 할 듯해요.
| are dependencies that are not included in our app source code—they | ||
| are only used in the development environment. | ||
| 프로젝트에 `json_serializable`를 포함시키기위해, 일반 의존성 한 개와 _개발 의존성_ 두 개가 필요합니다. | ||
| 짧게 말하자면, _개발 의존성_ 은 앱 소스코드에 포함되지 않고 오직 개발 환경에서만 사용되는 의존성입니다. |
| /// from a map. Pass the map to the generated `_$UserFromJson()` constructor. | ||
| /// The constructor is named after the source class, in this case User. | ||
| /// map 에서 새로운 User 객체를 생성하기위해 필요한 팩토리 생성자입니다. | ||
| /// 생성된 `_$UserFromJson()` 생성자에게 map 을 전달해줍니다. |
| /// The constructor is named after the source class, in this case User. | ||
| /// map 에서 새로운 User 객체를 생성하기위해 필요한 팩토리 생성자입니다. | ||
| /// 생성된 `_$UserFromJson()` 생성자에게 map 을 전달해줍니다. | ||
| /// 생성자의 이름은 클래스의 이름을 따릅니다. 본 예제의 경우 `User` 를 따릅니다. |
| /// `toJson` is the convention for a class to declare support for serialization | ||
| /// to JSON. The implementation simply calls the private, generated | ||
| /// helper method `_$UserToJson`. | ||
| /// `toJson` 은 JSON 직렬화의 지원을 선언하는 클래스의 규칙 입니다. |
| With this setup, the source code generator generates code for encoding | ||
| and encoding the `name` and `email` fields from JSON. | ||
| 이 작업으로 소스 코드 생성기는 인코딩을 위한 코드와, JSON으로 부터 `name` 와 `email` 필드를 | ||
| 디코딩하는 코드를 생성해줍니다. |
|
|
||
| While this is convenient, it would be nice if you did not have to run the | ||
| build manually every time you make changes in your model classes. | ||
| 이 방법도 좋지만, 모델 클래스에 변화가 있을 때 마다 빌드를 실행하지 않으면 더 좋을 것 같네요. |
There was a problem hiding this comment.
convenient의 의미를 살려주시면 좋을 것 같습니다. 이 방법도 좋지만, -> 이 방법도 편리하지만,
| `flutter packages pub run build_runner watch` in the project root. | ||
| _watcher_ 가 소스 코드 생성과정을 좀 더 편리하게 만들어 줍니다. 이는 프로젝트 파일들의 변화를 지켜 보고 | ||
| 자동으로 필요한 파일을 빌드 해줍니다. 프로젝트 루트에서 | ||
| `flutter packages pub run build_runner watch` 를 실행하여 watcher 를 시작하세요. |
There was a problem hiding this comment.
`flutter packages pub run build_runner watch` 를 -> `flutter packages pub run build_runner watch`를
|
|
||
| To decode a JSON string the `json_serializable` way, | ||
| you do not have actually to make any changes to our previous code. | ||
| `json_serializable` 으로 JSON 문자열을 디코드하기 위해서 |
There was a problem hiding this comment.
`json_serializable` 으로 -> `json_serializable`로
| to write automated tests to ensure that the serialization works—it's | ||
| now _the library's responsibility_ to make sure the serialization works | ||
| appropriately. | ||
| `json_serializable` 와 함께라면 `User` 클래스에서의 수동 JSON 직렬화는 잊어도 됩니다. |
There was a problem hiding this comment.
`json_serializable` 와 -> `json_serializable`과
| examples in GitHub]({{site.github}}/dart-lang/json_serializable/blob/master/example/lib/example.dart) | ||
| * [Discussion | ||
| about dart:mirrors in Flutter]({{site.github}}/flutter/flutter/issues/1150) | ||
| * [dart:convert][] 와 [JsonCodec][] 의 문서 |
There was a problem hiding this comment.
[dart:convert][] 와 [JsonCodec][] 의 문서 -> [dart:convert][]와 [JsonCodec][] 문서
| * [Discussion | ||
| about dart:mirrors in Flutter]({{site.github}}/flutter/flutter/issues/1150) | ||
| * [dart:convert][] 와 [JsonCodec][] 의 문서 | ||
| * [Pub 에 있는 json_serializable 패키지](https://pub.dartlang.org/packages/json_serializable) |
리뷰 부탁드립니다.
Terminology 의 경우 대체할 만한 단어를 찾지 못해 그대로 적어 놓았습니다.
코멘트로 어색한 부분들을 지적해주시면 감사하겠습니다.