Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
locale.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Sep 2011 at 20:12 UTC
Updated:
7 Feb 2012 at 13:23 UTC
Jump to comment: Most recent file
Comments
Comment #1
loganfsmyth commentedThis patch converts the regexes to extended form and adds tons of comments so you can actually tell what's going on.
This also applies to 7.x.
Comment #2
loganfsmyth commentedComment #3
gábor hojtsyAs I've said in person, this looks so much better. It is way cleaner to understand what is going on here. Do tests cover this already? If that is the case, this looks like just ready to go :)
Comment #4
loganfsmyth commentedI couldn't find any tests and totally breaking the regex didn't cause any failed tests, so I don't think there are any.
Here is a new patch with the same regex, and some new tests to make sure parsing is working.
Comment #5
gábor hojtsySuperb, looking forward to testing results.
Comment #6
gábor hojtsyLooks good, test looks pretty comprehensive and passes :) Thanks for your work.
Comment #7
chx commentedThe time increase in what takes PCRE to parse the string compared to parsing the string and throwing away whitespace and comments is barely measurable compared to actually running the PCRE state machine. Edit: I microbenchmarked this and on my machine 10 000 runs adds 0.02s time to the execution of the PCRE so every run we are talking of two microseconds. We can tolerate a 2us slowdown for readability.
Comment #8
catchI don't see any reason to create the file in the test rather than just ship it inside locale/tests - also not 100% but does simpletest even mess with the file directory during test runs or is this something which would have to be cleared up manually (which isn't done by the test if so).
Comment #9
loganfsmyth commentedIf just throwing a random file in the tests directory is acceptable, then I can do that. I mostly wasn't sure if that was a good way to do it, or if I should keep the test more self-contained like this.
I used the file_put_contents method because it seemed to work, and I assumed that it would get cleaned up because this method is also used in this: http://api.drupal.org/api/drupal/modules--simpletest--simpletest.module/...
Comment #10
gábor hojtsy@loganfsmyth: the direct backportable solution IMHO would be to put a locale.test.js or locale_test.js or somesuch in modules/locale/. Not sure what's the pattern, locale.test.js or locale_test.js though. Probably other tests have js test files, for aggregation testing for example to look for naming patterns.
Comment #11
loganfsmyth commentedI moved the JavaScript to a file called 'locale_test.js' in the locale/tests folder.
I also added one last test to make sure the total number of source strings found matches the expected value.
Comment #12
gábor hojtsyLooks good to me. Also, this should be backported to D7 (should apply direct). It is just about making the JS parser code more understandable and adding a heap of tests to verify.
Comment #13
dries commentedCommitted to 8.x. Moving to 7.x for Angie to consider.
Comment #14
rfayIt looks to me like this broke 8.x; most likely there were missing files that didn't get committed.
http://qa.drupal.org/8.x-status
Comment #15
loganfsmyth commentedIt looks like the patch wasn't properly applied.
You are right Randy, locale_test.js was in my patch, but wasn't committed.
Comment #16
gábor hojtsyIt is critical if its broke. We also have the file to commit, so RTBC.
Comment #17
bfroehle commentedI've attached the modules/locale/tests/locale_test.js hunk from the patch in #11 for ease.
Comment #18
gábor hojtsyAll right, @Dries added the file in. The D7 patch is in #11. :)
Edit: commit link at http://drupalcode.org/project/drupal.git/commitdiff/3c536d68db761d7a9e60...
Comment #20
loganfsmyth commented#11: locale-regex-extended-1281932-11.patch queued for re-testing.
Comment #21
loganfsmyth commentedTesting success on D7. Setting RTBC again as Gábor had it.
Comment #22
gábor hojtsyUploading again to make it clear this patch is for D7. Should be RTBC if tests pass, just like D8.
Comment #23
gábor hojtsyShould be good to go (not my patch, I just reposted it above :).
Comment #24
webchickSeems like this is no functional change, just makes everything a hell of a lot easier to understand and also adds more tests which is always a good thing. :)
Committed and pushed to 7.x. Thanks!
Comment #25
gábor hojtsySuperb, thanks, now onwards to #488496: Implement missing msgctx context in JS translation for feature parity with t() :)
Comment #27
gábor hojtsyTagging for UI translation.