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.
Plupload site explains how to translate plupload lib (http://www.plupload.com/punbb/viewtopic.php?pid=3949)
1) create an internationalization i18n js file (or grab an already existing one)
2) place it with all plupload js files under /js folder
3) into the caller html file, declare this i18n file just after the plupload.js declararation
Is this procedure still possible in Drupal ?
Which file must be changed to load the the translation file ?
Comment | File | Size | Author |
---|---|---|---|
#16 | 1219992_plupload_translation_16.patch | 1.7 KB | slashrsm |
#14 | 1219992_plupload_translation_12.patch | 1.68 KB | slashrsm |
#12 | 1219992_plupload_translation_12.patch | 1.68 KB | slashrsm |
#10 | plupload-translation-1219992-10.patch | 2.46 KB | axe312 |
#7 | 1219992-plupload-i18n-js.patch | 2.76 KB | Dave Reid |
Comments
Comment #0.0
kouri CreditAttribution: kouri commentedstep 3 corrected
Comment #0.1
kouri CreditAttribution: kouri commentedrebuild step 3 as symbols not authorized
Comment #1
gregglesIt doesn't, but we could.
I think justintime wanted to work on this.
AFAIK, this is an acceptable reason to fork a third party javascript library and commit it to d.o.
Comment #2
kouri CreditAttribution: kouri commentedThx for the answer.
So I understand that, actually, there's no choice but directly patch plupload .js files
Am I right ?
Comment #3
crea CreditAttribution: crea commentedPlease, let's not set unrealistic goals. If you fork the library, are you willing to support the fork ? If not, then why bother ? This is LOTS of work. Don't underestimate it.
It's not that hard to support non-Drupal way of translating.
Comment #4
gregglesIf it's maintained as a patch then "forking" is not such a bad/unmaintainable thing.
I don't see why you would say what is reasonable or unreasonable for someone else.
Does the Plupload library have a means to do translations itself?
Comment #5
crea CreditAttribution: crea commentedIt is described in the original post. You are supposed to add JS containing the translations object. What's a problem with that ? Besides that, it's even stated in their FAQ, that there are ready to use translation files, available for download. If that doesn't work, then it should be explained why, before suggesting forks, right ?
If someone wants to use Drupal translation mechanics, isn't it more logical to create bridge solution that creates the translation object using Drupal translations database, rather than to fork the library ?
I see lots of solutions, and forking is the worst.
Comment #6
Dave ReidI have a suggestion: Make an in-module callback for plupload/%language_code/i18n.js that outputs javascript (through PHP) after running the strings through t().
Then just:
Plus you only have to add the menu callback and Javascript if module_exists('locale')
Comment #7
Dave ReidComment #8
Dave ReidThe only downside to this is we don't get proper plural localization with strings like '%d files queued'.
Now that I think about it, there's no reason for this to be in PHP either - we can just have a plupload.i18n.js file that runs Drupal.t() on the strings, but this also allows us to do this server-side.
Comment #9
crea CreditAttribution: crea commentedSee #1270632: Use Drupal translation system for a D6 version where approach similar to #8 is implemented.
Comment #10
axe312 CreditAttribution: axe312 commentedI've recreated the patch from #6. Now the translations are working correctly :)
Comment #11
slashrsm CreditAttribution: slashrsm commentedI was testing this solution and I think that there are some problems when JS aggregation is used. It looks like Drupal does not include this in agreggated files, so this JS code is missing.
I'd rather go with a actual .js file for that reason.
Patch follows....
Comment #12
slashrsm CreditAttribution: slashrsm commentedPatch attached.
Comment #13
slashrsm CreditAttribution: slashrsm commentedPatch attached.
Comment #14
slashrsm CreditAttribution: slashrsm commentedPatch really attached.
Comment #15
axe312 CreditAttribution: axe312 commentedDoes not work for me!
File is included but returned object is not translated! Tested by writing "plupload.addI18n()" into console. (Chrome 16)
Manual test with "Drupal.t('Filename');" returns the correctly translated string. Something is going wrong :-/
Also cleared browser and drupal cache... did not help
Comment #16
slashrsm CreditAttribution: slashrsm commentedIt looks like this file needs to be included in footer, as translation info is not loaded early enough.
Attached patch works for me. Please check.
Comment #17
axe312 CreditAttribution: axe312 commentedWorking for me :) RTBC
Comment #18
slashrsm CreditAttribution: slashrsm commentedCommited to 7.x-1.x: http://drupalcode.org/project/plupload.git/commit/da6e4bf
Thanks!
Comment #20
fasdalf@fasdalf.ru CreditAttribution: fasdalf@fasdalf.ru commentedThank you all! You saved my day!
Comment #21
gomino CreditAttribution: gomino commentedIt does not work for me.
I do not see the js attached to the footer.
The locale module is active...
Comment #22
slashrsm CreditAttribution: slashrsm commentedIt should work. Are you really using latest version of Plupload? Tried to clear caches?
Comment #23
zikaelismik CreditAttribution: zikaelismik commentedI'm sorry if this sounds like a stupid question but still i don't get the right procedure to make translations work.
I installed the dev release and i see plupload library contains all the translations needed inside his js/i18n folder. Should i move those files somewhere else inside the module? because right now are not loaded at all.
Thanks
Michele
Comment #24
slashrsm CreditAttribution: slashrsm commentedDo you have locale.module enabled? Have you tried to clear cache?
Comment #24.0
slashrsm CreditAttribution: slashrsm commentedAdd a question