question

Kim Strasser avatar image
Kim Strasser asked

How can I change the player's profile language?

I want that the player can change his PlayFab profile language. In this example, I want to change the player's profile language to English, but I get an error message:

var languageTask = PlayFabClientAPI.SetProfileLanguageAsync(request);

'PlayFabClientAPI' does not contain a definition for 'SetProfileLanguageAsync'

How can I change the player's profile language?

        private void SetProfileLanguage()
        {
            var request = new SetProfileLanguageRequest { Language = "EN" };
            var languageTask = PlayFabClientAPI.SetProfileLanguageAsync(request);
            languageTask.ContinueWith(OnSetProfileLanguageComplete);
        }


        private void OnSetProfileLanguageComplete(Task<PlayFabResult<SetProfileLanguageResponse>> task)
        {
            var newLabel = "Unknown failure";
            if (task.Result.Result != null)
            {
                newLabel = "Changed language to EN";
            }
            if (task.Result.Error != null)
            {
                newLabel = "Something went wrong.\n"
                    + "Here's some debug information:\n"
                    + task.Result.Error.GenerateErrorReport();
            }
            lock (_myLabelText)
            {
                _myLabelText = newLabel;
            }
        }
Account Management
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Seth Du avatar image
Seth Du answered

It is because SetProfileLanguageAsync API call is contained in PlayFabProfilesAPI, you may call it through:

PlayFabProfilesAPI.SetProfileLanguageAsync();

More details are provided in the documentation: https://docs.microsoft.com/en-us/rest/api/playfab/profiles/account-management/setprofilelanguage?view=playfab-rest.

Please also refer to this thread, in case there is any confusion: https://community.playfab.com/questions/28072/any-ideas-andor-code-examples-on-how-to-change-the.html

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kim Strasser avatar image Kim Strasser commented ·

What is ExpectedVersion? Is ExpectedVersion always "0" or is it possible that ExpectedVersion is higher than "0"?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Kim Strasser commented ·

I have asked our team to check the source code. The algorithm is that if you set ExpectedVersion as 0 in the request, the code will not check your current version and update the profile language anyway. In addition, current version will be increased by 1 from 0 after a successful update.

If ExpectedVersion is not 0 and doesn't match the current version, you will get an error. You may try it on your own.

Since there is no API to get a specified version of profile. I don't think you need to worry about it for now. Set "0" will be fine.

1 Like 1 ·
Kim Strasser avatar image Kim Strasser commented ·

Thank you. I will always set ExpectedVersion as 0 in the request.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.