

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

# 如何以特定語言搜尋
<a name="how-to-search-specific-language"></a>

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

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

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

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

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

如果請求中沒有 `"Language": "EN"` 行，則會以希伯來文傳回結果。

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

```
{
    "QueryText": "Vegan",
        "BiasPosition":[    
                34.78953,
                32.08556
        ],
    "Language": "EN"
}
```

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

```
{
    "ResultItems": [
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointOfInterest",
            "Title": "Rainbow",
            "Address": {
                "Label": "Rainbow, Ibn Gabirol 88, 6404612 Tel Aviv-Yafo, Israel",
                "Country": {
                    "Code2": "IL",
                    "Code3": "ISR",
                    "Name": "Israel"
                },
                "Region": {
                    "Code": "TA",
                    "Name": "TA"
                },
                "SubRegion": {
                    "Name": "Tel Aviv"
                },
                "Locality": "Tel Aviv-Yafo",
                "District": "The New North-Southern Area",
                "PostalCode": "6404612",
                "Street": "Ibn Gabirol",
                "StreetComponents": [
                    {
                        "BaseName": "Ibn Gabirol",
                        "Language": "he-Latn"
                    }
                ],
                "AddressNumber": "88"
            },
            "Position": [
                34.78149,
                32.08252
            ],
            "Distance": 829,
            "Categories": [
                {
                    "Id": "restaurant",
                    "Name": "Restaurant",
                    "LocalizedName": "Restaurant",
                    "Primary": true
                },
                {
                    "Id": "fast_food",
                    "Name": "Fast Food",
                    "LocalizedName": "Fast Food",
                    "Primary": false
                }
            ],
            "FoodTypes": [
                {
                    "LocalizedName": "Vegan",
                    "Id": "vegan",
                    "Primary": true
                },
                {
                    "LocalizedName": "Fast Food",
                    "Id": "fast_food",
                    "Primary": false
                },
                {
                    "LocalizedName": "Burgers",
                    "Id": "burgers",
                    "Primary": false
                },
                {
                    "LocalizedName": "Jewish/Kosher",
                    "Id": "jewish/kosher",
                    "Primary": false
                }
            ]
        },
        {
            "PlaceId": "<Redacted>",
            "PlaceType": "PointOfInterest",
            "Title": "Alegria",
            "Address": {
                "Label": "Alegria, Ibn Gabirol 165, 6203305 Tel Aviv-Yafo, Israel",
                "Country": {
                    "Code2": "IL",
                    "Code3": "ISR",
                    "Name": "Israel"
                },
                "Region": {
                    "Code": "TA",
                    "Name": "TA"
                },
                "SubRegion": {
                    "Name": "Tel Aviv"
                },
                "Locality": "Tel Aviv-Yafo",
                "District": "The Old North-Northern Area",
                "PostalCode": "6203305",
                "Street": "Ibn Gabirol",
                "StreetComponents": [
                    {
                        "BaseName": "Ibn Gabirol",
                        "Language": "he-Latn"
                    }
                ],
                "AddressNumber": "165"
            },
            "Position": [
                34.78295,
                32.0923
            ],
            "Distance": 973,
            "Categories": [
                {
                    "Id": "restaurant",
                    "Name": "Restaurant",
                    "LocalizedName": "Restaurant",
                    "Primary": true
                },
                {
                    "Id": "coffee_shop",
                    "Name": "Coffee Shop",
                    "LocalizedName": "Coffee Shop",
                    "Primary": false
                },
                {
                    "Id": "specialty_food_store",
                    "Name": "Specialty Food Store",
                    "LocalizedName": "Specialty Food Store",
                    "Primary": false
                },
                {
                    "Id": "bakery_and_baked_goods_store",
                    "Name": "Bakery and Baked Goods Store",
                    "LocalizedName": "Bakery & Baked Goods Store",
                    "Primary": false
                }
            ],
            "FoodTypes": [
                {
                    "LocalizedName": "Vegan",
                    "Id": "vegan",
                    "Primary": true
                }
            ]
        }
    ]
}
```

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

```
curl --request POST \
  --url 'https://places.geo.eu-central-1.amazonaws.com/v2/search-text?key=Your_Key' \
  --header 'Content-Type: application/json' \
  --data '
        {
            "QueryText": "Vegan",
                "BiasPosition":[    
                        34.78953,
                        32.08556
                ],
            "Language": "EN"
        }'
```

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

```
aws geo-places search-text --key ${YourKey} --query-text "Vegan" \
--bias-position 34.78953 32.08556 \
--language "EN"
```

------