{"__v":3,"_id":"570fa1efd6c6f00e00b98804","category":{"__v":3,"_id":"56af6d6ecc4cbd0d00ce2c88","pages":["56af6e8460a37a0d00ed87ac","56af71e58be2ea0d00b48887","56af73a08be2ea0d00b48890"],"project":"56abbf55f25f160d00e17f4e","version":"56abbf55f25f160d00e17f51","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-01T14:36:30.275Z","from_sync":false,"order":2,"slug":"concepts","title":"Kongregate APIs & Concepts"},"parentDoc":null,"project":"56abbf55f25f160d00e17f4e","user":"56abbec30b9e0b0d00616274","version":{"__v":12,"_id":"56abbf55f25f160d00e17f51","project":"56abbf55f25f160d00e17f4e","createdAt":"2016-01-29T19:36:53.665Z","releaseDate":"2016-01-29T19:36:53.665Z","categories":["56abbf56f25f160d00e17f52","56abca6bf9757e0d007c6650","56acddfa0ab3c00d00ce3332","56af65da9d32e30d0006d30f","56af66cab34d210d003d9ad0","56af6afcd21e9c0d00b628d1","56af6d6ecc4cbd0d00ce2c88","5705b12221cfed0e00e8c580","570a5676ade45d0e00c1ad33","570d7d25d1e4b82000d9e385","570eac3c3160d10e0041df0e","575709000fd6a3200010dded"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-14T13:58:07.212Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":10,"body":"[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Deprecated API\",\n  \"body\": \"Localization preferences will soon no longer be supported. We are leaving the documentation up for reference, but we do not recommend spending time implementing this API for new games. The vast majority of our players are English-speaking.\"\n}\n[/block]\n## Localization (User Language)\n\nKongregate saves player language preferences and can pass their selection in our iframe games. By checking a quick parameter, you can respect their option even if it's different from their browser default! (Note that this feature is currently only supported for games using our iframe embedding option)\n\nIt's actually super simple and the data is already in the parameter we're sending to you. Here's an example of a URL we load an iframe game with:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"http://kg.tyrantonline.com/canvas/?DO_NOT_SHARE_THIS_LINK=1&\\nkongregate_username=PLAYER_NAME&\\nkongregate_user_id=PLAYER_ID_NUMBER&\\nkongregate_game_auth_token=GAME_AUTH_TOKEN&\\nkongregate_game_id=GAME_ID&\\nkongregate_host=http%3A%2F%2Fwww.kongregate.com&\\nkongregate_game_url=http%3A%2F%2Fwww.kongregate.com%2Fgames%2Fsynapse%2Ftyrant&\\nkongregate_api_host=http%3A%2F%2Fapi.kongregate.com&\\nkongregate_channel_id=CHANNEL_ID&\\nkongregate_api_path=http%3A%2F%2Fchat.kongregate.com%2Fflash%2FAPI_AS3_efeff9e3f4f6350255b95aa31ba0ef32.swf&\\nkongregate_ansible_path=chat.kongregate.com%2Fflash%2Fansible_5cae4aad0aa719bffe641383dd1d3178.swf&\\nkongregate_preview=false&\\nkongregate_language=en&\\npreview=false&\\nkongregate_split_treatments=none&\\nkongregate=true&KEEP_THIS_DATA_PRIVATE=1\",\n      \"language\": \"text\",\n      \"name\": \"Parameters\"\n    }\n  ]\n}\n[/block]\nYou'll notice near the end of all that is: `kongregate_language=en`. This identifies this player as having selected \"English\" as their preferred language. Currently Kongregate also supports German (de) and French (fr). These will adhere to [ISO 639-1 standards](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) as we add more languages.\n\nIf the [Javascript API](doc:javascript-api) has been initialized, you can access the language like so:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"kongregateAPI.flashVarsObject().kongregate_language\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nFor iframe games which do not use the JavaScript API, you can simply grab the parameter off the URL manually.","excerpt":"Obtain the preferred language for a user","slug":"api-localization","type":"basic","title":"Localization & User Language"}

Localization & User Language

Obtain the preferred language for a user

[block:callout] { "type": "danger", "title": "Deprecated API", "body": "Localization preferences will soon no longer be supported. We are leaving the documentation up for reference, but we do not recommend spending time implementing this API for new games. The vast majority of our players are English-speaking." } [/block] ## Localization (User Language) Kongregate saves player language preferences and can pass their selection in our iframe games. By checking a quick parameter, you can respect their option even if it's different from their browser default! (Note that this feature is currently only supported for games using our iframe embedding option) It's actually super simple and the data is already in the parameter we're sending to you. Here's an example of a URL we load an iframe game with: [block:code] { "codes": [ { "code": "http://kg.tyrantonline.com/canvas/?DO_NOT_SHARE_THIS_LINK=1&\nkongregate_username=PLAYER_NAME&\nkongregate_user_id=PLAYER_ID_NUMBER&\nkongregate_game_auth_token=GAME_AUTH_TOKEN&\nkongregate_game_id=GAME_ID&\nkongregate_host=http%3A%2F%2Fwww.kongregate.com&\nkongregate_game_url=http%3A%2F%2Fwww.kongregate.com%2Fgames%2Fsynapse%2Ftyrant&\nkongregate_api_host=http%3A%2F%2Fapi.kongregate.com&\nkongregate_channel_id=CHANNEL_ID&\nkongregate_api_path=http%3A%2F%2Fchat.kongregate.com%2Fflash%2FAPI_AS3_efeff9e3f4f6350255b95aa31ba0ef32.swf&\nkongregate_ansible_path=chat.kongregate.com%2Fflash%2Fansible_5cae4aad0aa719bffe641383dd1d3178.swf&\nkongregate_preview=false&\nkongregate_language=en&\npreview=false&\nkongregate_split_treatments=none&\nkongregate=true&KEEP_THIS_DATA_PRIVATE=1", "language": "text", "name": "Parameters" } ] } [/block] You'll notice near the end of all that is: `kongregate_language=en`. This identifies this player as having selected "English" as their preferred language. Currently Kongregate also supports German (de) and French (fr). These will adhere to [ISO 639-1 standards](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) as we add more languages. If the [Javascript API](doc:javascript-api) has been initialized, you can access the language like so: [block:code] { "codes": [ { "code": "kongregateAPI.flashVarsObject().kongregate_language", "language": "javascript" } ] } [/block] For iframe games which do not use the JavaScript API, you can simply grab the parameter off the URL manually.