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

David Koudela - December 24, 2008 - 16:04
Version:6.6» 6.8

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

plach - January 12, 2009 - 11:40
Title:JavaScript translation file not created but requested» Locale is unable to rebuild lost Javascript translation files
Version:6.8» 6.x-dev
Status:active» needs review

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 languages directory.

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

AttachmentSize
locale-338630-2.D6.patch 3.16 KB

#3

plach - January 6, 2009 - 20:31
Version:6.x-dev» 7.x-dev

This is the 7.x patch.

AttachmentSize
locale-338630-3.patch 3.28 KB
Testbed results
locale-338630-3.patchfailedFailed: Invalid PHP syntax. Detailed results

#4

System Message - January 8, 2009 - 01:05
Status:needs review» needs work

The last submitted patch failed testing.

#5

plach - January 8, 2009 - 15:17

fixed patch

AttachmentSize
locale-338630-4.patch 3.21 KB
Testbed results
locale-338630-4.patchfailedFailed: Failed to apply patch. Detailed results

#6

plach - January 8, 2009 - 20:53
Status:needs work» needs review

#7

a.horoshavin - January 19, 2009 - 23:30

plach thank you so much! Your answer was very helpful for me.

#8

plach - January 20, 2009 - 20:09

@a.horoshavin: did you test the patch or the module?

#9

Laurent_ - January 26, 2009 - 16:42

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

DanielTheViking - January 27, 2009 - 21:52

Subscribing.

#11

plach - February 4, 2009 - 12:45
Issue tags:+i18n sprint

I think this is another issue, I will try to investigate.

#12

realOFF - February 6, 2009 - 22:59

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

plach - February 9, 2009 - 02: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_path and 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

kkretsch - February 11, 2009 - 08:34

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

plach - February 11, 2009 - 09:43

@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

System Message - February 13, 2009 - 15:50
Status:needs review» needs work

The last submitted patch failed testing.

#17

David Koudela - February 23, 2009 - 14:43

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

plach - February 23, 2009 - 15:11

@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

David Koudela - February 24, 2009 - 09:49

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

plach - February 24, 2009 - 10:04

Please, check one thing: in the languages directory do you have any cs_*.js files, apart from the missing one?

#21

David Koudela - February 24, 2009 - 11:05

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

plach - February 24, 2009 - 15:04

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

dagmar - February 26, 2009 - 01:11

@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

David Koudela - February 26, 2009 - 09:00

I assume you mean following settings: administer >> site configuration >> file system and check box "Download method"
My Download method is public.

#25

plach - February 26, 2009 - 09:28

@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

David Koudela - February 26, 2009 - 09:31

@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

David Koudela - February 26, 2009 - 13:01

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

plach - March 1, 2009 - 22:55
Status:needs work» needs review

Rerolled the patch and added a simpletest for the JavaScript translations.

AttachmentSize
locale-338630-28.patch 5.28 KB
Testbed results
locale-338630-28.patchfailedFailed: Failed to apply patch. Detailed results

#29

dagmar - March 2, 2009 - 01:54

Excellent. Then, the patch for D6 is still #2? Or you are going to do a re roll for 6.x too?

#30

plach - March 2, 2009 - 10:10

Here is the 6.x version.

AttachmentSize
locale-338630-30.D6.patch 3.16 KB

#31

Frank Steiner - March 9, 2009 - 11:45
Status:needs review» reviewed & tested by the community

Works fine for our site!

#32

dagmar - March 9, 2009 - 11:54
Status:reviewed & tested by the community» needs review

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

System Message - March 20, 2009 - 08:40
Status:needs review» needs work

The last submitted patch failed testing.

#34

plach - March 21, 2009 - 00:02
Status:needs work» needs review

rerolled

AttachmentSize
locale-338630-34.patch 5.07 KB
Testbed results
locale-338630-34.patchfailedFailed: 10688 passes, 8 fails, 9 exceptions Detailed results

#35

System Message - April 1, 2009 - 01:55
Status:needs review» needs work

The last submitted patch failed testing.

#36

plach - April 6, 2009 - 23:02
Status:needs work» needs review

rerolled again

AttachmentSize
locale-338630-36.patch 5.45 KB
Testbed results
locale-338630-36.patchfailedFailed: 11111 passes, 23 fails, 62 exceptions Detailed results

#37

plach - April 12, 2009 - 11:21

fixed and encoding problem in the previous patch

AttachmentSize
locale-338630-37.patch 5.04 KB
Testbed results
locale-338630-37.patchfailedFailed: Failed to install HEAD. Detailed results

#38

Arancaytar - May 19, 2009 - 00:31
Status:needs review» needs work

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

plach - June 10, 2009 - 17:50
Status:needs work» needs review

