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.
The default text "Select Some Options" or "Select an Option" should be translatable at least. And if not even configurable. I temporarily hacked my Chosen library to make use of the Drupal.t() javascript function. But I'm sure the module could easily replace the text with a configurable variable...
I'm interested in your thoughts on this.
Comment | File | Size | Author |
---|---|---|---|
#20 | chosen-translation_of_default_text-1591908-20.patch | 1.43 KB | pcambra |
#12 | chosen-translation_of_default_text-1591908-12.patch | 1.44 KB | jmuzz |
#6 | chosen-1591908-bis.diff | 703 bytes | bago |
#5 | chosen-1591908.diff | 590 bytes | bago |
Comments
Comment #1
ddorian CreditAttribution: ddorian commentedAlso Interested
Comment #2
Cyclodex CreditAttribution: Cyclodex commentedJust came over this too.
There is also more text which should be translatable: Noting down the ones which we should try to fix:
Short investigation showed me that "No results match" is a option, so I will add this to my other already implemented options.
But I think I should not call it then as t(), perhaps we need this as translatable variable, not yet sure how to do this. (give me some time)
The other too needs some jquery change. I will try to have a look on that and will post you a patch here later.
Cheers Cyclodex
Comment #3
shadcn CreditAttribution: shadcn commentedChosen picks the placeholder from a data attributes. As a temp solution, a form alter and adding this attributes can help.
Comment #4
mh86 CreditAttribution: mh86 commentedThis can be easily fixed with adding following line to the chosen.js file:
Comment #5
bago CreditAttribution: bago commentedHere is a patch. It works only against recent chosen.js libraries (>= june 2012).
I preferred to localize the "extended" versions:
+ options.placeholder_text_multiple = Drupal.t('Choose some options');
+ options.placeholder_text_single = Drupal.t('Choose an option');
Comment #6
bago CreditAttribution: bago commentedThis one also supports "No results match" localization.
Please note that the string will appear as "No result match" followed by the text searched, so this will have to be taken into account during translation.
Comment #7
Cyclodex CreditAttribution: Cyclodex commentedThanks for the diff's and the feedback, works for me too.
Looks like we can implement this that way
Comment #8
bago CreditAttribution: bago commentedComment #9
Cyclodex CreditAttribution: Cyclodex commentedComment #10
Cyclodex CreditAttribution: Cyclodex commentedI just commited this into the dev! Thanks!
Comment #12
jmuzz CreditAttribution: jmuzz commentedIt looks like this solution was removed in the latest version, at least for customized strings. I saw that they were being loaded from variables but they weren't appearing in the Translatable Variables module. This patch adds a chosen.variables.inc file to allow these 3 strings to be translated with Translatable Variables.
Comment #13
Hydra CreditAttribution: Hydra commentedClosed #2087683: Implement Variable API to allow for translation of text variables as a duplicate, since the solution is the same.
Unfortunally I had no time to test this properly, I would love to see this in chosen before stable release, since so many people have issues with translating variables
Comment #14
lmeurs CreditAttribution: lmeurs commented#12 works great, many thanks!
Comment #15
boyan.borisov CreditAttribution: boyan.borisov commented#12 works for me, too.
Comment #16
boyan.borisov CreditAttribution: boyan.borisov commentedComment #19
Dave ReidThis hook doesn't seem to define all the variables used by Chosen? Why?
Closing paren for arrays should be unindented here as per coding standards.
Same
Same
Adds an extra space at the end of the line here which should be removed.
Comment #20
pcambraHi Dave,
I don't think we need to expose all chosen variables because the main intent of this patch is making them translatable, excepting the strings displayed (these are exposed to variable with this patch), the rest of variables are settings that doesn't make a lot of sense to translate.
Here's a new patch taking care of the coding standards bit.
Comment #21
lmeurs CreditAttribution: lmeurs commentedPatch is (besides coding standards corrections) the same as the earlier RTBC patch. Successfully re-applied this version of the patch to Chosen 7.x-2.0-beta4, thanks a lot!
Comment #23
Hydra CreditAttribution: Hydra commentedLooks good to me, Thx @all! committed to 7.x-2.x http://cgit.drupalcode.org/chosen/commit/?id=e7a0d22
Comment #25
kopeboy CreditAttribution: kopeboy commentedIs this included in beta?
I can see the strings at admin/config/regional/translate/translate but once translated they are not showing up, still only english is present.
Comment #26
hass CreditAttribution: hass commentedComment #27
hansrossel CreditAttribution: hansrossel commented@kopeboy: need to enable variable module and then check the chosen variables first at admin/config/regional/i18n/variable