Locale is unable to rebuild lost Javascript translation files
claudiu.cristea - November 24, 2008 - 20:54
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | locale.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
| Issue tags: | i18n sprint, JavaScript |
Description
I see a lot of "Page not found" errors in dblog related to JavaScript translation files. It's about those files that need to be generated by the locale.module [see locale_update_js_files()].
Looking in source of the page, in <HEAD> I see the JS file requested in line: <script type="text/javascript" src="/files/languages/ro_e8ed5acc13877f103dc82336f22ac598.js?3"></script> but in the specified folder the file is not present. This is happen only for the Romanian language. The site is multilingual (EN, IT, RO). In italian version I got no error.

#1
I had installed version 6.6 including Czech localization and everything was OK.
After update to 6.8 I often get this error message in web logs:
Type: "page not found"
Place: https://www.my_own_web.cz/sites/default/files/languages/cs_212be125b34b8...
I have already the localization file, but it has different name:
sites/default/files/languages/cs_212be125b34b88632a34700d1c2cae3a.js
How can I repair it? Where can I find the file name stored?
#2
Your problems are due to the fact that the Locale module is unable to rebuild the Javascript translation files: if one of these gets accidentally corrupted or lost there is no way to tell Drupal to rebuild it.
The patch should fix the problem: apply it, clear the cache (Site configuration > Performance > Clear cached data), visit a page which includes the missing file(s) and you should find it again in the
languagesdirectory.If you are unfamiliar with patching or do not wish to patch the core, you can find a module which will let you rebuild the files manually here:
edit: (updated link) http://download.psegno.it/files/drupal/locale_rebuild_js.zip
#3
This is the 7.x patch.
#4
The last submitted patch failed testing.
#5
fixed patch
#6
#7
plach thank you so much! Your answer was very helpful for me.
#8
@a.horoshavin: did you test the patch or the module?
#9
Hi plach
Your mini-module above enables to rebuild the file properly (BTW the patch was not working for me on D6.8).
However, locale module is not working properly on my configuration :
- file system is private method
- file folder is outside the www folder
- Drupal is in sub-directory of www (called 'my_directory' in my case).
In that case, if I set up the file system path in absolute path, locale module breaks because the page tries to call "/my_directory/absolute_path/languages/fr_xxx.js" which it doesn't exsit.
The only way to fix this is to set the file system path as relative path to Drupal base directory: "../../files". Strangely, the page calls "/my_directory/../../files/languages/fr_xxx.js" which seems to be fine (at least not logging a page not found).
Is that a correct set up ?
Thanks
Laurent
#10
Subscribing.
#11
I think this is another issue, I will try to investigate.
#12
I've tried the Locale Rebuild JS Module on Drupal 6.9.
I run it a couple of times but it seems it didn't work because every time I entered the Module page, I saw the same values in the table.
Now, I don't see the Module tab in the Language Settings and I can't even enter to the Edit page of the any language.
Any ideas?
Thanks in advance.
PS: Now I see I'm also getting error 404 on /path/to/your/sites/stylesheet.css?0. Maybe this is of any help.
#13
@LaurantB: as I supposed the problem you are reporting is caused by another issue, see #181003: private download method and dynamically generated CSS and JS for details. Unfortunately JavaScript translations won't work with the private file-system setting enabled until that one is fixed, that's why the patch is not working for you. Moreover I am afraid your soultion won't work because all the paths you suggest will be passed through
file_create_pathand rejected, as they actually point to locations outside the file directory.@realOFF: the values in the table are supposed to remain unchanged, for the other problems I'm afraid I can't help you: that module is an as-is solution while this issue gets fixed in core; if it does not work for you, please try the patch.
#14
Just one fix for the module from #2, you missed the curly braces in locale_rebuild_js.admin.inc around the table name, so with a fixed table prefix the first sql query throws an error. Line 107 should be:
$query = 'SELECT language, javascript FROM {languages} WHERE language IN ('. $placeholders .')';
at least now it worked for me.
#15
@kkretsch: thanks, I fixed that, but keep in mind that the module is just an interim solution while the patch find its way to the core...
#16
The last submitted patch failed testing.
#17
I have used the module, but the problem still remains and nothing happened.
I still get the "page not found" errors.
Is there any procedure how to remove all correct/incorrect translation files from Drupal and install them again?
This would be sufficient for me now.
I accept that I will lose some of my manual translations.
#18
@David Koudela: apply the patch in #2, follow the instructions, delete (backup them!) the language files.
The correct files should get rebuilt and you should not lose you translations.
#19
Ok, I did it:
- I applied the patch to the file and I copied it to the directory
- I removed the language files
- I cleaned the cache
But I still get "page not found" errors:
Type page not found
Date Tuesday, 24 February, 2009 - 10:42
User
Location https://www.koudelovi.cz/sites/default/files/languages/cs_f8cc24f295b687...
Referrer https://www.koudelovi.cz/cs/admin/reports
Message 500.phtml
Severity warning
Hostname
Operations
Any ideas what to do or how to better analyze the problem?
#20
Please, check one thing: in the languages directory do you have any cs_*.js files, apart from the missing one?
#21
I have following file:
sites/default/files/languages/cs_f8cc24f295b6870eee00c27dc541587e.js
So it seems to me correct, isn't it?
I have checked also permissions - all directories have at least 755 (rwxr-xr-x), the file has 664 (rw-rw-r--)
#22
In this case I'm afraid neither the patch nor the module will help, they just rebuild the file, if it is actually there you are probably experiencing some kind of server misconfiguration. Are you using private download method?
#23
@David Koudela: Maybe files directory should have 775 permissions. Apache will create the js file. So, it must have write permissions to create the file.
This bug is also present in Drupal 6.10. Do we have to change the version of this issue?. Maybe it can be fixed in 6.11 version.
#24
I assume you mean following settings: administer >> site configuration >> file system and check box "Download method"
My Download method is public.
#25
@dagmar: the issue the patch solves is present both in D6.x and in D7.x, to have the patch automatically passed to the testbed we have to keep the version to 7.x.
@David Koudela: I am sorry, this sounds to me as a server configuration issue.
#26
@dagmar: Ok, I have set the permissions of directories to 777 for a moment to be sure, that there is no problem with the permissions.
Then I have deleted the cs_*.js language file and I have tried to access some language local pages, but I still get the same errors :-(.
The language file is re-created again.
I would say that it is right time to uninstall the local language with its translatations, make a clean-up and install it again.
But I do not know how to do it without damaging the system :-).
#27
Well, I did a little progress.
I realized that I did not understand the message of the Drupal log.
The "missing" part was a page 500.phtml somehow requested by: cs_f8cc24f295b6870eee00c27dc541587e.js
I have created empty file 500.phtml at the root directory of my system and the problem disappeared.
I still do not understand why and where it is needed - search of Drupal files and database found nothing :-(
It seems to me a bug, but I can live with it.
Thanks for your help.
#28
Rerolled the patch and added a simpletest for the JavaScript translations.
#29
Excellent. Then, the patch for D6 is still #2? Or you are going to do a re roll for 6.x too?
#30
Here is the 6.x version.
#31
Works fine for our site!
#32
The patch should be tested in Drupal 7.
Sorry but, I don't think that your site is in drupal 7 :)
I have tested the 6.x version and can confirm that works fine too.
@Frank Steiner: If you have tested this patch for Drupal 7 please, forgive me, and change the status again.
Greetings
Mariano
#33
The last submitted patch failed testing.
#34
rerolled
#35
The last submitted patch failed testing.
#36
rerolled again
#37
fixed and encoding problem in the previous patch
#38
The test-case code has blank lines that contain trailing indentation.
I'm not sure
'SELECT min(lid) AS lid FROM {locales_source} WHERE location LIKE \'%.js%\' AND textgroup = \'default\''is proper - aren't strings containing single quotes supposed to be double-quoted rather than backslashed? I could be wrong there.#39
@Arancaytar: thanks for the review, I removed all the trailing spaces. The query should be fine: the backslash quote is a PHP-level quoting not a SQL-level one, however I copied it from line 909 of the original
locale.test.Edit: sorry, I misunderstood your comment about quotes, however an identical line is already committed.
Edit (2): I checked the coding standards and it seems there are no strong directives to follow about single quotes vs double quotes.
#40
I can confirm that the patch in http://drupal.org/node/338630#comment-1307862 fixes the issue for Drupal-6 and would really like to have it integrated with the next 6.x release
#41
The last submitted patch failed testing.
#42
rerolled
#43
The last submitted patch failed testing.
#44
fixed the simpletest
#45
The last submitted patch failed testing.
#46
Setting to 'needs review' - testbot was broken.
#47
The last submitted patch failed testing.
#48
retry
#49
The last submitted patch failed testing.
#50
rerolled
#51
few code style things.
$dir .'/'. $language->language .'_'. $data_hash .'.js'needs extra space for concatenation
+ $status = ($status == 'deleted') ? 'updated' : ($changed_hash ? 'created' : 'rebuilt');Maybe spit the ternary into two?
+ // Let slip through.No clear what's slipping through what.
+ function testJavaScriptTranslation() {This needs phpdoc.
db_fetch_object(db_query should be db_query()->fetchObject();Should be db_query()->fetchObject();
#52
Implemented suggestions from #51
#53
The last submitted patch failed testing.
#54
Thank you!
Patch from #52 has solved my problem. I haven't got any *.js file (or even language/ dir to be more precise) - probably lost them when moving from local to server. Anyway it seems to work nicely with D6.13.
#55
subscribe
#56
My language javascript file is missing too! The D6 patch in #52 fixed the problem for me. Thanks a lot. ^ ^
#57
+ $dest = $dir . '/' . $language->language . '_' . $data_hash .'.js';Should be
+ $dest = $dir . '/' . $language->language . '_' . $data_hash . '.js';#58
The last submitted patch failed testing.
#59
rerolled
#60
I used to get the warning every time I would "clear cache"
but now it does not appear after applying
patch from #52 for Drupal 6
#61
Private Download Method used here too. I have a .JS file in my files/languages folder (outside HTTP root). I tried applying the #52 patch (locally) with 'patch -p0 < locale-338630-52.D6.patch' (from the site root), and got this in Terminal:
patching file includes/locale.incHunk #1 succeeded at 2166 (offset 4 lines).
Hunk #2 succeeded at 2184 (offset 4 lines).
Hunk #3 succeeded at 2220 (offset 4 lines).
Hunk #4 succeeded at 2240 (offset 4 lines).
Things haven't changed much since then. I still have the JS file being asked for in the source HTML. Cleared the cache etc, a bit stumped. This is the first time I apply a patch. Anything I'm missing?
#62
@talino: see #9-#13
#63
Thanks, I understand it's incompatible with Private Downloads, however currently the link is still in the source and explicitly displaying the full path to the private files folder (and the host's entire folder structure). This is a major security concern, enough for me to take the site offline. What am I supposed to do now? The site uses French po files for interface string translation but is not multilingual. And I can't use Public Downloads. Do I need to take down a month of work because of a link to a missing JS file?
Thanks.
#64
Apologies. Please delete my#63. Haven't clicked far enough. Got the patch and responding there (http://drupal.org/node/296831#comment-969355).
#65
a little module for D6 which
Provides locale admin pages with buttons to rebuild/invalidate js translations.
is just an unobtrusive way to solve this unusual issue
- enable the module
- navigate to
admin/settings/language#js-translations- expand "JavaScript translations" fieldset
- use either "Invalidate js translations" or "Rebuild js translations" buttons
#66
This small module works for me. I don't really like your custom module package name (arhak - tweaks), though, but that's a minor issue and I just changed it to my likings (Multilanguage =))
#67
@#66 sorry about that
that is the way I mark the modules which doesn't have a project page in drupal.org
it should go under Multilanguage indeed
I haven't created a project for this neither for other modules because I won't be able to use CVS (explained at Looking for a CVS committer) and that workaround shouldn't be provided as a patch, since this issue has its own patch going on
#68
Thanks for your mini-module !
It solved my JS language problems. Hope you get CVS access soon.
#69
subscribed
#70
great! thx!
Greeting
CKIDOW
#71
The last submitted patch failed testing.