[geeklog-devel] CrowdTranslation-LANG array mapping

Tom websitemaster at cogeco.net
Sat Jun 22 10:33:48 EDT 2013


Hi Ben,

 

I am a little confused (my own doing as I haven't kept up on the project), I
was thinking the translations would be done on its own page from a list and
not on the actual page.

 

I don't think we would want to alter core/plugins language files directly
(unless at the end when everything is approved). Your Crowd Sourcing
Translation Plugin (CSTP) should keep it separate.

 

I think I would start by creating a plugin api (this would be hardcoded for
core) that the plugin would call when it is installed or upgraded  that
would let the CSTP know what it's language arrays are. Once this is known
your plugin could keep several different copies (originals, ones with span
added, new translations (I guess you could have multiple new translations
for one item from multiple users that are not approved))  serialized and
stored in the db.

 

To replace the existing Lang arrays with your new ones (with the edit icon)
I think as long as your plugin is the last in the plugin load order it could
do this  after all the other plugins  and core have set their language files
you would just overwrite them in memory.

 

This wouldn't be exactly the fastest way to go (since in reality you are
setting the language files twice) but it is the least obtrusive way to do it
and would require the least amount of code changes for core and plugins that
I can see.

 

One way to speed this up would be to allow the admin to set what he wants to
be translated. Some people may be interested in only having one  or two
plugins translated while other sites (like Geeklog.net) would have
everything setup to be translated.

 

I also wonder if there should be a translation mode. I don't think anonymous
users should be allowed to translate anything. But once logged in they could
go to the CSTP user page and enable translations which would in turn enable
the CSTP to switch the language arrays for its versions and allow the user
to start translating. Once they are finished they could turn off the
translation mode and continue to use the site.

 

Hope this helps

 

Tom

 

From: geeklog-devel-bounces at lists.geeklog.net
[mailto:geeklog-devel-bounces at lists.geeklog.net] On Behalf Of Benjamin Talic
Sent: June-21-13 6:41 PM
To: Geeklog Development
Subject: Re: [geeklog-devel] CrowdTranslation-LANG array mapping

 

Thank you for the reply Wim,
What you proposed is more or less what I had in mind.
But the current problem is actually identifying which strings should be
translated, that is which of the strings on the page are generated
from the language arrays.
The easiest way for me would be to "simply" go through the source code and
add a span everywhere where a LANG array is called, but with the first
change to geeklog the plugin would get  useless. Unless future developers
would go with adding the span (which I doubt).
Another thing which came to mind is to make the plugin, upon install get all
the geeklog php files as strings and add those spans programmatic. 

Something like 

 

 $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.'

. $_IMAGE_TYPE . '" alt="' . $LANG01[48] 

. '" title="' . $LANG01[48] . '"' . XHTML . '>'; 

 

would become

 

 $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.'

 . $_IMAGE_TYPE . '" alt="' ."<span class="translator">". $LANG01[48]
."</span>"

 . '" title="'."<span class="translator">" . $LANG01[48] ."</span>" . '"' .
XHTML . '>';

Or what would be much faster, and more reliable, to let the plugin alter the
actual language files and add such a span prefix to the arrays.

If I could do something like that I could use the jQuery selector to
identify the strings on a page. If we talk about expanding this to other
plugins and such the difference would be that I would have several classes
for the span such as class="translator_core",
class="translator_plugin_name"...

Would some of those approaches be acceptable?


Ben

 

On Sat, Jun 22, 2013 at 12:03 AM, Niemans <niemans at nlbox.com> wrote:


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

_______________________________________________
geeklog-devel mailing list
geeklog-devel at lists.geeklog.net
http://eight.pairlist.net/mailman/listinfo/geeklog-devel





 

-- 

Regards,

Benjamin

 

 

home:         http://summergeeek.blogspot.com/   nvandgsoc.blogspot.com

skype:         benjamintalic

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist8.pair.net/pipermail/geeklog-devel/attachments/20130622/8c894aef/attachment.html>


More information about the geeklog-devel mailing list