Many websites need to translate only front-end strings and this module helps to do that.
When enabled, module will make two files, one file will contain collected strings, the other one is for excluding strings (t function is called a lot of times and this file will helps to skip unrelated ones, also this file can be modified).
Additionally, this module adds support for importing strings from csv files.

For now, this module needs temporary patch to work which is included with the module.

Sandbox: https://drupal.org/sandbox/rang501/2184179
Git: http://git.drupal.org/sandbox/rang501/2184179.git

CommentFileSizeAuthor
#14 error.png68.16 KBluigisa

Comments

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxrang5012184179git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

rang501’s picture

rang501’s picture

Status: Needs work » Needs review
mike.roberts’s picture

Automated Review:

There are some typos in front_translations_remove.txt

  • Line 951: seperated ==> separated
  • Line 953: seperated ==> separated
  • Line 1441: specfic ==> specific
  • Line 1479: specfic ==> specific
  • Line 1963: succesful ==> successful
  • Line 1985: succesful ==> successful

Manual Review
export_frontend_strings.module

  • Line 13: In your hook menu you're using the path 'admin/config/csv-translation'. Perhaps consider using 'admin/config/regional/csv-translation' to place this menu item in the "Regional and Language" settings.
  • Line 143: You're using _locale_import_one_string_db() which is a "private" function of the locale module and should not be called from outside the module according to Drupal coding standards. There is probably another function in the locale module that is used as a wrapper around this function to be used in outside modules. See this page - https://drupal.org/node/70335 - and this comment - https://drupal.org/comment/3254490#comment-3254490 - for more details.
mike.roberts’s picture

Status: Needs review » Needs work
rang501’s picture

Issues are resolved.
About that private function: I'm unable to find such wrapper function for _locale_import_one_string_db().

rang501’s picture

Status: Needs work » Needs review
heddn’s picture

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

Storing string in the public file system will allow access bypass. Not all front-end strings are viewable by all people. The current implementation would extract those string and place them in a public file system.

Hacking core is not good. Please figure out a different way to implement this module's functionality. Perhaps hook into:

if (!isset($custom_strings[$options['langcode']])) {
    $custom_strings[$options['langcode']] = variable_get('locale_custom_strings_' . $options['langcode'], array());
  }

hook_menu -- Use this format: See https://drupal.org/node/300997

    'page callback' => 'drupal_get_form',
    'page arguments' => array('export_frontend_strings_import_form'),
    'access arguments' => array('administer site configuration'),
    'file' => 'export_frontend_strings.admin.inc',

It's best not to call pseudo private functions from other modules i.e. _locale_import_one_string_db(). Perhaps duplicate the code locally.

rang501’s picture

Status: Needs work » Needs review

I have made some improvements.
Core hacking is not required anymore and strings are not available on files system (moved this part to the variables table).

heddn’s picture

Status: Needs review » Reviewed & tested by the community
Automated Review
Best practice issues identified by pareview.sh / drupalcs / coder
Manual Review
  • Duplication
    • No
  • Multiple applications
    • No
  • README.txt
  • Master Branch
  • 3rd party code
  • Individual user account
  • Code too short/too simple
  • Licensing
    • No
  • Security
  • Coding style & Drupal API usage

    •   $form['csv_file_download']['download_markup'] = array(
          '#markup' => '<p>' . t('Strings collected: @count', array('@count' => $collected_count)) . '</p>' . l(t('Download'), 'admin/config/regional/csv-translation/download'),
        );

      Rather than concatenating the link, insert it into the translated string as a variable replacement.

    • export_frontend_strings_import_form
      There's no validation handler to confirm the file uploaded is a csv file. That would be a good thing.
    • function export_frontend_strings_install() {
        variable_set('export_frontend_strings_collected', array());
        variable_set('export_frontend_strings_exclude', array());
      }

      No need to set the values in hook_install, rather use default values from the variable_get.

    • export_frontend_strings_preprocess_html
      I'm not able to understand what is going on with the js logic in here. Could you provide some comments?
    • _export_frontend_strings_import_one_string_db()
      ...
      $exists = db_query("SELECT COUNT(lid) FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $langcode))->fetchField();
      

      The array should wrap the values onto a new line.

    Starred items (*) are fairly big issues and warrant going back to Needs Review. The rest of the comments in the code walkthrough are recommendations.

Extra Branch
It appears you are working in a "dev" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.

There are no release blockers. Moving to RTBC.

kscheirer’s picture

Status: Reviewed & tested by the community » Needs work

Blocking issues (performance):

  1. What are you trying to do in export_frontend_strings_init()? This function will be executed on every non-cached page request, is it safe to modify locale's static like that? The same applies to export_frontend_strings_preprocess_html(), that gets called on most page renders, surely your module's code doesn't need to affect every page request?

Non-blocking issues:

  • You don't need to set variables in export_frontend_strings_install(), just provide a default when calling variable_get().
  • Is export_frontend_strings_import_form_submit() assuming 'en' is the base language? This might not always be the case
  • You may be able to use db_merge() in _export_frontend_strings_import_one_string_db() to simplify some of the insert/update code

Potentially blocking (duplication):

  • How does this module differ from other translation import/export modules like potx?
rang501’s picture

Hi!
I found some time to fix the issues.

1. I made improvements on the blocking issues, so my code is only running on non-admin paths, which was the main idea in the first place. You are right about the performance problem, and I was aware of that, but I was able to improve it, by not touching it and introducing a new static variable to preserve the state and later on, find the difference between the arrays.

-----
Non-blocking:

  • I don't know what I was thinking, fixed that.
  • Yes, it does. I'll improve it, when it is needed.
  • Maybe, but I wouldn't touch that code, it is taken from locale module.

-----
Potentially blocking:
It is a bit similar, but my module tries to be more specific and collects only those strings the user is interested in (by navigating manually the pages). This might be a rare use case, but it might find more uses over time.

rang501’s picture

Status: Needs work » Needs review
luigisa’s picture

StatusFileSize
new68.16 KB

Automated Review

Found errors in automated review: http://pareview.sh/pareview/httpgitdrupalorgsandboxrang5012184179git

Manual Review

Coding style & Drupal API usage

Found 2 warnings and 1 fatal error, with this can not be review more

heddn’s picture

re #14: Can you be more specific in your review on the fatal error? It isn't clear what action you wish from @rang501.

luigisa’s picture

re #15: for example this:
in this function "export_frontend_strings_preprocess_html"

$merge = array_keys($diff);
+if(!is_array($merge)) {
+ $merge = array($merge);
+}
_export_frontend_strings_merge($merge);

rang501’s picture

Made the required changes.

rang501’s picture

Status: Needs review » Closed (won't fix)