Voog.com

Languages

Summary of language endpoints

List all available languages for the current site

GET /admin/api/languages

Example response:

Status: 200 OK
[
  {
    "id": 1,
    "code": "en",
    "region": "GB",
    "title": "ENG",
    "site_title": "My new site",
    "position": 1,
    "default_language": false,
    "published": "true",
    "created_at": "2014-01-20T09:19:04.000Z",
    "updated_at": "2014-01-20T09:19:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/languages/1",
    "move_url": "http://helloworld.voog.co/admin/api/languages/1/move",
    "contents_url": "http://helloworld.voog.co/admin/api/languages/1/contents",
    "pages_url": "http://helloworld.voog.co/admin/api/pages?language_id=1"
  }, {
    "id": 2,
    "code": "fr",
    "region": null,
    "title": "FRA",
    "site_title": "Mon nouveau site",
    "position": 2,
    "default_language": false,
    "published": "true",
    "created_at": "2014-01-21T14:43:48.000Z",
    "updated_at": "2014-01-21T14:43:48.000Z",
    "url": "http://helloworld.voog.co/admin/api/languages/2",
    "move_url": "http://helloworld.voog.co/admin/api/languages/2/move",
    "contents_url": "http://helloworld.voog.co/admin/api/languages/2/contents",
    "pages_url": "http://helloworld.voog.co/admin/api/pages?language_id=2"
  }
]

Parameters

  • per_page - elements per response (default: 50; maximum: 250).
  • page - requested page (default: 1).

Filter attributes

Read more about filters.

  • Object language attributes: id, code, region, title, position, published, default_language, created_at, updated_at.

Create a new language for the current site

POST /admin/api/languages

The request adds new language to the end of the language list and creates automatically a front page for it.

Example data:

{
  "code": "et",
  "title": "Eesti",
  "site_title": "Minu uus sait",
  "site_header": "Tere tulemast uuele saidile!"
}

Example response:

Status: 201 Created
{
  "id": 3,
  "code": "et",
  "region": null,
  "title": "Eesti",
  "site_title": "Minu uus sait",
  "position": 3,
  "default_language": false,
  "published": "true",
  "created_at": "2014-01-21T14:53:11.000Z",
  "updated_at": "2014-01-21T14:53:11.000Z",
  "url": "http://helloworld.voog.co/admin/api/languages/3",
  "move_url": "http://helloworld.voog.co/admin/api/languages/3/move",
  "contents_url": "http://helloworld.voog.co/admin/api/languages/3/contents",
  "pages_url": "http://helloworld.voog.co/admin/api/pages?language_id=3"
}

Parameters

Required parameters:

  • code - two-letter language code (see more: ISO 639-1).
  • title - language title for language menu.

Optional parameters:

  • region - two-letter region code (see more: ISO 3166-1 alpha-2)
  • site_title - language specific site title (overrides global site title) mostly used for html title section.
  • site_header - language specific site header (language specific content area).
  • default_language - if present and value is true then newly created language is set as default language (default: false).
  • published - determines whether the language is publicly visible or not (default: true)

Get data for a single language

GET /admin/api/languages/1

Example request:

GET http://helloworld.voog.co/admin/api/languages/1

Example response:

Status: 200 OK
{
  "id": 1,
  "code": "en",
  "region": "GB",
  "title": "ENG",
  "site_title": "My new site",
  "site_header": "My site header",
  "position": 1,
  "default_language": false,
  "published": "true",
  "created_at": "2014-01-20T09:19:04.000Z",
  "updated_at": "2014-01-20T09:19:04.000Z",
  "url": "http://helloworld.voog.co/admin/api/languages/1",
  "move_url": "http://helloworld.voog.co/admin/api/languages/1/move",
  "contents_url": "http://helloworld.voog.co/admin/api/languages/1/contents",
  "pages_url": "http://helloworld.voog.co/admin/api/pages?language_id=1"
}

Update attributes of a single language

PUT /admin/api/languages/1

This request updates the language with provided attributes.

Example request:

PUT http://helloworld.voog.co/admin/api/languages/3

Example data:

Status: 200 OK
{
  "title": "EN",
  "site_title": "Hello, world!",
  "default_language": true
}

Example response:

Status: 200 OK
{
  "id": 1,
  "code": "en",
  "region": "GB",
  "title": "EN",
  "site_title": "Hello, world!",
  "site_header": "My site header",
  "position": 1,
  "default_language": true,
  "published": "true",
  "created_at": "2014-01-20T09:19:04.000Z",
  "updated_at": "2014-01-21T15:00:11.000Z",
  "url": "http://helloworld.voog.co/admin/api/languages/1",
  "move_url": "http://helloworld.voog.co/admin/api/languages/1/move",
  "contents_url": "http://helloworld.voog.co/admin/api/languages/1/contents",
  "pages_url": "http://helloworld.voog.co/admin/api/pages?language_id=1"
}

Parameters

Optional parameters:

  • code - two-letter language code (see more: ISO 639-1).
  • region - two-letter region code (see more: ISO 3166-1 alpha-2)
  • title - language title for language menu.
  • site_title - language specific site title (overrides global site title) mostly used for html title section.
  • site_header - language specific site header (language specific content area).
  • default_language - if present and value is true in request then current language is set as default language (default: false).
  • published - determines whether the language is publicly visible or not (default: true)

Reorder a language

PUT /admin/api/languages/1/move

Moves the language in languages list.

Example request:

PUT http://helloworld.voog.co/admin/api/languages/3/move?before=1

Example response:

Status: 200 OK
{
  "id": 3,
  "code": "et",
  "region": null,
  "title": "Eesti",
  "site_title": "Minu uus sait",
  "position": 1,
  "default_language": false,
  "published": "true",
  "created_at": "2014-01-21T14:53:11.000Z",
  "updated_at": "2014-01-21T14:53:11.000Z",
  "url": "http://helloworld.voog.co/admin/api/languages/3",
  "move_url": "http://helloworld.voog.co/admin/api/languages/3/move",
  "contents_url": "http://helloworld.voog.co/admin/api/languages/3/contents",
  "pages_url": "http://helloworld.voog.co/admin/api/pages?language_id=3"
}

Parameters

Optional parameters:

  • before - existing language id. Moves the language before given language. (E.g. ?before=2)
  • after - existing language id. Moves the language after given language. (E.g. ?after=1)

Enable language automatic detection for site visitors

PUT /admin/api/languages/enable_autodetect

This request enables language automatic detection for site visitors by setting default_language value to false for all languages.

Example request:

PUT /admin/api/languages/enable_autodetect

Example response:

Status: 204 No Content

Remove a language

DELETE /admin/api/languages/1

This request deletes the language from the database.

Example request:

DELETE http://helloworld.voog.co/admin/api/languages/3

Example response:

Status: 204 No Content