简体   繁体   English

Google Analytics API数据的本地化翻译

[英]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. 我正在使用Google APIs PHP客户端库 ,试图从Google Analytics API中获取数据。

When I request fe ga:city as a dimension, I get a list of all the city names. 当我要求fe ga:city作为维度时,我会得到所有城市名称的列表。 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? 还是一般来说使用Google API都不可能?

The Google Analytics API returns data in English only. Google Analytics API仅以英语返回数据。 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. 提示 :如果您要进行某种翻译,请改用ga:countryISOcodega:cityid They are more acturate then ga:city 它们比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: 根据Google文档:

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. 默认情况下,Google Chart库会加载“ en”语言环境。 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. 要加载针对特定区域设置格式的图表,请使用language参数,如下所示。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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