

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 如何以特定語言進行地理編碼
<a name="how-to-geocode-specific-language"></a>

此功能允許從 BCP47-compliant代碼中選擇偏好的回應語言。它會根據名稱變體偵測查詢語言，並針對不相符的字符和模棱兩可的案例使用偏好的語言。如果沒有請求的語言，**則 Places** API 會以官方國家/地區語言提供結果，但會優先考慮不同區域中的區域語言。作為備用策略，如果請求的語言中有任何地址元素無法使用，**則 Places** APIs會以預設語言傳回地址。

## 潛在的使用案例
<a name="potential-use-geocode-language"></a>

一個潛在的使用案例是將查詢和/或結果當地語系化。

## 範例
<a name="geocode-language-examples"></a>

### 取得特定語言的結果
<a name="geocode-language-result"></a>

------
#### [ Sample request ]

```
{
    "QueryText":"Patna, Bihar, Bharat",
    "Language": "HI"
}
```

------
#### [ Sample response ]

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "Locality",
            "Title": "पटना, बिहार, भारत",
            "Address": {
                "Label": "पटना, बिहार, भारत",
                "Country": {
                    "Code2": "IN",
                    "Code3": "IND",
                    "Name": "भारत"
                },
                "Region": {
                    "Code": "BR",
                    "Name": "बिहार"
                },
                "SubRegion": {
                    "Name": "पटना"
                },
                "Locality": "पटना",
                "PostalCode": "800001"
            },
            "Position": [
                85.13752,
                25.60134
            ],
            "MapView": [
                85.03222,
                25.55157,
                85.27107,
                25.65917
            ],
            "MatchScores": {
                "Overall": 1,
                "Components": {
                    "Address": {
                        "Country": 1,
                        "Region": 1,
                        "Locality": 1
                    }
                }
            }
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
    "QueryText":"Patna, Bihar, Bharat",
    "Language": "HI"
}'
```

------
#### [ AWS CLI ]

```
aws geo-places geocode --key ${YourKey} --query-text "पटना, बिहार, भारत" --language "HI"
```

------

### 以特定語言查詢
<a name="geocode-language-query"></a>

------
#### [ Sample request ]

```
{
    "QueryText":"पटना, बिहार, भारत"
}
```

------
#### [ Sample response ]

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "Locality",
            "Title": "Patana, Bihar, Bharat",
            "Address": {
                "Label": "Patana, Bihar, Bharat",
                "Country": {
                    "Code2": "IN",
                    "Code3": "IND",
                    "Name": "Bharat"
                },
                "Region": {
                    "Code": "BR",
                    "Name": "Bihar"
                },
                "SubRegion": {
                    "Name": "Patana"
                },
                "Locality": "Patana",
                "PostalCode": "800001"
            },
            "Position": [
                85.13752,
                25.60134
            ],
            "MapView": [
                85.03222,
                25.55157,
                85.27107,
                25.65917
            ],
            "MatchScores": {
                "Overall": 1,
                "Components": {
                    "Address": {
                        "Country": 1,
                        "Region": 1,
                        "Locality": 1
                    }
                }
            }
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
    "QueryText":"पटना, बिहार, भारत"
}'
```

------
#### [ AWS CLI ]

```
aws geo-places geocode --key ${YourKey} --query-text "पटना, बिहार, भारत"
```

------

### 查詢並產生特定語言
<a name="geocode-language-query-result"></a>

------
#### [ Sample request ]

```
{
    "QueryText":"पटना, बिहार, भारत",
    "Language": "HI"
}
```

------
#### [ Sample response ]

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "Locality",
            "Title": "पटना, बिहार, भारत",
            "Address": {
                "Label": "पटना, बिहार, भारत",
                "Country": {
                    "Code2": "IN",
                    "Code3": "IND",
                    "Name": "भारत"
                },
                "Region": {
                    "Code": "BR",
                    "Name": "बिहार"
                },
                "SubRegion": {
                    "Name": "पटना"
                },
                "Locality": "पटना",
                "PostalCode": "800001"
            },
            "Position": [
                85.13752,
                25.60134
            ],
            "MapView": [
                85.03222,
                25.55157,
                85.27107,
                25.65917
            ],
            "MatchScores": {
                "Overall": 1,
                "Components": {
                    "Address": {
                        "Country": 1,
                        "Region": 1,
                        "Locality": 1
                    }
                }
            }
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/geocode?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '{
    "QueryText":"पटना, बिहार, भारत",
    "Language": "HI"
}'
```

------
#### [ AWS CLI ]

```
aws geo-places geocode --key ${YourKey} --query-text "पटना, बिहार, भारत" --language "HI"
```

------