简体   繁体   中英

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:

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. Now, the actual problem:
I am using Google Play Games Api in my app. 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). But when I change the default system language, the Api recognizes that giving responses in that language. 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)'.

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.
  • 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. 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.

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