简体   繁体   中英

Localization translation for Google Analytics API data

I'm using the Google APIs PHP client library , trying to get data out of the Google Analytics API.

When I request fe ga:city as a dimension, I get a list of all the city names. The city names are however in English, and not in the local language.

Is it possible to set a locale? Or is it even not possible with Google API in general?

The Google Analytics API returns data in English only. You will have to translate them yourself.

Tip : If you are going to do some kind of translation I would use ga:countryISOcode or maybe ga:cityid instead. They are more acturate then ga:city

Post about Geo networking dimensions

You can set the locale as follows, however in your specific case this will still get city names in English only. :(

 // Load Google Charts for the Japanese locale.
  google.charts.load('current', {'packages':['corechart'], 'language': 'ja'});

According to Google documentation:

Locales are used to customize text for a country or language, affecting the formatting of values such as currencies, dates, and numbers.

By default, the Google Chart libraries are loaded with the "en" locale. You can override this default by explicitly specifying a locale in the loading parameters.

To load a chart formatted for a specific locale, use the language parameter like so.

(Source: https://developers.google.com/chart/interactive/docs/basic_load_libs#loadwithlocale )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM