View a markdown version of this page

如何取得地址翻譯 - Amazon Location Service

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

如何取得地址翻譯

AddressTranslations 可讓您擷取所有可用語言之地址元件的所有名稱轉譯和替代名稱。您可以使用 AddressTranslations請求參數指定要翻譯的地址元件。

潛在的使用案例

  • 多語言應用程式:為國際使用者顯示多種語言的地址元件。

  • 當地語系化:顯示城市和區域的當地語言和user-preferred-language名稱。

範例

Sample request
{ "QueryText": "1 Rue de Rivoli, Paris", "AddressTranslations": ["Locality", "Region"] }
Sample response
{ "ResultItems": [ { "PlaceId": "<Redacted>", "PlaceType": "PointAddress", "Title": "1 Rue de Rivoli, 75004 Paris, France", "Translations": { "Locality": [ { "Names": [ { "Value": "Paris", "Language": "fr", "Type": "BaseName", "Primary": true }, { "Value": "Parigi", "Language": "it", "Type": "Exonym" }, { "Value": "パリ", "Language": "ja", "Type": "Exonym" } ], "Preference": "Primary" } ], "Region": [ { "Names": [ { "Value": "Île-de-France", "Language": "fr", "Type": "BaseName", "Primary": true }, { "Value": "IDF", "Language": "fr", "Type": "Abbreviation" } ], "Preference": "Primary" } ] } } ] }
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": "1 Rue de Rivoli, Paris", "AddressTranslations": ["Locality", "Region"] }'
AWS CLI
aws geo-places geocode --key ${YourKey} --query-text "1 Rue de Rivoli, Paris" --address-translations Locality Region

開發人員秘訣

  • 的有效值AddressTranslationsDistrictRegionLocalitySubRegion

  • 每個翻譯都包含一個Type欄位,指出名稱變體的類型: BaseName(官方名稱)Abbreviation、、 Exonym(翻譯為另一種語言)Shortened、 或 Synonym

  • Primary 欄位指出指定語言的主要名稱變體。