Hi there,
I am looking for best practises and general guidelines for content translated strings from a Service. In the WoW API module, it typically connect through the battle.net API to fetch in game data.
The RESTful interface can be retrieved in several languages, for instance, giving the locale URL parameter like this: http://eu.battle.net/api/wow/character/archimonde/Mercurial?locale=fr_FR will return a character in the language FR.
For items this is different, I have an item entity, with a Field for title and description at the same time. They are localized while the item entity is not localized. So typically in the ItemController I have somewhere the following code:
<?php
$language = entity_language('wow_item', $entity);
$entity->wow_item[$language][0] = array(
'name' => $entity->name,
'description' => $entity->description,
);
?>However, the item class language property is never stored into the database, it just get filled on Service fetch operation with the language returned dataset.
My question is: Should I create a language property ? I don't think I need to translate entities because items have a lot of fields such as weapon damage, price, durability and other game related stuff.
How this will integrate when entity translation will be supported on Drupal ? Right now I am using Fields because it is supported out-the-box with Field API.
Second question: I am feeling using too much of the internals when I am setting wow_item[$language][0] manually. I could not find an API or helper methods, I am doing this right ? Is a sort of API is on the track for D8 ?
Also, what are the conventions for languages in drupal ? fr-FR, en-GB, fr_FR, en_GB ? Right know I am just getting the two first characters of the current drupal language, using GLOBAL $language_content->language to map to a supported API language.
<?php
$infos['us'] = (object) array(
'name' => 'United States',
'locales' => array(
'en' => 'en_US',
'es' => 'es_MX',
'pt' => 'pt_BR',
),
'content' => 'us.media.blizzard.com',
'host' => 'us.battle.net',
);
$infos['eu'] = (object) array(
'name' => 'Europe',
'locales' => array(
'en' => 'en_GB',
'es' => 'es_ES',
'fr' => 'fr_FR',
'ru' => 'ru_RU',
'de' => 'de_DE',
'pt' => 'pt_PT',
),
'content' => 'eu.media.blizzard.com',
'host' => 'eu.battle.net',
);
?>Do you think this compatibility layer could be skipped ? And enforce the site builder to respect battle.net conventions, thus making language that have as key: en_US, or en_GB for instance. Is that can be problematic ?
Thanks a lot for advices.
Sylvain

Comments
Do you think the Entity
Do you think the Entity Translation module could help ?