简体   繁体   English

如何以特定语言请求Android上的Google Play游戏?

[英]How to make request in a specific language for Google play games on Android?

I am working on an android app in which the user can change the language of the app from within the the app iteself using the following code: 我正在开发一个Android应用,其中用户可以使用以下代码从应用自身内部更改应用的语言:

Locale.setDefault(locale);
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
configuration.locale = locale;
resources.updateConfiguration(configuration, resources.getDisplayMetrics()); 

It works correctly with my local string resources, ie the language specific string resource is called when the App Locale is changed. 它可以与我的本地字符串资源一起正常使用,即,更改App Locale时将调用特定于语言的字符串资源。 Now, the actual problem: 现在,实际的问题是:
I am using Google Play Games Api in my app. 我在我的应用中使用Google Play Games Api。 I have added language specific translations to the Developer Console. 我已将特定语言的翻译添加到开发人员控制台。 When I make requests to the server, it gives responses in the default language of the phone system. 当我向服务器发出请求时,它将以电话系统的默认语言给出响应。 It does not consider the App specific locale, which is set by the user (using the above code). 它不考虑由用户(使用上面的代码)设置的App specificApp specific语言环境。 But when I change the default system language, the Api recognizes that giving responses in that language. 但是,当我更改默认系统语言时,Api会识别以该语言给出响应。 I have googled a lot, but can't find any way of telling the Games Api that 'Hey, I want the response in a different language (Set by my app)'. 我已经在Google上搜索了很多,但是找不到任何方式告诉Games Api:“嘿,我希望使用其他语言(由我的应用设置)进行响应”。

Is there a way of doing this? 有办法吗? I am stuck here. 我被困在这里。 Any help would be appreciated! 任何帮助,将不胜感激!

You can set your own translations for game details, including the display name, game description, and graphic assets. 您可以为游戏详细信息设置自己的翻译,包括显示名称,游戏说明和图形资产。 You can also specify your own translations for achievements and leaderboards that are associated with your game. 您还可以为与游戏相关联的成就和排行榜指定自己的翻译。

To add your own translations for game details: 要为游戏详细信息添加自己的翻译,请执行以下操作:

  • Open the Games with Game Services page from the Google Play Developer Console, and select your game. 从Google Play开发者控制台打开“ 带游戏服务的游戏”页面,然后选择您的游戏。
  • On the Game details page, click the Add translations button. 游戏详细信息页面上,单击添加翻译按钮。
  • Select the languages that you will provide translations for, then click Add to confirm your selection. 选择您将提供翻译的语言,然后单击“ 添加”以确认您的选择。 On the Game details page, you should see buttons for the languages that you selected. 在“ 游戏详细信息”页面上,您应该看到所选语言的按钮。
  • On the same page, click the button for a language, then edit the form with your translations for the display name, description, and the graphic assets. 在同一页面上,单击一种语言的按钮,然后使用显示名称,描述和图形资产的翻译来编辑表单。
  • Click Save to store your translated game details. 单击“ 保存”以存储您翻译的游戏详细信息。
  • Open Linked apps for your game. 打开您的游戏的链接应用程序 For each linked application, add the corresponding details for the translation languages that you added. 对于每个链接的应用程序,为您添加的翻译语言添加相应的详细信息。

For more information on adding translations for achievements and leaderboards, see the achievements and leaderboards game concepts. 有关为成就和排行榜添加翻译的更多信息,请参见成就排行榜游戏概念。

When displaying game detail, leaderboard, and achievement strings, Google Play games services uses the game-supported language that is closest to the user-requested language. 显示游戏详细信息,排行榜和成就字符串时,Google Play游戏服务会使用与用户要求的语言最接近的游戏支持语言。 For example, if the user's device language preference is set to French (Canada) (fr-CA), but the game supports only English (United States) (en-US) and French (France) (fr-FR), Google Play games services will select the fr-FR strings to display since this is the closest matching language. 例如,如果用户的设备语言偏好设置设置为法语(加拿大)(fr-CA),但游戏仅支持英语(美国)(en-US)和法语(法国)(fr-FR),则Google Play游戏服务会选择fr-FR字符串来显示,因为这是最接近的匹配语言。

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

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