"TMGMT OHT" module is a plugin for Translation Management Tool module. It uses OneHourTranslation service for automated translation of the content.

Project page: http://drupal.org/sandbox/OneHourTranslation/1612398.
Git clone: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/OneHourTranslation/1612398.git tmgmt_oht.
Drupal version: Drupal 7
Dependencies: Translation Management Tool

I have examined my project using PAReview. Here is results: http://ventral.org/pareview/httpgitdrupalorgsandboxonehourtranslation161...

Reviews of other projects:
http://drupal.org/node/1619120#comment-6085064
http://drupal.org/node/1619120#comment-6085596
http://drupal.org/node/1632990#comment-6116076
http://drupal.org/node/1632990#comment-6116128
http://drupal.org/node/1635612#comment-6120558
http://drupal.org/node/1632990#comment-6116128

Comments

patrickd’s picture

Status: Active » Needs review

welcome,

Good to see that you've fixed all issues of the automated report

Please read about the workflow for project applications.

As installation and usage instructions are quite important for us to review, please take a moment to make your project page follow the tips for a great project page. Also make sure your README.txt follows the guidelines for in-project documentation. Your readme may follow the contents of your project page.

We do really need more hands in the application queue and highly recommend to get a review bonus so we can come back to your application sooner.

regards

patrickd’s picture

Issue summary: View changes

added link to PAReview results.

DavidS’s picture

changed description of the project

DavidS’s picture

Issue summary: View changes

added more info regarding reviews

DavidS’s picture

Status: Needs review » Active

I have added links to bonus reviews in the topic

DavidS’s picture

changing status to needs review

patrickd’s picture

Status: Active » Needs review
Issue tags: +PAreview: review bonus

you forgot the tag

patrickd’s picture

Issue summary: View changes

added info about reviews

carlhinton’s picture

Checked through ventral - the code is clear of any errors

DavidS’s picture

yes, this has been mentioned in the first post.

berdir’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus

Nice work! The code looks great.

A bunch of things that I noticed below, mostly just some ideas/remarks, the only things that should be fixed is the finished() call and the check_plain(). Happy to RTBC this after that.

    $job = tmgmt_job_load(check_plain($_POST['custom0']));

