Posted by Manuel Garcia on February 5, 2009 at 2:17pm
| Project: | String Overrides |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | chxisawesome |
Issue Summary
Just a quick question here, does this module handle translatable strings from js files that use the Drupal.t() function?
I am testing it and it doesn't look like it's replacing it... so I was just looking to clarify this before I throw my computer out the window hehe :)
Thanks!
Comments
#1
No it doesn't, but that is definitely a good idea. Would it just send all the strings set in String Overrides to
Drupal.locale.strings? How does Locale do it? What if there was an additional String Overrides tab for JavaScript strings?#2
I opened up locale.module and found this function which looks like it's how its being done: locale_update_js_files().
I then ran a find in files for that function on the whole of drupal, and found _locale_invalidate_js() in locale.inc.
As far as how string overrides should step in I'm afraid it's passed my knowledge... perhaps we should harass someone in #drupal ?
I think having another tab for JavaScript strings would make sense, since this would probably work differently. Again, just guessing here...
Hope this helps -- thanks for caring!
#3
#4
http://www.palantir.net/blog/drupals-javascript-translation-system
#5
#6
t() supports
locale_custom_strings_eneven without Locale enabled -- you can set$custom_stringsin settings.php.Shouldn't
Drupal.t()accesslocale_custom_strings_entoo?#7
Someone must have got this working by now, right?
#8
Sue me for abusing the context.
Edit: most of this is, of course, copy-paste from locale.module.
#9
Concerned about having a hash and file IO calculations every page load, what if we were to put the translations directly in Drupal.settings, and then had a stringoverrides.js load them into the Drupal translation system?
Forgive me for not having the .patch file include adding stringoverrides.js itself. I'm lazy.
#10
Whoops, should probably be:
(function($) {
/**
* String Overrides behavior to load in JavaScript-based translations.
*/
Drupal.behaviors.stringoverrides = {
attach: function (context, settings) {
if (settings.stringoverrides || false) {
// Make sure the strings array is initialized.
Drupal.locale.strings = Drupal.locale.strings || {};
// Add the string overrides translations to the strings array.
jQuery.extend(Drupal.locale.strings, settings.stringoverrides);
}
}
};
})(jQuery);
Needs an actual review though, I haven't tested this thoroughly.
#11
Woot!!!