[geeklog-devel] CrowdTranslation-LANG array mapping

Niemans niemans at nlbox.com
Fri Jun 21 18:03:57 EDT 2013


Depends on what you want the effect to be when you find all the occurrences in the page.
On first sight I do have two different thoughts:

1. Assuming that the effect you are pursuing is a effect that the user wants, since he/she is involved in the translating:
1.1 Adjust the Language arrays that need translation: add a <span> tag with a general class to every item; add a id (=index) if necessary
1.2 Add some css that highlights the text
1.3 Add a click event so that a editor can pop up (and don't interfere with real links)

2. Assuming the user is translating item by item:
2.1 The problem drills down to finding the page(s) in the Geeklog module/plugin that contains that specific item (hard to do for validation text or error messages)
2.2 Do the same as 1.1 upto 1.3, but now for the target translation language only; maybe limit this to untranslated items

Above seems difficult to achieve. Think of adding a new language : "myTranslation". And switch languages after finishing each translated item.

Than, finding target text in the displayed page looks like a javascript endeavor: scan the DOM elements for the text (or all <span>tags). You may catch titles, alt-attributes, form values etc. too.
Maybe xslt, xQuery or xPath could be used, though they are slow too.
And you could load the php array into javascript of course, which is similar to persistence.

Wim




Op 21 jun. 2013, om 23:17 heeft Benjamin Talic het volgende geschreven:

> Hi All,
> 
> Again I have run into a problem with the plugin. I have been trying to figure out a good solution for days...
> 
> The problem:
> Once a page is loaded the plugin should kick in and find all text which is essentially from the LANG arrays from the language file.
> All the solutions I have come up with are bad and I have run out of ideas.
> 
> Here is what I have:
> 
> 1) Assuming that the default site language will not change put all the LANG files inside a database table (also saving the data from which array it originally came and under which index).
> Later on use the text (or HTML) of the shown page to find all matches between what is displayed to the user and what is in the database table. The same thing could somewhat be improved if I would use a persistent PHP array so that the database is queried only once.
> 
> 2) Have a list of all available LANG arrays and loop through them to find macing strings. This would probably take a very long time.
> 
> Both approaches have the same problem, if the page contains a story/comment with the text "We could save the city" it could identify the save from that sentence as a element of the LANG32 array.
> 
> Any nudge in the right direction would be much appreciated...
> 
> Thanks in advance
> Ben
> _______________________________________________
> geeklog-devel mailing list
> geeklog-devel at lists.geeklog.net
> http://eight.pairlist.net/mailman/listinfo/geeklog-devel




More information about the geeklog-devel mailing list