Needs review
Project:
Translation template extractor
Version:
8.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Oct 2011 at 08:31 UTC
Updated:
19 Jan 2026 at 13:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Alex.Enciu commentedComment #3
Alex.Enciu commentedComment #5
torotil commentedI redid the patch with git diff - this should work better with our test-bot.
Comment #6
pbuyle commentedI made the same changes before finding this issue. Works for me.
Comment #7
gábor hojtsyLooks like a great patch. We are attempting to make the potx.inc file be a library that can be reused among different major Drupal versions. Putting this change in would not allow us to do that. So it would be great to add some conditions on the major Drupal version being run and only add the context if it is >= 7.
Comment #8
jacobfriis commentedPatch based on Alex.Enciu and torotil's work (#5), which attempts to accomplish the Drupal version conditional requirement (Gábor #7).
Created against current dev (7.x-1.x 8ac54a17480f9fa41ce07fd38642bca809e49a8a) but also appears to work against 7.x-1.0.
Comment #9
jacobfriis commentedFor some reason neither of these patches get applied (in my context ;-) when added to the .make of an install profile; whereas other patches get applied just fine. And no error is logged, drush (5.8) pretends that everything is swell and adds a PATCHES.txt in potx' dir. However they do work with drush 6.0 (on a Windows box!).
But that's another story ;-)
Comment #10
idebr commentedReroll against the latest 7.x-3.x-dev release.
Comment #11
idebr commentedComment #12
PascalAnimateur commentedI'm trying to extract the translations for various features modules I've created (mostly with custom content types), but I can't get a single msgctxt out of this module, even with patch #10 applied to clean 3.x-dev.
This is probably due to the fact that I'm using title / entity_translation / localize_fields to translate my content types.
Anybody know if this could be the case? In what scenarios are you getting context properly extracted?
Comment #13
jacobfriis commented@PascalAnimateur
Did you
drush localize-fields sites/all/modules/my_features_module?
A Features module export doesn't supply contextual translation of field labels, descriptions, allowed values.
The Localize Fields drush script fixes that.
Comment #14
PascalAnimateur commented@jacobfriis hum... I should have RTFM !! Maybe I'll go back to using localize_fields instead of i18n_field after all...
Comment #15
duaelfrPatch in #10 do the job! Thank you! You saved me hours of headache!
The patch looks good. I'm surprised that there is not an easier way to find out which core version we are running on. What about reading the system module info file?
Comment #16
gábor hojtsy@DuaelFr: there is no version information in that file: http://cgit.drupalcode.org/drupal/tree/modules/system/system.info?h=7.x
Comment #17
duaelfr@Gábor Hojtsy
There is at least
core = 7.xthat can help finding the major version.More, if the version has been downloaded from d.o, the buildbot also adds
version = "7.38"but I'm not sure we need to be so precise.If we really need to be backward compatible with versions older than Drupal 6 that can be a problem as this "core" key has been introduced in D6.
Comment #18
idebr commentedNote: the patch does not fix the extract for plural translations.
Comment #19
dmsmidtIt does work for me in D7.
Comment #20
idebr commentedIssue still occurs in 8.x-1.x as well. Attached patch applies to 8.x-1.x.
Comment #21
super_romeo commentedPatch Failed to Apply
Comment #22
spadxiii commentedDid a quick re-roll of the patch against latest dev.
Comment #23
gábor hojtsyThis assumes potx is run inside Drupal with the given version. That may or may not be true depending on how you run potx (it can be run as an independent project and can be run against codebases of other projects etc).
I would simply look at the SQL table if it has a context column or not and then carry that info over to later.
Re @idebr: Plurals are handled in #3013103: Plural translation values are not exported..
Comment #24
dimiter commentedI have re-rolled patch #22 from @SpadXIII against the current 7.x-3.x (dev) of potx (90afb499264672b34cb28a433aa38bf880263706). I did not implement the suggested change of Gábor Hojtsy from #23.
Comment #25
timohuismanI've updated the patch from #22 to 8.x-1.0 to add Drupal 9 compatibility, see https://www.drupal.org/node/3148463
Comment #26
gngn commented#25 worked for me (with potx 8.x-1.0-alpha1).
Comment #27
fernly commentedI tried patch #25 for a twig translation with context such as
{{ "Text to translate"|t({}, {'context' : 'Context name'}) }}The context was not picked up in this case.
Comment #28
idebr commentedAttached fixed the test failures with the patch from #25
#23 still needs to be addressed
#27 still needs to be addressed
Comment #29
mpp commentedMarking as needs work due to
#23 still needs to be addressed
#27 still needs to be addressed
Comment #30
gngn commented#28 worked for me (with potx 8.x-1.0).
Comment #32
geek-merlinRan into this when a wrong translation made it into prod. Setting critical as of data loss. (If s.o. bikesheds it to major, i won't argue.)
Notes:
- Code concerning Drupal 6 is not needed anymore (i.e. while D6 modules can still be extracted, the patch is for D8+ and can be as-is backported to D7, and no localization site should run D6 today.)
- Which obsoletes #23.
- #27 is obviously a different bug. Please file it as such.
- Also, the current patch misses one query (w/ plurals code path)
Comment #34
geek-merlin- Added MR with the simplified code to review and test.
- Verified that the patch applies and fixes the issue for me.
Comment #35
geek-merlinUps, merge error? The MR seems to be onto 7.x? I guess this issue was re-purposed 7 / 8. Or whatever.
Comment #38
geek-merlinSo ignore that MR !23, it's MR !24 ftw.
Comment #39
geek-merlinOK, tests are green, off for today.
Comment #40
espurnesHello,
Any update on the #27 issue?
Is there any other issue thread addressing that?
Thanks
Comment #41
rcodinaI have tested MR !24 and it works like a charm.
I confirm that #27 is still an issue (literal gets extracted but with no context) but this other way works fine:
Comment #42
theanisotropicHello! I've created a patch in issue 2816601, a reroll of a previous patch in the same issue, which attempts to fix the problem mentioned in #27. It is for the current dev version 8.x-1.x.