Preferred Language

Preferred Language

in API Development

Posted by: StevenL.3761

StevenL.3761

Q:

Is there a way to figure out the user’s in-game “Text Language” setting somehow? I’m afraid to go by the current system’s settings, because those include unsupported languages.

If the answer is no, could a dev please update /v1 to include Content-Language headers in the response? The API data defaults to English when the value of the “lang” parameter is invalid. That’s fine, but it should be reflected in the response when it happens.

Preferred Language

in API Development

Posted by: smiley.1438

smiley.1438

A:

So: i’d say you can’t without violating the EULA. Since GW2 doesn’t store the settings in the windows registry but most likely in the /appdata/roaming/Guild Wars 2/Local.dat. So you’d have to find the setting in there or might hook into the game to find out. (But i guess you know that anyway)

(edited by smiley.1438)

Preferred Language

in API Development

Posted by: smiley.1438

smiley.1438

Seriously, the Content-Language header doesn’t make any sense at all. The default language is always english as you already noticed and will only change if requested.

So if you request ?lang=de, the content language won’t be “cn”. Also, i highly doubt that anyone would do any changes to the v1 API now that it has basically reached end-of-life.

Preferred Language

in API Development

Posted by: StevenL.3761

StevenL.3761

It does make sense. Observe the differences between the response data for all of these:

https://api.guildwars2.com/v1/event_names.json
https://api.guildwars2.com/v1/event_names.json?lang=en
https://api.guildwars2.com/v1/event_names.json?lang=de
https://api.guildwars2.com/v1/event_names.json?lang=ru
https://api.guildwars2.com/v1/event_names.json?lang=zh

Responses: en → en → de → en → error

There is no way to accurately determine which language is actually returned (other than analyzing the value of the “name” property using some advanced language detection algorithm).

The only solution for now is to limit allowed values to values that are known to work. Which brings us back to the original problem: the system language might not be supported.

(edited by StevenL.3761)

Preferred Language

in API Development

Posted by: smiley.1438

smiley.1438

Of course there is a way to determine the language of the content. You know that the v1 API i will return data in exactly 4 languages: “en”, “de”, “es” and “fr” while “en” is default. So any other values than these 4 will most likely return english. Always.
That a systems language might not be supported is not a problem of the API and you shouldn’t even consider do detect it to determine it to set the API-language.

(zh isn’t even a valid language code, so this might cause the error – it would be cn-zh)

(edited by smiley.1438)

Preferred Language

in API Development

Posted by: StevenL.3761

StevenL.3761

Why shouldn’t I detect the system language in order to provide a better user experience?

(zh is a valid language code for v2, but not v1.)

Preferred Language

in API Development

Posted by: smiley.1438

smiley.1438

Why shouldn’t I detect the system language in order to provide a better user experience?

Why do “developers” always think that a “better user experience” is to withdraw control from the user? Just give them a choice.

(zh is a valid language code for v2, but not v1.)

Ok, i’ve confused the country code with the language code. However, you know the valid values and you can check them any time.

Preferred Language

in API Development

Posted by: StevenL.3761

StevenL.3761

So that brings me back to my original question: can I detect the user’s in-game language setting somehow? That way, they can set my app’s language by changing their in-game language. And it will always be a valid value.

Preferred Language

in API Development

Posted by: StevenL.3761

StevenL.3761

So: i’d say you can’t without violating the EULA. Since GW2 doesn’t store the settings in the windows registry but most likely in the /appdata/roaming/Guild Wars 2/Local.dat. So you’d have to find the setting in there or might hook into the game to find out. (But i guess you know that anyway)

Actually I didn’t know that, but I’ll look into it. If Local.dat is really where the language setting is stored, I should be able to find it by checking which bytes change when I change my language setting.

edit : thanks, it worked.

Attachments:

(edited by StevenL.3761)

Preferred Language

in API Development

Posted by: smiley.1438

smiley.1438

Preferred Language

in API Development

Posted by: Alcarin.9024

Alcarin.9024

Don’t trust local.dat, you don’t know if the position or the coding of the language could change tomorrow. In that case you need to stay up-to-date with current local.dat format, maybe it never change, maybe you need to update your application every 2 weeks or every feature packs.
I think that the best solution could be detect system language, and if the system language is one of the GW2 “known language” use it, otherwise use English.

I agree with smiley, in any case you should allow the user to overwrite any detected language.

Preferred Language

in API Development

Posted by: StevenL.3761

StevenL.3761

I’ll put in multiple layers of settings. From high to low priority : user defined language -> Local.dat language (if file is present and in a known format) -> system language (if supported) -> default language (English).

Still need to figure out the format first. It’s more complicated than I thought at first.

(edited by StevenL.3761)