Hi,
As multilanguage support is one of the drupal 6 credo, it could be very cool to see a multilanguage support for this module.
Basically, it would provide one tabs for each language in which you could define some replacement rules.
It would bring 2 major enhancement :
- prevent server overloading : Imagine you have a website with 8 language enabled. if you want to replace some words, you have to do it for each language, and as the module don't make some differences between languages, it would apply 8 replacement rules for each words. With a lot of words replacement, it would quickly overload a server
- prevent replacement errors : 2 language could have the same word that mean something different. ATM the module don't make the difference so it could make wrong word replacement...
What's your opinion about this feature ? Do you plan to implement it ? I can try to work on a patch but I'm very new with the new internationalization core and API and I'm not sure to be able to create a clean code.
| Comment | File | Size | Author |
|---|---|---|---|
| #35 | wordfilter.265565.patch | 13.6 KB | jaydub |
| #33 | wordfilter_locale.patch | 15.02 KB | stella |
| #29 | wordfilter.module.patch | 13.46 KB | jaydub |
| #28 | wordfilter.module.patch | 12.8 KB | jaydub |
| #26 | wordfilter.module.patch | 18.95 KB | jaydub |
Comments
Comment #1
zmove commentedI worked on it and make a patch.
What the patch provide ?
On the wordfilter add or edit form, you have a new list to select language for which the wordfilter apply. the list get the installed language list of the drupal installation + an all option. So if there the user don't have multilanguage website, it should work too. (see screenshot 1)
The wordfilter listing show the language for which the filter apply (see screenshot 2)
And then, the wordfilter module take care of the node language to get the right filter list to apply (so, for example, if you create a node in french, the module will get all the filter that gave "all" and "french" language selected).
I attach 2 patch
As my winmerge seems to sux creating patch, I attach too a full package of the modified module.
PS: You can install the full package and launch update.php, I wrote an update rule, so it should quite easy to install.
Please, give me feedback and feel free to make it core (but I would see it in core for easy update later ^^)
Comment #2
zmove commentedforgot to change the issue status...
Comment #3
zmove commentedOhh, I hoped to enjoy some people by providing this stuff... ;) Can you give me feedback about it ?
(it's for D6)
Comment #4
jaydub commentedAre there any additional modules required for this level of
Internationalization in Drupal 6?
Also can you post patches using the Drupal standards:
cvs diff -up original.php > filename.patch
or
diff -up original.php new.php > filename.patch
Comment #5
zmove commentedThe patch call language_list() to get country language for admin, so it's ok for administration section.
About the nodes, it need to get the node language, so I don't know if it's a variable provided by core. Maybe it need the locale or content translation core module to be enabled.
I'm not at work anymore, so I will get the info and stay you informed.
Comment #6
zmove commentedHi,
I checked if this patch bring module dependencies, it seems not.
If the user don't have several language installed, in admin, the returned list will be empty, so it will have a dropdown list with only one "all" item, which is pretty logic. (If only one "all" option in the list, maybe you can hide this list but it's a minor usability issue).
On filter conditions about the node language, it will not cause problem too. If $node->language don't exist (so if it have independent language or if locale is not installed), the wordfilter module will not apply language restriction to get the filter list so it will works great.
So the module will continue to work great without adding dependencies.
Is there a plan to make this patch official with these new informations ?
Comment #7
zmove commentedHi,
Can I have any news with the latest informations I bring, about the multilanguage support for this module.
Do you plan to review my code and implement it or do I create another module to provide this feature ?
thanks
zmove
Comment #8
jaydub commentedI'm really busy with my day job at the moment. In the meantime
could you repost your patch using the Drupal standards?
cvs diff -up original.php > filename.patch
or
diff -up original.php new.php > filename.patch
It makes it a lot easier to work with
Comment #9
zmove commentedHi,
Sorry for the long time passed between my last post, I'm busy too and I needed to find another PC because as you could see, I have problems with winmerge on mine.
I attach to this post the 2 patch (in the standard drupal way) for the .install and .module file.
They were made on the latest dev version of wordfilter.
Comment #10
zmove commentedLittle bumb because 6 weeks without reply..
Is the module abandonned ?
Comment #11
nedjoThis is definitely a needed feature. Patch looks generally good.
Needs some code style cleanup--indent issues (tabs used instead of spaces).
Looks like the update missed changing the schema to add the new field.
Comment #12
zmove commentedHi,
I'm glad to finally see a reply for this feature ;)
I test it on a test site since the first patch I posted and I noticed no issues at all.
Wordfilter had a new (little) dev release after my patch, so maybe the patch can't apply well now. But it is little and can be easily applied by hands.
Comment #13
hailu commentedI'll do the style cleanup, and take care of the schema issues as well.
Look out for a re-roll...
Hailu
Comment #14
zmove commentedOk ok, the F5 key is never so far :)
Comment #15
jaydub commentedOk I've taken some time to start working on this and I have
a few comments on the patch and some issues that we need
to figure out.
FIrst off for the .install file, the changes to the table need to
be added to the wordfilter_schema() function as well as added
in as a hook_update_N function. Second the hook_update_N
must use the schema API to add the field. The version you had
was MySQL specific. I use PostgreSQL so that would be a problem :)
I've made those changes already.
Now the for module itself, we have a rather significant problem that
we have to figure out. Filtering on node/comment titles/subjects is not
a problem as we can do the filtering via hook_nodeapi and hook_comment
calls as in the module currently. Because we have access to the node or
comment object at that point we can pass in the language, if any, for the node
(or node that the comment is posted on) to the wordfilter filter.
However when we run the wordfilter filter on the node or comment body
this is done using the Drupal filter mechanism and so nodes and comments
are checked via check_markup during the node's hook_nodeapi 'prepare'
operation and during the comment's theme_comment_view function (or
other theme_comment_view theme override function). When check_markup
is called it only has the text to check and not other other information such
as the node or comment object.
So this means that when the wordfilter filter function wordfilter_filter_process()
is called we have no node context with which to extract the language setting
if any for that node. In the simplistic case where we are viewing a node we
might be able to test for arg(0) == 'node' and arg(1) is a number but that
won't help when we are viewing a list of teasers such as could be the case if
you are using Views and pulling a list of the latest 10 nodes on your site.
The alternative is to change the design of the module and do body/teaser filtering
in hook_nodeapi & hook_comment but the downside there is that you lose the
filter caching that you have via check_markup.
I'm open to suggestions of how we can handle this problem. maybe there's something
I'm missing here but I think that currently handling filtering via Drupal filters and
making use of node language settings is harder than the patch suggests....
Comment #16
zmove commentedHi
I think we have no really choice to use the nodeapi or the filtering system. Using the nodeapi will bring too much performance issues for a 'little' feature like word replacement. It is, for me, an absolute necessary to cache the data.
About the language issue, I don't remember well because I submit this patch some times ago now. I dont remember to had some problems with the language context, I believe that the language context is present on the node creation form, but maybe I don't remember well...
If the node language cannot be retrieved on node creation, you could take the user, or the website default language as a replacement.
Comment #17
nedjoI've posted a patch for D7 to add a $language argument to hook_filter(): #319788: Pass language information to filters. Reviews would be great.
For 6, the best we can do may be
Comment #18
nedjoComment #19
nedjoThe core patch went in. I think we shd use the temporary approach I suggested in #17 for D6 and then have a fullter solution built on the core change for D7.
Comment #20
recidive commentedI've worked on improving the patch.
Added code similar to #17, to make it get language in context. However I'm getting a WSOD when viewing a node. On listings (e.g. /node), only node titles get translated. So there is a problem on on the filter. I'm investigating.
Also, fixed code styling issues and added some checks so it don't cause fatal error if locale module is disabled.
Assigning to myself.
Comment #21
recidive commentedUpdated patch.
I did some basic testing and it seems to be working.
Comment #22
hailu commentedI'm getting WSOD when i try to view a node using the patch from #21.
The corresponding entry from my error.log is "[Wed Nov 26 17:52:13 2008] [notice] child pid 9931 exit signal Segmentation fault (11)
"
Comment #23
jaydub commented#21 were you testing with filtering on node/comment titles enabled also? menu_get_object() basically ends up dong a node_load to return the node object. If you are filtering titles, then wordfilter_filter_process is called on the hook_nodeapi() load operation which leads to menu_get_object() again which does a node_load which invokes hook_nodeapi() and so on and so forth. I think perhaps that's what #22 was running into.
Comment #24
recidive commentedChanging to hook_nodeapi() $op = 'view', instead of 'load' fixes the issue. It's also now inline with hook_comment() implementation.
Is there any drawbacks from this change?
Comment #25
recidive commentedChanging to hook_nodeapi() $op = 'view' makes it don't work on node titles in full nodes.
So I tried a different approach with _wordfilter_list() accepting a object explicitly when one exists.
Comment #26
jaydub commentedHere's a quick patch with my implementation. It varies somewhat from recidive's work most recently in #25 as I had already been working on the implementation up to the point the patches appeared here. However the basic elements of that patch as first posted in #20 are here.
This patch includes some other changes that haven't been committed yet mostly in documentation text and such. I'll commit those first separate from the multilanguage stuff here but for now I just wanted to have recidive and any other interested parties take a look.
Comment #27
catchsubscribing to this, will do a proper review later on.
Comment #28
jaydub commentedhere's an updated patch without the changes to documentation and help text (already committed now).
Comment #29
jaydub commentedre-rolled once again after porting another change in the d5 branch to d6.
Comment #30
jaydub commentedI've got a window coming up at the end of the month where I'll be working on my modules...If recidive or anyone else can try out the latest patch please let me know the results.
Comment #31
jaydub commentedanyone able to review #29? My window for pushing out a release with this patch is closing as I am relocating from China back to the US in a couple weeks...
Comment #32
catchsubscribing - hoping to review this week.
Comment #33
stella commentedRe-rolled patch with a few coding style changes, and also removed
t()calls from the message strings passed towatchdog().Overall the patch looks good and when viewing nodes with an associated language, the correct word replacement is done. However if viewing a "language neutral" node, then all language filters are applied. I'm not sure this is the desired behaviour. Here are the steps I did when testing:
The correct replacement was done for French and English nodes. In the German node, the word was correctly replaced with the fallback 'all languages' replacement word. However, in the language neutral node, the French word replacement was done. I presume this is because it was the first word filter I set up. I think the correct behaviour would be to apply the "all languages" filter first for language neutral nodes. If no "all languages" filter is found, but there is a language specific one, then either apply that language specific filter, or perhaps it might be better not to apply language specific filters at all in this scenario.
Cheers,
Stella
Comment #34
recidive commentedComment #35
jaydub commentedOk I added a query sort condition which should resolve the scenario mentioned in #33. Also folded in the other coding changes in #33.
Comment #36
priyanka2008 commentedhi ..i think you can use the module "Localizer" for multi language support..
Regards
Comment #37
kerberos commented#36: Localizer has been abandoned and only worked in D5 and also doesn't help with this. :)
Have there been any updates on this issue? We are willing to help out with this if any help is needed.
-Daniel
Comment #38
jaydub commentedWell I've been reluctant to spend too much time on this as there were no perfect solutions. The feature in question has been added to core for D7 in the filter module so it's possible that a combination of the patches posted here and a look at how it's been accomplished in core for D7 could net a better patch for D6. Realistically I can't spend much time on this myself given my day job demands but if you want to take it and run with it then please do so and post patches here.
Comment #39
kerberos commentedGreat, thanks, we'll take a look and see if there's a good alternative.
-Daniel
Comment #40
q0rban commentedWork on this for 7 is happening in #1073026: Implement CTools exportables and export UI
Comment #41
jaydub commentedLooks like this can be revisited in D7.
Comment #42
mxh commented