@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.

AttachmentSize
locale-338630-39.patch 5.18 KB
Testbed results
locale-338630-39.patchfailedFailed: Failed to apply patch. Detailed results

#40

jandd - May 21, 2009 - 11:05

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

System Message - May 25, 2009 - 09:21
Status:needs review» needs work

The last submitted patch failed testing.

#42

plach - May 25, 2009 - 11:07
Status:needs work» needs review

rerolled

AttachmentSize
locale-338630-42.patch 5.11 KB
Testbed results
locale-338630-42.patchfailedFailed: 11813 passes, 2 fails, 8 exceptions Detailed results

#43

System Message - June 2, 2009 - 15:35
Status:needs review» needs work

The last submitted patch failed testing.

#44

plach - June 2, 2009 - 18:08
Status:needs work» needs review

fixed the simpletest

AttachmentSize
locale-338630-44.patch 5.44 KB
Testbed results
locale-338630-44.patchfailedFailed: Failed to install HEAD. Detailed results

#45

System Message - June 13, 2009 - 13:11
Status:needs review» needs work

The last submitted patch failed testing.

#46

lilou - June 13, 2009 - 13:45
Status:needs work» needs review

Setting to 'needs review' - testbot was broken.

#47

System Message - June 24, 2009 - 01:30
Status:needs review» needs work

The last submitted patch failed testing.

#48

plach - June 24, 2009 - 08:02
Status:needs work» needs review

retry

#49

System Message - June 28, 2009 - 03:55
Status:needs review» needs work

The last submitted patch failed testing.

#50

plach - July 1, 2009 - 17:14
Status:needs work» needs review

rerolled

AttachmentSize
locale-338630-50.patch 5.64 KB
Testbed results
locale-338630-50.patchfailedFailed: 11714 passes, 0 fails, 1 exception Detailed results

#51

catch - July 5, 2009 - 20:48
Status:needs review» needs work

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

plach - July 5, 2009 - 23:38
Status:needs work» needs review

Implemented suggestions from #51

AttachmentSize
locale-338630-52.patch 5.95 KB
locale-338630-52.D6.patch 3.28 KB
Testbed results
locale-338630-52.patchfailedFailed: 12090 passes, 12 fails, 9 exceptions Detailed results

#53

System Message - August 11, 2009 - 13:18
Status:needs review» needs work

The last submitted patch failed testing.

#54

obi22 - August 12, 2009 - 19:04

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

momper - August 15, 2009 - 16:20

subscribe

#56

ball.in.th - August 28, 2009 - 11:51

My language javascript file is missing too! The D6 patch in #52 fixed the problem for me. Thanks a lot. ^ ^

#57

dagmar - August 28, 2009 - 12:32
Status:needs work» needs review

+  $dest = $dir . '/' . $language->language . '_' . $data_hash .'.js';

Should be

+  $dest = $dir . '/' . $language->language . '_' . $data_hash . '.js';

AttachmentSize
locale-338630-57.patch 5.95 KB
Testbed results
locale-338630-57.patchfailedFailed: Failed to apply patch. Detailed results

#58

System Message - August 28, 2009 - 12:42
Status:needs review» needs work

The last submitted patch failed testing.

#59

dagmar - August 28, 2009 - 16:18
Status:needs work» needs review

rerolled

AttachmentSize
locale-338630-59.patch 5.95 KB
Testbed results
locale-338630-59.patchfailedFailed: 14443 passes, 10 fails, 0 exceptions Detailed results

#60

GiorgosK - August 29, 2009 - 20:56

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

talino - September 7, 2009 - 09:23

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.inc
Hunk #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

plach - September 7, 2009 - 12:24

@talino: see #9-#13

#63

talino - September 7, 2009 - 13:10

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

talino - September 7, 2009 - 13:27

Apologies. Please delete my#63. Haven't clicked far enough. Got the patch and responding there (http://drupal.org/node/296831#comment-969355).

#65

arhak - September 12, 2009 - 21:59

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

AttachmentSize
2009-09-12 tweak_locale_js.zip 1.27 KB

#66

marcushenningsen - September 16, 2009 - 11:35

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

arhak - September 16, 2009 - 16:56

@#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

koorneef - September 30, 2009 - 13:18

Thanks for your mini-module !
It solved my JS language problems. Hope you get CVS access soon.

#69

sinasalek - October 10, 2009 - 12:43

subscribed

#70

CKIDOW - October 26, 2009 - 10:33

great! thx!

Greeting

CKIDOW

#71

System Message - November 7, 2009 - 10:11
Status:needs review» needs work

The last submitted patch failed testing.

 
 

Drupal is a registered trademark of Dries Buytaert.