Ver Mensaje Individual
  #8 (permalink)  
Antiguo 23/11/2010, 16:06
Avatar de metacortex
metacortex
Viejo demente
 
Fecha de Ingreso: junio-2004
Ubicación: Caracas - Venezuela
Mensajes: 9.027
Antigüedad: 19 años, 11 meses
Puntos: 832
Respuesta: Problema con array

Voy a aprovechar que en Venezuela estamos en época de besibol para darle un batazo a la mierda de computadora esta, y luego me doy otro por animal.

Éstas son las horas que todavía sigo con esta porquería de código y nada que arranca. He estado intentándolo durante todo el santo día. Me encuentro casi en el mismo punto que al inicio: los datos aparecen ordenados hasta que me encuentro con las malditas líneas repetidas; ahí se desbarata todo y no hallo la forma de ordenarlas una encima de otra. Estoy dando vueltas en círculo.

Éste es el más reciente intento:

Código PHP:
Ver original
  1. <?php
  2. $archivo = str_replace( basename($_SERVER['PHP_SELF']) , '' , $_SERVER['SCRIPT_FILENAME']) . '/lang/prueba.po';
  3. $leer = file($archivo, FILE_IGNORE_NEW_LINES);
  4. $html = null;
  5. $txt = null;
  6. foreach($leer as $l) {
  7.     $txt = explode(' ' , $l);
  8.     switch($txt[0]) {
  9.         case 'msgid':
  10.             $html .='<h3>'. $l .'</h3>' . "\n";
  11.         break;
  12.         case 'msgstr':
  13.             $html .='<p>'. $l .'</p>' . "\n";
  14.         break;
  15.         case 'msgstr[0]':
  16.             $html .='<p>'. $l .'</p>' . "\n";
  17.         break;
  18.         case 'msgid_plural':
  19.             $html .='<h3>'. $l .'</h3>' . "\n";
  20.         break;
  21.         case 'msgstr[1]':
  22.             $html .='<p>'. $l .'</p>' . "\n";
  23.         break;
  24.     }
  25. }
  26. echo $html;
  27. ?>

Así debería quedar la cosa: el texto en azul debería ir en la posición indicada.



Anexo archivo de prueba por si acaso:

Código PHP:
Ver original
  1. # Translation of WordPress 2.9.2.
  2. # Copyright (C) 2010 WordPress
  3. # This file is distributed under the same license as the WordPress package.
  4. # FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
  5. #
  6. msgid ""
  7. msgstr ""
  8. "Project-Id-Version: WordPress 2.9.2 en español (v1.0)\n"
  9. "Report-Msgid-Bugs-To: [email protected]\n"
  10. "POT-Creation-Date: 2010-02-15 17:47+0000\n"
  11. "PO-Revision-Date: 2010-02-16 01:12+0100\n"
  12. "Last-Translator: \n"
  13. "Language-Team: TodoWordPress <[email protected]>\n"
  14. "MIME-Version: 1.0\n"
  15. "Content-Type: text/plain; charset=UTF-8\n"
  16. "Content-Transfer-Encoding: 8bit\n"
  17. "Plural-Forms: nplurals=2; plural=n !=1;\n"
  18. "X-Poedit-Language: Spanish\n"
  19. "X-Poedit-Country: SPAIN\n"
  20. "X-Poedit-SourceCharset: utf-8\n"
  21.  
  22. #: wp-admin/edit-attachment-rows.php:207
  23. msgid "Get permalink"
  24. msgstr "Obtener enlace permanente"
  25.  
  26. #: wp-admin/edit-attachment-rows.php:226
  27. #: wp-admin/upload.php:434
  28. msgid "No media attachments found."
  29. msgstr "No hay archivos que mostrar."
  30.  
  31. #: wp-admin/edit-category-form.php:14
  32. msgid "You do not have sufficient permissions to edit categories for this blog."
  33. msgstr "No tienes permisos para editar las categorías del blog."
  34.  
  35. #: wp-admin/edit-category-form.php:80
  36. #: wp-admin/edit-link-category-form.php:27
  37. #: wp-admin/includes/template.php:266
  38. msgid "Update Category"
  39. msgstr "Actualizar categoría"
  40.  
  41. #: wp-admin/edit-comments.php:114
  42. #, php-format
  43. msgid "Edit Comments on “%s”"
  44. msgstr "Editar comentarios en “%s”"
  45.  
  46. #: wp-admin/edit-comments.php:116
  47. msgid "Edit Comments"
  48. msgstr "Editar comentarios"
  49.  
  50. #: wp-admin/edit-comments.php:151
  51. #, php-format
  52. msgid "%s comment approved"
  53. msgid_plural "%s comments approved"
  54. msgstr[0] "%s comentario aprobado"
  55. msgstr[1] "%s comentarios aprobados"
  56.  
  57. #: wp-admin/edit-comments.php:155
  58. #, php-format
  59. msgid "%s comment marked as spam."
  60. msgid_plural "%s comments marked as spam."
  61. msgstr[0] "%s comentario ha sido marcado como spam"
  62. msgstr[1] "%s comentarios han sido marcados como spam"
  63.  
  64. #: wp-admin/edit-comments.php:157
  65. #: wp-admin/edit-comments.php:166
  66. #: wp-admin/edit-pages.php:170
  67. #: wp-admin/edit.php:171
  68. #: wp-admin/includes/image-edit.php:56
  69. #: wp-admin/includes/media.php:1243
  70. #: wp-admin/includes/template.php:2384
  71. #: wp-admin/includes/template.php:2387
  72. #: wp-admin/upload.php:210
  73. #: wp-includes/js/tinymce/langs/wp-langs.php:213
  74. #: wp-includes/js/tinymce/wp-mce-help.php:209
  75. msgid "Undo"
  76. msgstr "Deshacer"
  77.  
  78. #: wp-admin/edit-comments.php:160
  79. #, php-format
  80. msgid "%s comment restored from the spam"
  81. msgid_plural "%s comments restored from the spam"
  82. msgstr[0] "El comentario %s ha sido restaurado."
  83. msgstr[1] "Los comentarios %s han sido restaurados."
  84.  
  85. #: wp-admin/edit-comments.php:164
  86. #, php-format
  87. msgid "%s comment moved to the trash."
  88. msgid_plural "%s comments moved to the trash."
  89. msgstr[0] "%s comentario ha sido mandado a la papelera."
  90. msgstr[1] "%s comentarios han sido enviados a la papelera."