From cdb4d23314d83690280ce41edb8845499615f050 Mon Sep 17 00:00:00 2001 From: Hui Zhong <xanogayu@live.com> Date: Sun, 24 Sep 2017 18:44:05 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=BF=BB=E8=AF=91location.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/hardware/location.md | 95 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/docs/hardware/location.md b/docs/hardware/location.md index 93d48732d..382cf8c3f 100644 --- a/docs/hardware/location.md +++ b/docs/hardware/location.md @@ -8,25 +8,45 @@ previous_url: /location # Location +# 地理位置 + > **IMPORTANT:** Starting with NativeScript 1.5.0, the built-in Location module is deprecated. To implement geolocation in your apps, use the `nativescript-geolocation` plugin, available via npm. This plugin provides an API similar to the [W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html). +> **重要信息:** 从NativeScript 1.5.0版本开始, 内建的地理位置模块将被弃用. 若需要在您的应用中实现地理位置处理相关功能, 可以通过npm安装使用`nativescript-geolocation`插件。 该插件提供了类似于[W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html)的API。 + The most important difference between the deprecated module and the new plugin is that location monitoring via the plugin returns an `id` that you can use to stop location monitoring. The `nativescript-geolocation` plugin also uses an accuracy criteria approach to deliver geolocation. This means that getting a location is powered by the most accurate location provider that is available. For example, if a GPS signal is available and the GPS provider is enabled, the plugin uses GPS; if GPS is not connected, the device falls back to other available providers such as Wi-Fi networks or cell towers). +被弃用的模块和新启用的插件之间最大的区别在于,通过插件获取到的位置监控器返回一个`id`,你可以通过使用这个`id`来结束位置监控器。此外,`nativescript-geolocation`插件还通过使用一种高精度标准的方式来提供地理位置信息。这意味着获取的位置信息由当前可用的最精确的位置提供者提供。例如,如果可以获取到GPS信号而且GPS提供者被启用,则插件使用GPS;如果GPS无法连接,则设备使用其他可用的提供者例如Wi-Fi网络或者蜂窝网络信号塔。 + This approach does not limit location monitoring only to a specific location provider; it can still work with all of them. +这种方式并不是要限制位置监控器,使其使用某个特定的位置提供者;所有的位置提供者均被会使用。 + You might want to start with this [example](https://github.com/nsndeck/locationtest), which demonstrates how to use the `nativescript-geolocation` plugin. +你可能会希望通过一个教你如何使用`nativescript-geolocation`插件的[示例](https://github.com/nsndeck/locationtest)来开始了解这一部分的内容。 + To make the plugin available in your app, run the following command: +为了在你的App中使用这个插件,请执行以下的命令: + +```Shell +tns plugin add nativescript-geolocation +``` + ```Shell tns plugin add nativescript-geolocation ``` To import the module in your code, use: + +在代码中引入插件: + {% nativescript %} ```JavaScript var geolocation = require("nativescript-geolocation"); ``` + {% endnativescript %} ```TypeScript import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, distance, clearWatch } from "nativescript-geolocation"; @@ -34,16 +54,32 @@ import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, di ## Getting information about a location service +## 获取和位置服务相关的信息 + NativeScript has a universal way to check if location services are turned on—the `isEnabled` method. The method returns a Boolean value (true if the location service is enabled). +在NativeScript中使用`isEnabled`这样一个通用的方法来检查位置服务是否开启。方法会返回一个`Boolean`类型的值(如果位置服务已开启则返回`true`)。 + > **NOTE:** For Android, `isEnabled` checks if the location service is enabled (any accuracy level). For iOS, the method checks if the location service is enabled for the application in foreground or background mode. +> **注意:** 在Android平台下,`isEnabled`检测的是(任意精度等级)的位置服务是否启用。而在iOS中,这个方法检查的是你的应用在前台或者后台等任意一种状态下位置服务是否启用。 + ## Requesting permissions to use location services +## 获取使用位置服务的权限 + By default, the `nativescript-geolocation` plugin adds the required permissions in `AndroidManiest.xml` for Android and `Info.plist` for iOS. For iOS, the plugin adds two dummy string values which serve as the message when the platform asks for permission to use location services. You can edit this message later. +`nativescript-geolocation`会默认在Android平台下的`AndroidManiest.xml`和iOS平台下的`Info.plist`中添加所需的权限。此外,在iOS平台下,插件添加了两个空字符串作为平台向用户请求位置服务权限时使用的提示语句。你可以事后对其进行修改。 + After you install the plugin, you can request to use location services in the app with the code in __Example 1__: + +在你完成插件的安装后,你可以使用__样例1__中的代码来请求使用位置服务。 + > Example 1: How to enable location service on a device + +> 样例1:如何在设备启用位置服务 + {% nativescript %} ```XML <Page> @@ -78,8 +114,12 @@ exports.enableLocationTap = enableLocationTap; ## Getting location +## 获取定位 + You can get location with `getCurrentLocation` or with `watchLocation`. Using `distance`, you can obtain the distance between two locations. +你可以通过使用`getCurrentLocation`或`watchLocation`方法来获取位置信息。通过使用`distance`方法来获取两个位置之间的距离。 + * [getCurrentLocation](#getcurrentlocation) * [watchLocation](#watchlocation) * [distance](#distance) @@ -88,12 +128,20 @@ You can get location with `getCurrentLocation` or with `watchLocation`. Using `d This method gets a single location. It accepts the `location options` parameter. +这个方法获取单个位置信息。方法接受`location options`参数。 + `getCurrentLocation` returns a `Promise<Location>` where `Location` and `location options` are defined as follows. +`getCurrentLocation`返回一个`Promise<Location>`。`Location`和`location options`的定义如下. + #### Class: location +#### 类: location A data class that encapsulates common properties for a geolocation. +一个包含地理位置基本信息的数据类。 + ##### Instance properties +##### 实例属性 Property | Type | Description ---|---|--- @@ -108,10 +156,28 @@ Property | Type | Description `android` | Object | The Android-specific [location](http://developer.android.com/reference/android/location/Location.html) object. `ios` | CLLocation | The iOS-specific [CLLocation](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/) object. + +属性 | 类型 | 描述 +---|---|--- +`latitude` | Number | 纬度,以角度为单位 +`longitude` | Number | 纬度,以角度为单位 +`altitude` | Number | 海拔(如果可用),以米为单位 +`horizontalAccuracy` | Number | 水平精度,以米为单位 +`verticalAccuracy` | Number | 垂直精度,以米为单位 +`speed` | Number | 速度,以米每秒为单位 +`direction` | Number | 方向(航向),以角度为单位 +`timestamp` | Object | 此位置获取完成时候的时间戳 +`android` | Object | Android特有[位置](http://developer.android.com/reference/android/location/Location.html)对象 + `ios` | CLLocation | iOS特有[位置](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/)对象 + #### Interface: options +#### 接口: options Provides options for location monitoring. +为位置检测提供的选项 + ##### Properties +##### 属性 Property | Type | Description ---|---|--- @@ -121,7 +187,18 @@ Property | Type | Description `maximumAge` | Number | (Optional) Filters locations by how long ago they were received, in milliseconds. For example, if the `maximumAge` is 5000, you will get locations only from the last 5 seconds. `timeout` | Number | (Optional) Specifies how long to wait for a location, in milliseconds. +属性 | 类型 | 描述 +---|---|--- +`desiredAccuracy` | Number | (可选的)制定所需的精度,以米为单位. NativeScript有一个特殊的枚举类型[Accuracy](http://docs.nativescript.org/api-reference/modules/_ui_enums_.accuracy.html)来帮助提高代码的可读性。默认设为`Accuracy.any`。这样的精度可以通过WiFi和辅助GPS来实现,不会对电池消耗造成额外的压力。若要使用高精度模式(需要GPS传感器)请将其设置为`Accuracy.high`. +`updateDistance` | Number | (可选的) 更新距离筛选器,以米为单位。指定更新的频率。在iOS中无法筛选,在Android中默认为0米。 +`minimumUpdateTime` | Number | (可选的) 设置位置信息更新的最小间隔时间,以毫秒为单位。在iOS中会被忽略。 +`maximumAge` | Number | (可选的) 筛选多少时间内我们获取到的位置信息,以毫秒为单位。例如,如果`maximumAge`设置为5000,你只会获取到5秒内获取到的位置数据。 +`timeout` | Number | (可选的) 设置获取位置的最大等待时间,以毫秒为单位 + > Example 2: How to get current location + +> 样例2:如何获取当前位置 + {% nativescript %} ```XML <Page> @@ -166,9 +243,15 @@ exports.buttonGetLocationTap = buttonGetLocationTap; ### `watchLocation` +### `监视位置` + With this method, location watching does not stop automatically until the `clearWatch` method is called. You might need to use this method in apps which require a GPS log or active location tracking. -> Example 3: How to handle location chnage event +通过使用这个方法,位置监视会一直生效不会自动停止,直到你调用了`clearWatch`方法。 你可能在App中会需要使用这个方法来获取GPS日志或者跟踪实时位置。 + +> Example 3: How to handle location change event + +> 样例3:如何处理位置发生变化的事件 {% nativescript %} ```XML @@ -233,9 +316,15 @@ exports.buttonStopTap = buttonStopTap; ### `distance` +### `距离` + This method lets you measure the distance between two locations in meters. -> Example 4: How to get distance between to too location +这个方法为你计算两个位置之间以米作为单位的距离。 + +> Example 4: How to get distance between to two location + +> 样例4:获取两个位置之间的距离 {% nativescript %} ```JavaScript @@ -252,6 +341,8 @@ function getDistance(loc1, loc2) { ## See Also +## 参考资料 + * [NativeScript Plugins](http://docs.nativescript.org/plugins/plugins) * [Location Module (Deprecated)](http://docs.nativescript.org/api-reference/modules/_location_.html) * [NativeScript-Geolocation in NPM](https://www.npmjs.com/package/nativescript-geolocation) From b2be0add7d2f02a7f6d62e7009b3fafe3f282f82 Mon Sep 17 00:00:00 2001 From: Hui Zhong <xanogayu@live.com> Date: Tue, 26 Sep 2017 15:25:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?location.md=E6=A0=A1=E8=AE=A2=EF=BC=8Ctutor?= =?UTF-8?q?ial=E7=AB=A0=E8=8A=82=E7=9A=84ng-chapter-0.md=E5=88=9D=E7=BF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/hardware/location.md | 62 ++++++++++++++++------------------- docs/tutorial/ng-chapter-0.md | 50 ++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 33 deletions(-) diff --git a/docs/hardware/location.md b/docs/hardware/location.md index 382cf8c3f..286a993fd 100644 --- a/docs/hardware/location.md +++ b/docs/hardware/location.md @@ -12,19 +12,19 @@ previous_url: /location > **IMPORTANT:** Starting with NativeScript 1.5.0, the built-in Location module is deprecated. To implement geolocation in your apps, use the `nativescript-geolocation` plugin, available via npm. This plugin provides an API similar to the [W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html). -> **重要信息:** 从NativeScript 1.5.0版本开始, 内建的地理位置模块将被弃用. 若需要在您的应用中实现地理位置处理相关功能, 可以通过npm安装使用`nativescript-geolocation`插件。 该插件提供了类似于[W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html)的API。 +> **重要信息:** 内建的地理位置模块将从NativeScript 1.5.0版本开始被弃用。若要在应用中实现地理位置处理功能, 可用npm安装`nativescript-geolocation`插件。该插件提供了类似于[W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html)的API。 The most important difference between the deprecated module and the new plugin is that location monitoring via the plugin returns an `id` that you can use to stop location monitoring. The `nativescript-geolocation` plugin also uses an accuracy criteria approach to deliver geolocation. This means that getting a location is powered by the most accurate location provider that is available. For example, if a GPS signal is available and the GPS provider is enabled, the plugin uses GPS; if GPS is not connected, the device falls back to other available providers such as Wi-Fi networks or cell towers). -被弃用的模块和新启用的插件之间最大的区别在于,通过插件获取到的位置监控器返回一个`id`,你可以通过使用这个`id`来结束位置监控器。此外,`nativescript-geolocation`插件还通过使用一种高精度标准的方式来提供地理位置信息。这意味着获取的位置信息由当前可用的最精确的位置提供者提供。例如,如果可以获取到GPS信号而且GPS提供者被启用,则插件使用GPS;如果GPS无法连接,则设备使用其他可用的提供者例如Wi-Fi网络或者蜂窝网络信号塔。 +被弃用的模块和新启用的插件之间最大的区别在于,通过插件获取到的位置监控器返回一个`id`,这个`id`可以用来停止位置监控器。此外,`nativescript-geolocation`插件还通过使用一种高精度标准的方式来提供地理位置信息。这意味着获取的位置信息由当前可用的最精确的位置提供者提供。例如,如果可以获取到GPS信号而且GPS提供者被启用,则插件使用GPS;如果GPS无法连接,则设备使用其他可用的提供者,例如Wi-Fi网络或者蜂窝网络信号塔。 This approach does not limit location monitoring only to a specific location provider; it can still work with all of them. -这种方式并不是要限制位置监控器,使其使用某个特定的位置提供者;所有的位置提供者均被会使用。 +但这种方式并不会把位置监控器限定为某个特定的位置提供者,而是仍使用全部的。 You might want to start with this [example](https://github.com/nsndeck/locationtest), which demonstrates how to use the `nativescript-geolocation` plugin. -你可能会希望通过一个教你如何使用`nativescript-geolocation`插件的[示例](https://github.com/nsndeck/locationtest)来开始了解这一部分的内容。 +你可能会希望通过一个[示例](https://github.com/nsndeck/locationtest)来学会如何使用`nativescript-geolocation`插件。 To make the plugin available in your app, run the following command: @@ -40,7 +40,7 @@ tns plugin add nativescript-geolocation To import the module in your code, use: -在代码中引入插件: +之后在代码中引入插件: {% nativescript %} ```JavaScript @@ -58,11 +58,11 @@ import { isEnabled, enableLocationRequest, getCurrentLocation, watchLocation, di NativeScript has a universal way to check if location services are turned on—the `isEnabled` method. The method returns a Boolean value (true if the location service is enabled). -在NativeScript中使用`isEnabled`这样一个通用的方法来检查位置服务是否开启。方法会返回一个`Boolean`类型的值(如果位置服务已开启则返回`true`)。 +在NativeScript中使用了`isEnabled`这个通用方法来检查位置服务是否开启。方法会返回一个`Boolean`类型的值(如果位置服务已开启则返回`true`)。 > **NOTE:** For Android, `isEnabled` checks if the location service is enabled (any accuracy level). For iOS, the method checks if the location service is enabled for the application in foreground or background mode. -> **注意:** 在Android平台下,`isEnabled`检测的是(任意精度等级)的位置服务是否启用。而在iOS中,这个方法检查的是你的应用在前台或者后台等任意一种状态下位置服务是否启用。 +> **注意:** 在Android平台下,`isEnabled`检测的是(任意精度等级)的位置服务是否启用。而在iOS中,这个方法检查的是应用在前台或者后台等任意状态下位置服务是否启用。 ## Requesting permissions to use location services @@ -70,15 +70,15 @@ NativeScript has a universal way to check if location services are turned on&mda By default, the `nativescript-geolocation` plugin adds the required permissions in `AndroidManiest.xml` for Android and `Info.plist` for iOS. For iOS, the plugin adds two dummy string values which serve as the message when the platform asks for permission to use location services. You can edit this message later. -`nativescript-geolocation`会默认在Android平台下的`AndroidManiest.xml`和iOS平台下的`Info.plist`中添加所需的权限。此外,在iOS平台下,插件添加了两个空字符串作为平台向用户请求位置服务权限时使用的提示语句。你可以事后对其进行修改。 +`nativescript-geolocation`会默认在Android平台下的`AndroidManiest.xml`和iOS平台下的`Info.plist`中添加所需的权限。此外,在iOS平台下,插件添加了两个空字符串作为提示语句,它们将会在平台向用户请求位置服务权限时使用。你可以事后对其进行修改。 After you install the plugin, you can request to use location services in the app with the code in __Example 1__: -在你完成插件的安装后,你可以使用__样例1__中的代码来请求使用位置服务。 +在完成插件的安装后,你可以使用__样例1__中的代码来请求使用位置服务。 > Example 1: How to enable location service on a device -> 样例1:如何在设备启用位置服务 +> 样例1:如何在设备中启用位置服务 {% nativescript %} ```XML @@ -118,7 +118,7 @@ exports.enableLocationTap = enableLocationTap; You can get location with `getCurrentLocation` or with `watchLocation`. Using `distance`, you can obtain the distance between two locations. -你可以通过使用`getCurrentLocation`或`watchLocation`方法来获取位置信息。通过使用`distance`方法来获取两个位置之间的距离。 +你可以通过`getCurrentLocation`或`watchLocation`方法来获取位置信息,并通过`distance`方法来获取两个位置之间的距离。 * [getCurrentLocation](#getcurrentlocation) * [watchLocation](#watchlocation) @@ -128,11 +128,11 @@ You can get location with `getCurrentLocation` or with `watchLocation`. Using `d This method gets a single location. It accepts the `location options` parameter. -这个方法获取单个位置信息。方法接受`location options`参数。 +此方法用来获取单个位置信息,它接受`location options`参数。 `getCurrentLocation` returns a `Promise<Location>` where `Location` and `location options` are defined as follows. -`getCurrentLocation`返回一个`Promise<Location>`。`Location`和`location options`的定义如下. +`getCurrentLocation`方法返回`Promise<Location>`。对`Location`和`location options`的定义如下。 #### Class: location #### 类: location @@ -159,22 +159,22 @@ Property | Type | Description 属性 | 类型 | 描述 ---|---|--- -`latitude` | Number | 纬度,以角度为单位 -`longitude` | Number | 纬度,以角度为单位 -`altitude` | Number | 海拔(如果可用),以米为单位 -`horizontalAccuracy` | Number | 水平精度,以米为单位 -`verticalAccuracy` | Number | 垂直精度,以米为单位 -`speed` | Number | 速度,以米每秒为单位 -`direction` | Number | 方向(航向),以角度为单位 -`timestamp` | Object | 此位置获取完成时候的时间戳 -`android` | Object | Android特有[位置](http://developer.android.com/reference/android/location/Location.html)对象 - `ios` | CLLocation | iOS特有[位置](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/)对象 +`latitude` | Number | 纬度,以度数(deg)为单位。 +`longitude` | Number | 经度,以度数(deg)为单位。 +`altitude` | Number | 海拔(如果可用),以米为单位。 +`horizontalAccuracy` | Number | 水平精度,以米为单位。 +`verticalAccuracy` | Number | 垂直精度,以米为单位。 +`speed` | Number | 速度,以米每秒为单位。 +`direction` | Number | 方向(航向),以度数(deg)为单位。 +`timestamp` | Object | 刚刚取到此位置时的时间戳。 +`android` | Object | Android特有[位置](http://developer.android.com/reference/android/location/Location.html)对象。 + `ios` | CLLocation | iOS特有[位置](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/)对象。 #### Interface: options #### 接口: options Provides options for location monitoring. -为位置检测提供的选项 +为位置检测提供的选项。 ##### Properties ##### 属性 @@ -189,11 +189,11 @@ Property | Type | Description 属性 | 类型 | 描述 ---|---|--- -`desiredAccuracy` | Number | (可选的)制定所需的精度,以米为单位. NativeScript有一个特殊的枚举类型[Accuracy](http://docs.nativescript.org/api-reference/modules/_ui_enums_.accuracy.html)来帮助提高代码的可读性。默认设为`Accuracy.any`。这样的精度可以通过WiFi和辅助GPS来实现,不会对电池消耗造成额外的压力。若要使用高精度模式(需要GPS传感器)请将其设置为`Accuracy.high`. +`desiredAccuracy` | Number | (可选的)指定所需的精度,以米为单位。NativeScript有一个特殊的枚举类型[Accuracy](http://docs.nativescript.org/api-reference/modules/_ui_enums_.accuracy.html)来帮助提高代码的可读性。默认设为`Accuracy.any`。这样的精度可以通过WiFi和辅助GPS来实现,不会对电池消耗造成额外的压力。若要使用高精度模式(需要GPS传感器)请将其设置为`Accuracy.high`。 `updateDistance` | Number | (可选的) 更新距离筛选器,以米为单位。指定更新的频率。在iOS中无法筛选,在Android中默认为0米。 `minimumUpdateTime` | Number | (可选的) 设置位置信息更新的最小间隔时间,以毫秒为单位。在iOS中会被忽略。 `maximumAge` | Number | (可选的) 筛选多少时间内我们获取到的位置信息,以毫秒为单位。例如,如果`maximumAge`设置为5000,你只会获取到5秒内获取到的位置数据。 -`timeout` | Number | (可选的) 设置获取位置的最大等待时间,以毫秒为单位 +`timeout` | Number | (可选的) 设置获取位置的最大等待时间,以毫秒为单位。 > Example 2: How to get current location @@ -243,11 +243,9 @@ exports.buttonGetLocationTap = buttonGetLocationTap; ### `watchLocation` -### `监视位置` - With this method, location watching does not stop automatically until the `clearWatch` method is called. You might need to use this method in apps which require a GPS log or active location tracking. -通过使用这个方法,位置监视会一直生效不会自动停止,直到你调用了`clearWatch`方法。 你可能在App中会需要使用这个方法来获取GPS日志或者跟踪实时位置。 +使用此方法会让位置监视一直生效,直到你调用了`clearWatch`方法才会停止。在App中可能需要通过它来实现GPS日志获取或者实时位置跟踪。 > Example 3: How to handle location change event @@ -316,11 +314,9 @@ exports.buttonStopTap = buttonStopTap; ### `distance` -### `距离` - This method lets you measure the distance between two locations in meters. -这个方法为你计算两个位置之间以米作为单位的距离。 +此方法用来计算两个位置之间距离,以米为单位。 > Example 4: How to get distance between to two location @@ -341,7 +337,7 @@ function getDistance(loc1, loc2) { ## See Also -## 参考资料 +## 其他参考 * [NativeScript Plugins](http://docs.nativescript.org/plugins/plugins) * [Location Module (Deprecated)](http://docs.nativescript.org/api-reference/modules/_location_.html) diff --git a/docs/tutorial/ng-chapter-0.md b/docs/tutorial/ng-chapter-0.md index 34a5c06ee..822d7704f 100644 --- a/docs/tutorial/ng-chapter-0.md +++ b/docs/tutorial/ng-chapter-0.md @@ -8,53 +8,103 @@ environment: angular # Building Apps with NativeScript and Angular +# 使用NativeScript和Angular来构建应用 + Welcome to the NativeScript & Angular getting started guide. In this hands-on tutorial, you’ll build a cross-platform iOS and Android app from scratch. +欢迎来到NativeScript与Angular快速上手教程。在这个实战教程中,你将会从头开始构建一个跨iOS与Android平台的App。 + ## Table of contents +## 目录 + - [0.1: What is NativeScript? What is Angular?](#01-what-is-nativescript-what-is-angular) +- [0.1: 什么是NativeScript?什么是Angular?](#01-what-is-nativescript-what-is-angular) - [0.2: Prerequisites](#02-prerequisites) +- [0.2: 前置知识](#02-prerequisites) - [0.3: Installation](#03-installation) +- [0.3: 安装](#03-installation) > **TIP**: If you’re a video learner, the third-party site NativeScripting has a [free video course](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide) that walks you through this guide step by step. +> **提示**: 如果你是一位视频方式学习者,第三方网站NativeScripting有一个[免费的视频课程](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide),它将会一步一步引导你完成本教程。 + ## 0.1: What is NativeScript? What is Angular? +## 0.1: 什么是NativeScript? 什么是Angular? + <div class="intro-box"> <img src="../img/cli-getting-started/angular/chapter0/NativeScript_logo.png" class="plain" alt="NativeScript logo"> <p><a href="https://www.nativescript.org/">NativeScript</a> is a free and open source framework for building native iOS and Android apps using JavaScript and CSS. NativeScript renders UIs with the native platform’s rendering engine—no <a href="http://developer.telerik.com/featured/what-is-a-webview/">WebViews</a>—resulting in native-like performance and UX.</p> </div> +<div class="intro-box"> + <img src="../img/cli-getting-started/angular/chapter0/NativeScript_logo.png" class="plain" alt="NativeScript logo"> + <p><a href="https://www.nativescript.org/">NativeScript</a>是一个免费、开源的框架,仅通过使用JavaScript和CSS就得以构建原生的iOS以及Android应用。NativeScript使用原生平台的渲染引擎来渲染用户界面—而不是<a href="http://developer.telerik.com/featured/what-is-a-webview/">WebViews</a>—从而获取到接近原生的性能和用户体验。</p> +</div> + <div class="intro-box"> <img src="../img/cli-getting-started/angular/chapter0/Angular_logo.png" class="plain" alt="Angular logo"> <p><a href="https://angular.io/">Angular</a> is one of the most popular open source JavaScript frameworks for application development. The latest version of Angular makes it possible to use the framework outside of a web browser, and developers at <a href="https://www.progress.com/">Progress</a>—the company that created and maintains NativeScript—<a href="http://angularjs.blogspot.com/2015/12/building-mobile-apps-with-angular-2-and.html">worked closely with developers at Google for over a year</a> to make Angular in NativeScript a reality.</p> </div> +<div class="intro-box"> + <img src="../img/cli-getting-started/angular/chapter0/Angular_logo.png" class="plain" alt="Angular logo"> + <p><a href="https://angular.io/">Angular</a>是用于构建应用的最流行的开源JavaScript框架之一。最新版本的Angular可以在浏览器环境外使用,经过<a href="https://www.progress.com/">Progress</a>—创建和维护NativeScript的公司—<a href="http://angularjs.blogspot.com/2015/12/building-mobile-apps-with-angular-2-and.html">的开发者与Google的开发者一年多的紧密合作,</a>使得在NativeScript中使用Angular成为现实。</p> +</div> + The result is a software architecture that allows you to build mobile apps using the same framework—and in some cases the same code—that you use to build Angular web apps, with the performance you’d expect from native code. Let’s look at how it all works by building an app. +这所带来的结果就是能够把用于构建Angular Web应用的框架——或者代码——使用到构建移动应用中去,同时得到你所期望的原生代码的性能。现在我们来了解如何使用它来构建一个应用。 + > **NOTE**: If you spot any issues while completing this guide, let us know on our [Angular GitHub repo](https://github.com/NativeScript/nativescript-angular/issues). +> **注意**: 如果在完成引导的过程中遇到什么问题,请提交issue到[Angular GitHub repo](https://github.com/NativeScript/nativescript-angular/issues)让我们知道。 + ## 0.2: Prerequisites +## 0.2: 前置知识 + This guide assumes that you have some basic knowledge of JavaScript, CSS, and your development machine’s terminal. More specifically: +这份教程会假设你已经拥有了一些JavaScript、CSS和终端的一些基础知识。详细的有: + * **JavaScript**: You should know basic JavaScript concepts, such as how functions, if statements, and loops work. +* **JavaScript**: 了解JavaScript的基础概念,例如如何使用函数,if语句和循环。 * **CSS**: You should know how to write simple CSS selectors, and know how to apply CSS rules as name/value pairs. +* **CSS**: 知道如何写一些简单的CSS选择器, 同时也知道如何使用CSS规则例如键值对。 * **The terminal**: You should know how to open a terminal or command-line prompt on your development machine, how to change directories, and how to execute commands. +* **终端**: 需要知道如何在你的开发设备上打开终端或者命令行工具,如何切换路径以及如何执行命令。 * **A text editor or IDE**: You should know the basics of your text editor or IDE of choice. You can use any text editor to build NativeScript apps, however, for the best possible experience you may want an editor with built-in TypeScript support, such as [Visual Studio Code](https://code.visualstudio.com/). +* **一个文本编辑器或者集成开发环境**: 对你所选的文本编辑器或者集成开发环境有基本的了解。你可以使用任何一个文本编辑器来构建NativeScript应用,但是通过经验来看你最好选择一个内建TypeScript支持的编辑器例如[Visual Studio Code](https://code.visualstudio.com/)。 This guide will _not_ assume you have any knowledge of Angular or TypeScript. When background Angular or TypeScript expertise will help you understand a concept, this guide will link you to the appropriate places in the [Angular](https://angular.io/docs/ts/latest/) or [TypeScript](http://www.typescriptlang.org/Handbook) documentation. +这份引导_不_假设你有任何关于Angular或者TypeScript的知识。当需要Angular或TypeScript的专业知识作为背景帮你了解一些概念的时候,这份引导将会给出一个适当的[Angular](https://angular.io/docs/ts/latest/)或[TypeScript](http://www.typescriptlang.org/Handbook)文档链接供你参考。 + ## 0.3: Installation +## 0.3: 安装 + In order to start this tutorial you need to have the NativeScript CLI (command-line interface) installed on your development machine, which you can do using the link below. +在开始教程前需要将NativeScript CLI(命令行界面)安装到你的开发设备上。可以按照下面提供的链接完成安装。 + * [Complete the NativeScript installation guide](/start/quick-setup) +* [引导你完成NativeScript的安装](/start/quick-setup) > **TIP**: Setting up your machine for native development can be tricky, especially if you’re new to mobile development. If you get stuck, or if you have questions while going through these instructions, the [NativeScript community forum](http://forum.nativescript.org/) is a great place to get help. +> **提示**: 配置原生开发的过程中可能会有奇怪的问题,特别是对移动开发陌生的情况下。如果你遇到困难,或者在学习过程中碰到一些问题,[NativeScript community forum](http://forum.nativescript.org/)将会是个获取帮助的好去处。 + With that out of the way, let’s get started building apps with NativeScript! +搞定以上这些,就让我们开始用NativeScript构建应用吧! + <div class="next-chapter-link-container"> <a href="ng-chapter-1">Continue to Chapter 1—Getting Up and Running</a> </div> + +<div class="next-chapter-link-container"> + <a href="ng-chapter-1">继续第一章—开始和运行</a> +</div> From f9924b8fd3d2d7ed96db350a65dd4792dd7ad479 Mon Sep 17 00:00:00 2001 From: Hui Zhong <xanogayu@live.com> Date: Tue, 26 Sep 2017 15:56:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AF=B9ng-chapter-0.md=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=87=AA=E6=88=91=E6=A0=A1=E8=AE=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/hardware/location.md | 2 +- docs/tutorial/ng-chapter-0.md | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/hardware/location.md b/docs/hardware/location.md index 286a993fd..4946ff012 100644 --- a/docs/hardware/location.md +++ b/docs/hardware/location.md @@ -12,7 +12,7 @@ previous_url: /location > **IMPORTANT:** Starting with NativeScript 1.5.0, the built-in Location module is deprecated. To implement geolocation in your apps, use the `nativescript-geolocation` plugin, available via npm. This plugin provides an API similar to the [W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html). -> **重要信息:** 内建的地理位置模块将从NativeScript 1.5.0版本开始被弃用。若要在应用中实现地理位置处理功能, 可用npm安装`nativescript-geolocation`插件。该插件提供了类似于[W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html)的API。 +> **重要信息:** 内建的地理位置模块将从NativeScript 1.5.0版本开始被弃用。若要在应用中实现地理位置处理功能, 可用npm安装`nativescript-geolocation`插件。该插件提供了与[W3C Geolocation API](http://dev.w3.org/geo/api/spec-source.html)相仿的API。 The most important difference between the deprecated module and the new plugin is that location monitoring via the plugin returns an `id` that you can use to stop location monitoring. The `nativescript-geolocation` plugin also uses an accuracy criteria approach to deliver geolocation. This means that getting a location is powered by the most accurate location provider that is available. For example, if a GPS signal is available and the GPS provider is enabled, the plugin uses GPS; if GPS is not connected, the device falls back to other available providers such as Wi-Fi networks or cell towers). diff --git a/docs/tutorial/ng-chapter-0.md b/docs/tutorial/ng-chapter-0.md index 822d7704f..f964be35c 100644 --- a/docs/tutorial/ng-chapter-0.md +++ b/docs/tutorial/ng-chapter-0.md @@ -12,7 +12,7 @@ environment: angular Welcome to the NativeScript & Angular getting started guide. In this hands-on tutorial, you’ll build a cross-platform iOS and Android app from scratch. -欢迎来到NativeScript与Angular快速上手教程。在这个实战教程中,你将会从头开始构建一个跨iOS与Android平台的App。 +欢迎来到NativeScript与Angular快速上手教程。在这个实战教程中,你将会从头开始构建一个横跨iOS与Android平台的App。 ## Table of contents @@ -27,7 +27,7 @@ Welcome to the NativeScript & Angular getting started guide. In this hands-on tu > **TIP**: If you’re a video learner, the third-party site NativeScripting has a [free video course](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide) that walks you through this guide step by step. -> **提示**: 如果你是一位视频方式学习者,第三方网站NativeScripting有一个[免费的视频课程](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide),它将会一步一步引导你完成本教程。 +> **提示**: 如果你喜欢用视频的方式进行学习,在第三方网站NativeScripting中有一个[免费的视频课程](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide),它可以一步一步教程你完成本教程。 ## 0.1: What is NativeScript? What is Angular? @@ -40,7 +40,7 @@ Welcome to the NativeScript & Angular getting started guide. In this hands-on tu <div class="intro-box"> <img src="../img/cli-getting-started/angular/chapter0/NativeScript_logo.png" class="plain" alt="NativeScript logo"> - <p><a href="https://www.nativescript.org/">NativeScript</a>是一个免费、开源的框架,仅通过使用JavaScript和CSS就得以构建原生的iOS以及Android应用。NativeScript使用原生平台的渲染引擎来渲染用户界面—而不是<a href="http://developer.telerik.com/featured/what-is-a-webview/">WebViews</a>—从而获取到接近原生的性能和用户体验。</p> + <p><a href="https://www.nativescript.org/">NativeScript</a>是一个免费、开源的框架,它通过使用JavaScript和CSS来构建原生的iOS以及Android应用。NativeScript使用原生平台的渲染引擎—而不是<a href="http://developer.telerik.com/featured/what-is-a-webview/">WebViews</a>—来渲染用户界面,从而得到接近原生的性能和用户体验。</p> </div> <div class="intro-box"> @@ -50,16 +50,16 @@ Welcome to the NativeScript & Angular getting started guide. In this hands-on tu <div class="intro-box"> <img src="../img/cli-getting-started/angular/chapter0/Angular_logo.png" class="plain" alt="Angular logo"> - <p><a href="https://angular.io/">Angular</a>是用于构建应用的最流行的开源JavaScript框架之一。最新版本的Angular可以在浏览器环境外使用,经过<a href="https://www.progress.com/">Progress</a>—创建和维护NativeScript的公司—<a href="http://angularjs.blogspot.com/2015/12/building-mobile-apps-with-angular-2-and.html">的开发者与Google的开发者一年多的紧密合作,</a>使得在NativeScript中使用Angular成为现实。</p> + <p><a href="https://angular.io/">Angular</a>是最流行的JavaScript应用开发开源框架之一。最新版本的Angular可以脱离浏览器使用。在经过<a href="https://www.progress.com/">Progress</a>—创建和维护NativeScript的公司—<a href="http://angularjs.blogspot.com/2015/12/building-mobile-apps-with-angular-2-and.html">的开发者与Google的开发者一年多的紧密合作,</a>使得在NativeScript中使用Angular成为现实。</p> </div> The result is a software architecture that allows you to build mobile apps using the same framework—and in some cases the same code—that you use to build Angular web apps, with the performance you’d expect from native code. Let’s look at how it all works by building an app. -这所带来的结果就是能够把用于构建Angular Web应用的框架——或者代码——使用到构建移动应用中去,同时得到你所期望的原生代码的性能。现在我们来了解如何使用它来构建一个应用。 +因此,我们可以用相同的框架——甚至是相同代码——来同时构建Angular Web应用和移动应用,并且得到你所期望的原生代码的性能。现在我们来了解如何用它来构建应用。 > **NOTE**: If you spot any issues while completing this guide, let us know on our [Angular GitHub repo](https://github.com/NativeScript/nativescript-angular/issues). -> **注意**: 如果在完成引导的过程中遇到什么问题,请提交issue到[Angular GitHub repo](https://github.com/NativeScript/nativescript-angular/issues)让我们知道。 +> **注意**: 如果在完成教程的过程中遇到什么问题,请提交issue到[Angular GitHub repo](https://github.com/NativeScript/nativescript-angular/issues)让我们知道。 ## 0.2: Prerequisites @@ -67,7 +67,7 @@ The result is a software architecture that allows you to build mobile apps using This guide assumes that you have some basic knowledge of JavaScript, CSS, and your development machine’s terminal. More specifically: -这份教程会假设你已经拥有了一些JavaScript、CSS和终端的一些基础知识。详细的有: +本教程会假设你已经拥有了一些JavaScript、CSS和终端的基础知识。详细的有: * **JavaScript**: You should know basic JavaScript concepts, such as how functions, if statements, and loops work. * **JavaScript**: 了解JavaScript的基础概念,例如如何使用函数,if语句和循环。 @@ -80,7 +80,7 @@ This guide assumes that you have some basic knowledge of JavaScript, CSS, and yo This guide will _not_ assume you have any knowledge of Angular or TypeScript. When background Angular or TypeScript expertise will help you understand a concept, this guide will link you to the appropriate places in the [Angular](https://angular.io/docs/ts/latest/) or [TypeScript](http://www.typescriptlang.org/Handbook) documentation. -这份引导_不_假设你有任何关于Angular或者TypeScript的知识。当需要Angular或TypeScript的专业知识作为背景帮你了解一些概念的时候,这份引导将会给出一个适当的[Angular](https://angular.io/docs/ts/latest/)或[TypeScript](http://www.typescriptlang.org/Handbook)文档链接供你参考。 +本教程_并不_假设你有任何关于Angular或者TypeScript的知识。当需要Angular或TypeScript的专业知识作为背景帮你了解一些概念的时候,教程将会给出一个适当的[Angular](https://angular.io/docs/ts/latest/)或[TypeScript](http://www.typescriptlang.org/Handbook)文档链接供你参考。 ## 0.3: Installation @@ -88,14 +88,14 @@ This guide will _not_ assume you have any knowledge of Angular or TypeScript. Wh In order to start this tutorial you need to have the NativeScript CLI (command-line interface) installed on your development machine, which you can do using the link below. -在开始教程前需要将NativeScript CLI(命令行界面)安装到你的开发设备上。可以按照下面提供的链接完成安装。 +在开始教程前需要将NativeScript CLI(命令行界面)安装到你的开发设备上。可以参照下面链接中的内容完成安装。 * [Complete the NativeScript installation guide](/start/quick-setup) -* [引导你完成NativeScript的安装](/start/quick-setup) +* [带你完成NativeScript的安装](/start/quick-setup) > **TIP**: Setting up your machine for native development can be tricky, especially if you’re new to mobile development. If you get stuck, or if you have questions while going through these instructions, the [NativeScript community forum](http://forum.nativescript.org/) is a great place to get help. -> **提示**: 配置原生开发的过程中可能会有奇怪的问题,特别是对移动开发陌生的情况下。如果你遇到困难,或者在学习过程中碰到一些问题,[NativeScript community forum](http://forum.nativescript.org/)将会是个获取帮助的好去处。 +> **提示**: 配置原生开发环境的过程中可能会有奇怪的问题,特别是对移动开发陌生的情况下。如果你遇到困难,或者在学习过程中碰到一些问题,[NativeScript community forum](http://forum.nativescript.org/)将会是个获取帮助的好去处。 With that out of the way, let’s get started building apps with NativeScript! From f66de90a1efd4b585d496fca978ecf396c322a05 Mon Sep 17 00:00:00 2001 From: Hui Zhong <xanogayu@live.com> Date: Tue, 26 Sep 2017 16:30:29 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=94=A8=E8=AF=8D=E5=92=8C=E4=BF=AE=E6=AD=A3=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/hardware/location.md | 2 +- docs/tutorial/ng-chapter-0.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/hardware/location.md b/docs/hardware/location.md index 4946ff012..2fa7144a3 100644 --- a/docs/hardware/location.md +++ b/docs/hardware/location.md @@ -70,7 +70,7 @@ NativeScript has a universal way to check if location services are turned on&mda By default, the `nativescript-geolocation` plugin adds the required permissions in `AndroidManiest.xml` for Android and `Info.plist` for iOS. For iOS, the plugin adds two dummy string values which serve as the message when the platform asks for permission to use location services. You can edit this message later. -`nativescript-geolocation`会默认在Android平台下的`AndroidManiest.xml`和iOS平台下的`Info.plist`中添加所需的权限。此外,在iOS平台下,插件添加了两个空字符串作为提示语句,它们将会在平台向用户请求位置服务权限时使用。你可以事后对其进行修改。 +`nativescript-geolocation`会默认在Android平台下的`AndroidManiest.xml`和iOS平台下的`Info.plist`中添加所需的权限。此外,在iOS平台下,插件添加了两个空字符串作为提示语句,它们将会在平台向用户请求位置服务权限时使用。你可以在之后修改它。 After you install the plugin, you can request to use location services in the app with the code in __Example 1__: diff --git a/docs/tutorial/ng-chapter-0.md b/docs/tutorial/ng-chapter-0.md index f964be35c..f18f13634 100644 --- a/docs/tutorial/ng-chapter-0.md +++ b/docs/tutorial/ng-chapter-0.md @@ -12,7 +12,7 @@ environment: angular Welcome to the NativeScript & Angular getting started guide. In this hands-on tutorial, you’ll build a cross-platform iOS and Android app from scratch. -欢迎来到NativeScript与Angular快速上手教程。在这个实战教程中,你将会从头开始构建一个横跨iOS与Android平台的App。 +欢迎来到NativeScript与Angular快速上手教程。在本次实战中,你将会从头开始构建一个横跨iOS与Android平台的App。 ## Table of contents @@ -21,13 +21,13 @@ Welcome to the NativeScript & Angular getting started guide. In this hands-on tu - [0.1: What is NativeScript? What is Angular?](#01-what-is-nativescript-what-is-angular) - [0.1: 什么是NativeScript?什么是Angular?](#01-what-is-nativescript-what-is-angular) - [0.2: Prerequisites](#02-prerequisites) -- [0.2: 前置知识](#02-prerequisites) +- [0.2: 预备知识](#02-prerequisites) - [0.3: Installation](#03-installation) - [0.3: 安装](#03-installation) > **TIP**: If you’re a video learner, the third-party site NativeScripting has a [free video course](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide) that walks you through this guide step by step. -> **提示**: 如果你喜欢用视频的方式进行学习,在第三方网站NativeScripting中有一个[免费的视频课程](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide),它可以一步一步教程你完成本教程。 +> **提示**: 如果你喜欢用视频的方式进行学习,在第三方网站NativeScripting中有一个[免费的视频课程](https://nativescripting.com/course/nativescript-with-angular-getting-started-guide),它会一步一步带你完成本教程。 ## 0.1: What is NativeScript? What is Angular? @@ -63,7 +63,7 @@ The result is a software architecture that allows you to build mobile apps using ## 0.2: Prerequisites -## 0.2: 前置知识 +## 0.2: 预备知识 This guide assumes that you have some basic knowledge of JavaScript, CSS, and your development machine’s terminal. More specifically: