Comments

berdir’s picture

  1. +++ b/public_html/sites/all/modules/contrib/tmgmt/sources/field/tmgmt_field.link.inc
    @@ -29,30 +29,61 @@
      * @ingroup tmgmt_source
      */
    -function hook_tmgmt_source_translation_structure($entity_type, $entity, $field, $instance, $langcode, $items) {
    +function link_tmgmt_source_translation_structure($entity_type, $entity, $field, $instance, $langcode, $items) {
    

    Something with the patch doesn't look right. Looks like you copied the api.php and then made a partial diff against that?

    This should show up as a new file in the diff.

  2. +++ b/public_html/sites/all/modules/contrib/tmgmt/sources/field/tmgmt_field.link.inc
    @@ -29,30 +29,61 @@
    + * Implements hook_tmgmt_field_type_populate_entity().
    + *
    + * This hook is implemented on behalf of the field_collection module.
    

    field_collection => link.

  3. +++ b/public_html/sites/all/modules/contrib/tmgmt/sources/field/tmgmt_field.link.inc
    @@ -29,30 +29,61 @@
     
    +  $entity->{$field_name}[LANGUAGE_NONE][0]['url'] =
    +    $data[$field_name][0]['value']['#text'];
    

    I don't think that LANGUAGE_NONE here is correct, that should be the target language?

Status: Needs review » Needs work

The last submitted patch, tmgmt_provide_link_support.patch, failed testing.

mpgeek’s picture

In my use case, i needed to support link title translation only, as the path/URL is handled by another means (URL context switching). Here is a correctly formatted patch. That does exactly that. I didn't need to implement hook_field_type_tmgmt_populate_entity since tmgmt already knows how to deal with text. The only thing required was to supply the structure.

mpgeek’s picture

Status: Needs work » Needs review
mpgeek’s picture

mpgeek’s picture

Sorry. Try this patch, it gets rid of the extra code block in the end that was commented out of #2.

GDrupal’s picture

Previous patches fail populating the entity when the trasnlation is back, attached a more functional patch.

claudiu.cristea’s picture

StatusFileSize
new5.37 KB

Here's one trying to build the foundation for other cases.

claudiu.cristea’s picture

Title: Support for link field - patch attached » Support for link field
StatusFileSize
new9.46 KB
new7.18 KB

Well, the URL should be also translatable. More, the 'attributes' column might contain the HTML 'title' attribute and that can be configured to be a user input.

berdir’s picture

I'm not convinced about the URL being translatable.

Our understanding of translatable is different than core. It's whether a translator ( a real person but also google/microsoft machine translation) can actually provide a translation for it. That's not really the case with a URL.

claudiu.cristea’s picture

But when the translator is a human, it might be desirable. Then automated translators can implement a hook that post alters the structure and get out the URL.

Delphine Lepers’s picture

Status: Needs review » Reviewed & tested by the community

I have tested patch #9 successfully on several sites

dxvargas’s picture

I'm not convinced about the URL being translatable.

@Bedir and what about if we need to target external URLs in different language versions? Seems to me a very common use case where a translatable URL would be handy.

I've tested #9 and it works.