Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If I have a file field whose display is set to "download link," the download link text is not translatable as far as I can tell.
Comment | File | Size | Author |
---|---|---|---|
#8 | file_entity-make-download-links-translatable-2097261-8.patch | 2.07 KB | Nixou |
#7 | file_entity-download_link_i18n-2097261-7.patch | 491 bytes | Ludo.R |
#5 | file_entity-download_link_i18n-2097261-4.patch | 491 bytes | stefan.r |
#1 | file_entity-download_link_i18n-2097261-1.patch | 475 bytes | dafeder |
Comments
Comment #1
dafederNot always sure where it's appropriate to add a t(), but here goes.
Comment #2
Dave ReidShouldn't the proper way to handling this is to allow the formatter configuration to be translatable?
Comment #3
Leksat CreditAttribution: Leksat at Amazee Labs commentedI did some research. It's hard to use i18n_string here, because the string can come from a regular field formatter or from a panel pane. We need some relevant context to use i18n_string() and in case of panels it is not available.
The i18n_panels module tries to solve the similar issue. It provides "i18n_settings" option for content type plugins.
Both i18n_string and i18n_panels solutions would be hard to implement. I personally used #1 patch. It's not the proper way, but it works.
Comment #4
rodrigoaguileraYeah I think it makes sense to solve this issue with this patch for now. If the number of strings that can be configurable and translatable grows makes sense to make a new translation group with i18n_string.
For example the field_group module manages the labels with t().
Comment #5
stefan.r CreditAttribution: stefan.r commentedUploading a reroll.
I doubt Dave Reid will commit this as such, so ideally someone addresses #2
Comment #6
dafederFWIW I agree #2 is the preferable approach
Comment #7
Ludo.RReroll this patch against latest dev version.
Comment #8
Nixou CreditAttribution: Nixou at Actency commentedI wrote a patch to have the download link text translatable through i18n_string (as it's a better approach since t() has not to be used on variables).
The approach is simple using a new group "File entity" and the hook_i18n_string_list().
Declared strings use the link text in the i18n_string key so it's possible to have different text per view mode for a same field in a same bundle.
I didn't use the view_mode directly in the key because this information is not available in hook_field_formatter_view() so I can't rebuild the key there.
To use this patch you need to have the i18n_string (submodule of i18n) enabled and go to admin/config/regional/translate/i18n_string to refresh "File entity" strings.
After that you will find strings into admin/config/regional/translate/translate filtering by "File Entity" group.
Comment #9
stijndmd CreditAttribution: stijndmd commentedThis may not be very relevant any more, but the patch in #8 works a charm and looks a great solution.
Comment #10
joseph.olstadPing me in a few weeks if I haven't yet committed the patch, it looks great, thanks!
Comment #13
joseph.olstad