The check_plain() here doesn't make much sense. That should only be used for things that are going to be displayed. You should be able to simply remove it.

    $job->addMessage('Status for project @project changed to "@status". Estimated finish: @finish',

Hint: You *could* use %status instead of adding "", that would wrap it in < em > tags by default. Also

@project_id

in the submitted message.

exit('');

You shouldn't use exit() in a page callback, that can have weird results because some cleanup things might not be run properly. If you don't return anything in your page callback then Drupal will render an empty page by default. If you really want to exit, you should call drupal_exit().

- I noticed that you have a hardcoded supported language list. This is fine but the downside is that when you add a new language on your side, you need to do a new release so that users can translate into that language. The Supertext translator plugin AFAIK does this mapping on the server side. This is absolutely nothing that you need to fix, just something to keep in mind as a possible improvement for a later version.

    $job->finished('The translation has been received.');

You shouldn't do this. Adding translations will automatically set all job items to needs review and once they are accepted (manually or automatically), will mark the job as finished automatically.

   foreach ($data as $key => $value) {
      $items .= str_replace(array('@key', '@text'), array($key, $value['#text']), '<item key="@key"><text type="text/html"><![CDATA[@text]]></text></item>');

Do you have a way to pass a label of the text forward? We're still improving the API part of that, but there is both a #label and a #parent_labels ( I think, in the latest -dev) property that you could use.

berdir’s picture

Uh, no idea why the "PAReview: review bonus" was removed, does that happen automatically?

DavidS’s picture

Status: Needs work » Needs review
Issue tags: +PAreview: review bonus

@Berdir, all issues you have mentioned fixed.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

It looks like you added a "d" somewhere to a comment, search for "Handling response.d".

Other than that, this looks good to me. Thanks for the quick response.

Any idea already on how to deal with the label? My suggestion would be to open an issue so that it can be discussed there. Please tell me the issue number so that I can follow.

berdir’s picture

Issue summary: View changes

added one more link of manual review

DavidS’s picture

I have fixed this mistyping.

Now, we support only content translation. But, as I understood, you suggest to translate also labels and other stuff, yes?
In any case, I think you can create issue in project's issue queue.

berdir’s picture

I don't mean translating the labels, just passing them through. See http://drupal.org/node/1645244. They might contain relevant information for a translator.

The advantage of relying on TMGMT is that you don't need to care if something is content or something else. A job could just as well contain comments/commerce products/... through entity translation, or things like menus or taxonomy terms through i18n string translation. That's another reason the labels are important, as they would tell you there if it's a menu link title or description and so on.

DavidS’s picture

Ok, thanks, I will think, but I don't sure if this will be useful since the XML (which we are sending for translation) doesn't make any sense for translator. They see this XML in raw format.
This format has been introduced by module developers to have possibility to send HTML data for translation.

klausi’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

manual review:

  • tmgmt_oht_callback(): this menu callback is unprotected. Anyone can send POST data to your site which is inserted for translation review. I'm not familiar with the TMGMT architecture here, and the other modules in TMGMT core seem to have the same weakness. Could you explain how a site is protected against random spam translation submitted by someone impersonating the translation service? Maybe I'm missing something here, can't find the access check.

Otherwise looks ready to me.

berdir’s picture

Status: Postponed (maintainer needs more info) » Needs work

Oh yes, I missed that, sorry.

Most translators solve this by passing the/some authentication information from the server to the client, e.g. the same api and signed key. Also, I think all translators don't actually submit the translations directly, they just tell the client that the translation is ready and provide an API to fetch translations.

This has two advantages:
a) It's not possible to inject something. the client always needs to connect to the service and authenticate there to get the information.
b) Websites behind a firewall (e.g. intranets, although those probably don't require translations, but dev/staging environments are often not available from the outside) can do a manual fetch, triggered by a button in the checkoutInfo() method, see the nativy translator for an example of that.

I however think that this part is optional and would possibly require a quite major overhaul of your API. However, doing some kind of authentication is quite important.

DavidS’s picture

Status: Needs work » Needs review

I have refactored code. Now translation are retrieving with another call to API.

@Berdir. While testing and refactoring, I have found some strange (maybe not) thing. I got broken request because of empty field reference in TMGMTJob object (see code here). It didn't save value but I set value. (My code is similar to the one in nativy module.)
After some debugging I found non-obvious thing: in requestTranslation() method, I should post this line before adding messages to the job (calling addMessage or submitted).
But there is another thing, which impressed me: method submitted() calls method setState(), which calls $this->save() and $this->addMessage(). The last one also is saving job entity. So when we call submitted() method the current job will be saved twice.
I thought maybe this is not good and you should know that.

Thanks.

misc’s picture

Status: Needs review » Reviewed & tested by the community

You have some minor coding standards errors you should take care about:
http://ventral.org/pareview/httpgitdrupalorgsandboxonehourtranslation161...

Else, this is RTBC for me, one question though - is your user account a company or a personal one?

misc’s picture

Issue tags: -PAreview: review bonus

Removing review bonus, please do more reviews to get a quicker approval.

DavidS’s picture

Thanks. I have fixed comments' formatting.

misc’s picture

How about the user account, is it personal or company?

berdir’s picture

Reason for the question: AFAIK it's not permitted to have shared accounts that are used by multiple people, although I currently can't find where this is stated. If that's not the case anyway, maybe rename your account to avoid such confusions.

Note that once your project is approved, you can add as many personal accounts from your company as maintainers for the project as you want and they can have full control over it, the only thing they can't do is create new full projects on their own.

klausi’s picture

This is stated at http://drupal.org/user/register (you need to log out to access that page)

DavidS’s picture

So, I have changed the name of account. Can we proceed now?

misc’s picture

@DavidS: You still have to answer the question #21, so it is not unclear.

DavidS’s picture

I have changed the name of the account, and I hoped it's clear now that this is personal account.

misc’s picture

It should be clear but I world also like if you answer the question so we know, so I ask again is your user account personal?

klausi’s picture

Status: Reviewed & tested by the community » Needs work

manual review:
tmgmt_oht_callback(): i can still inject random status change messages for a job. I just have to guess a job id. Please make sure that those messages can only be added from an authorized source.

DavidS’s picture

Status: Needs work » Needs review

I have added hash into request parameters to avoid spamming. Please, review.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Changes look good to me.

To avoid any discussions: Yes, a call with a wrong argument is going to lead to a watchdog entry, but there are easy ways to do this with a bare Drupal core installation as well, just go to /doesnotexist and it will do the same. So really not a problem.

misc’s picture

Status: Reviewed & tested by the community » Needs work

#21 have never been answered, please do so.

berdir’s picture

Status: Needs work » Reviewed & tested by the community

I don't understand what you're trying to achieve here.

#26 is quite clear to me, he states that it is a personal account:

I have changed the name of the account, and I hoped it's clear now that this is personal account.

Translates to Yes, this is a personal account.

As klausi mentioned, this rule is displayed on the user register form so he already agreed to it when he created the account. And even if it weren't so, nobody would honestly answer No to that question in here, knowing that it's not allowed. Which means that your question is pointless, it's enough to clearly state that it must be personal, what has been done multiple times.

misc’s picture

Berdir, please do not get into discussion if this is valid question or not here. Raise the question the code review group or on #drupal-codereview. It is a simple question and has not been direct answered by the applicant. I will approve @DavidS as git vetted user after I get a direct answer on that question. (ups, can not do that, I reviewed this one, sorry)

DavidS’s picture

@MiSc, for the question #21 the answer is: This is personal account!

I hope we can proceed now with module reviewing and finish the discussion about account status.

DavidS’s picture

@Berdir,

Sorry I don't understand what are you saying:

there are easy ways to do this with a bare Drupal core installation as well, just go to /doesnotexist and it will do the same.

What do you mean? Just call drupal_not_found() instead of adding entry to watchdog?

berdir’s picture

Watchdog is fine, that's what I was trying to say :)

DavidS’s picture

ok, thanks.

What else should I do?

mitchell’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, DavidS!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on irc in #drupal-contribute and #drupal-i18n. So, come hang out and stay involved! Thanks again, and good luck! :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

one more review added