Created
November 6, 2013 21:29
-
-
Save brycefisher/7344428 to your computer and use it in GitHub Desktop.
Drupal6: Create dummy translations of all nodes in a content type via drush script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @file | |
| * This is a drush script designed to create fake translations of the genera pages for development purposes ONLY. | |
| * | |
| * NOTE: | |
| * ----- | |
| * This file must be located somewhere inside the drupal root. | |
| * | |
| * USAGE: | |
| * ------ | |
| * 1) Open Terminal | |
| * 2) cd into the directory containing this file. | |
| * 3) Now execute: | |
| * $ drush scr make-solution-section-translations.php | |
| * 4) You should see a list of node ids created as translations from other node ids printed to the screen. | |
| */ | |
| // Find all genera nodes | |
| $results = db_query(' | |
| SELECT nid | |
| FROM {node} | |
| WHERE type = "mktg_solution_genus" | |
| AND language = "en" | |
| '); | |
| while($node = db_fetch_object($results)) { | |
| // modify node:tnid - used by i18n | |
| $node = node_load($node->nid); | |
| $tnid = $node->nid; | |
| $node->tnid = $tnid; | |
| node_save($node); | |
| // create translations | |
| $languages = array('de','es','fr','ja','ko'); | |
| foreach ($languages as $langcode) { | |
| $node->nid = NULL; | |
| $node->language = $langcode; | |
| $node->tnid = $tnid; | |
| node_save($node); | |
| print "Created new $langcode translation node {$node->nid} from source node {$node->tnid}\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment