On a node edit page you can't translate the bundle name on the add paragraph button/select. It's possible to translate the "'Add !title'" label, but it's not possible to translate the bundle name itself.
For example "Add image" translated to Dutch should be "Afbeelding toevoegen". But currently it's only possible to translate it to "Image toevoegen".
I've attached a patch to solve this.
| Comment | File | Size | Author |
|---|---|---|---|
| #27 | paragraphs-make_bundles_translatable-2580427-27-rc5.patch | 43.51 KB | joshahubbers |
| #23 | paragraphs-make_bundles_translatable-2580427-23-d7.patch | 43.51 KB | eelkeblok |
| #21 | paragraphs_make-bundles-translatable-2580427-21.patch | 45.02 KB | idebr |
Comments
Comment #2
jeroen.b commentedThanks for the patch! Could you add a translation context so it's easier to translate specific terms?
(I had issues with the word "Case" in multiple projects, they always resulted in "Hoofdlettergebruik" ;) )
Comment #3
vollepeer commentedI updated the patch to work with 7.x-1.0-rc4
Comment #4
vollepeer commentedWhoops, filename contained a space...
Comment #5
vollepeer commentedI added a translation context as requested in comment #2.
Comment #6
vollepeer commentedComment #7
Johnny vd Laar commentedAttached is a patch that adds another translation when you are editing a node with paragraphs.
Comment #8
dgtlmoon commentedThis patch is being used successfully here but other people might want to review it also
Comment #9
eelkeblokSorry to be a party pooper, but putting user-defined strings (i.e. bundle names) into t() is generally not the accepted way to do this sort of thing. This would look to be a job for the i18n module.
Comment #10
rudi teschner commentedI agree, worst case this could result in a recursion situation.
It would be cleaner to make the paragrah names itself translatable. Just like i18n_node provided options to translate content type names.
Comment #11
geek-merlinSo this needs a different approach like outlined here:
i18n module integration | Drupal.org
Comment #12
idebr commentedSince Paragraphs already depends on Entity API, we can leverage the EntityDefaultUIController and EntityDefaultI18nStringController to make Paragraphs bundles translatable. As a bonus, Paragraph bundles are now entities so the CRUD operations and Features exports are now available for 'free' by the Entity API.
Attached patch converts Paragraphs bundles to entities and applies i18n_string translations through the EntityDefaultI18nStringController in the paragraphs_i18n submodule.
Comment #14
idebr commentedI have regenerated the Features module that is used to test the Paragraphs module to reflect the changes in the export hooks. This should also fix the failing test.
Comment #16
geek-merlinEntity api, wooooot! Great work.
Comment #17
rudiedirkx commentedUsing Entity API to export config creates monstrosities like this:
Entities in D7 are definitely not for exporting config. Feature exports should be hardcoded, sorted, predictable. It takes 3 features hooks to do it correctly. I doubt all this is necessary to translate a few labels.
Comment #18
geek-merlin#17: i don't see the monstrosity in this. quite some module use this approach, first of all rules. and we get some other benefits of it. +1 for entity api.
Comment #19
eelkeblokI think using Entity API is not unreasonable. If you take offence with the format it produces for exportables, that's probably something to be taken up with Entity API. If others agree, all modules that use entity API might benefit. FWIW, I think this format might be less conflict-prone than the usual lines and lines of nearly identical array structures Features tends to produce.
Comment #20
tvoesenek commentedPatch works for me, i've created an rc4 only patch from the patch in #14
Comment #21
idebr commentedReroll against -dev
Comment #22
idebr commentedComment #23
eelkeblokAnother reroll against latest dev.
Comment #24
eelkeblokComment #25
ericdsd commented+1 for entity api
This issue seems to be abandoned for a while, but it would clearly be an useful feature.
Comment #26
joshahubbers commentedPatch for the rc5 version.
Comment #27
joshahubbers commentedPrevious patch did not include the ParagraphsBundleEntity.inc file. This patch is complete.
Comment #28
paulvandenburg commented#27 confirmed working.
Comment #29
jstollerThe patch no longer applies to dev and may require functional changes due to more recent commits. Please re-roll and retest.
Comment #30
bluegeek9 commentedUnfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.