IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

task i18n:extract => there is not connection [1.x]


Sujet :

Symfony PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de guiyomh
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    328
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 328
    Par défaut task i18n:extract => there is not connection
    Bonjour,

    j'essaye de faire un projet avec Diem. j'ai bien avancé, et je souhaite maintenant générer le cataloge de traduction.

    je lance donc la commande
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ./symfony i18n:extract front fr
    et j'ai un beau pavé rouge qui apparaît avec "There is no open connection",

    j'ai chercher un peu comment c'est fait dans diem. Apparemment, il stocke el catalogue en base de donnée. Je pense donc avec un problème de connexion à la base de donnée.

    Mais comment on configure ça ?

    merci

  2. #2
    Expert confirmé
    Avatar de Michel Rotta
    Homme Profil pro
    DPO
    Inscrit en
    Septembre 2005
    Messages
    4 954
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : DPO
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2005
    Messages : 4 954
    Par défaut
    J'ai abandonné tout espoirs de faire quelque chose avec i18n:extract pour un projet de plus de 1 modules...

    Je n'ai pas utilisé Diem, mais, à priori, il te faudra renseigner tes enregistrement, à la mano. Ou faire un CRUD dessus.

    Et tu peux, dans la configuration de i18n mettre un préfixe et un surfix à tous ce qui n'a pas été traduit dans la langue utilisée.

  3. #3
    Membre éclairé Avatar de guiyomh
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    328
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 328
    Par défaut
    Bonjour,

    je pense avoir localiser une partie du problème.
    Ce serais dans la class dmDb (dmCorePlugin/lib/doctrine/database/dmDb.php)
    dans la méthode pdo().
    Cette méthode est appeler depuis la class sfMessageSource_dm (dmCorePlugin/lib/i18n/sfMessageSource_dm.php)

    Je pense que la tâche n'arrive pas à créer la connexion à la base de donnée. Ce qui met en échec la méthode pdo().
    Je me demande si c'est pas lié au fait qu'on ne précise pas l'environnement lors de l’exécution de la tâche.

  4. #4
    Membre éclairé Avatar de guiyomh
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    328
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 328
    Par défaut
    J'ai progresser,

    j'arrive a me connecter à la base et à lister les chaine à traduire, j'ai pour cela modifier le code de /lib/vendor/diem/symfony/lib/task/i18n/sfI18nExtractTask.class.php


    voic le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
     
    <?php
     
    /*
     * Current known limitations:
     *   - Can only works with the default "messages" catalogue
     *   - For file backends (XLIFF and gettext), it only saves/deletes strings in the "most global" file
     */
     
    /*
     * This file is part of the symfony package.
     * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
     *
     * For the full copyright and license information, please view the LICENSE
     * file that was distributed with this source code.
     */
     
    /**
     * Extracts i18n strings from php files.
     *
     * @package    symfony
     * @subpackage task
     * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
     * @version    SVN: $Id: sfI18nExtractTask.class.php 9883 2008-06-26 09:04:13Z FabianLange $
     */
    class sfI18nExtractTask extends sfBaseTask
    {
      /**
       * @see sfTask
       */
      protected function configure()
      {
        $this->addArguments(array(
          new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'),
          new sfCommandArgument('culture', sfCommandArgument::REQUIRED, 'The target culture'),
        ));
     
        $this->addOptions(array(
          new sfCommandOption('display-new', null, sfCommandOption::PARAMETER_NONE, 'Output all new found strings'),
          new sfCommandOption('display-old', null, sfCommandOption::PARAMETER_NONE, 'Output all old strings'),
          new sfCommandOption('auto-save', null, sfCommandOption::PARAMETER_NONE, 'Save the new strings'),
          new sfCommandOption('auto-delete', null, sfCommandOption::PARAMETER_NONE, 'Delete old strings'),
     
    /*************************************************************
     * Ajouter les 2 lignes ci-dessous
     **********************************************************/
          new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), //<--------------A rajouter
          new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),  //<--------------A rajouter
     
    /*************************************************************
     * Fin de l'ajout
     **********************************************************/
        ));
     
        $this->namespace = 'i18n';
        $this->name = 'extract';
        $this->briefDescription = 'Extracts i18n strings from php files';
     
        $this->detailedDescription = <<<EOF
    The [i18n:extract|INFO] task extracts i18n strings from your project files
    for the given application and target culture:
    
      [./symfony i18n:extract frontend fr|INFO]
    
    By default, the task only displays the number of new and old strings
    it found in the current project.
    
    If you want to display the new strings, use the [--display-new|COMMENT] option:
    
      [./symfony i18n:extract --display-new frontend fr|INFO]
    
    To save them in the i18n message catalogue, use the [--auto-save|COMMENT] option:
    
      [./symfony i18n:extract --auto-save frontend fr|INFO]
    
    If you want to display strings that are present in the i18n messages
    catalogue but are not found in the application, use the
    [--display-old|COMMENT] option:
    
      [./symfony i18n:extract --display-old frontend fr|INFO]
    
    To automatically delete old strings, use the [--auto-delete|COMMENT] but
    be careful, especially if you have translations for plugins as they will
    appear as old strings but they are not:
    
      [./symfony i18n:extract --auto-delete frontend fr|INFO]
    EOF;
      }
     
      /**
       * @see sfTask
       */
      public function execute($arguments = array(), $options = array())
      {
        $this->logSection('i18n', sprintf('extracting i18n strings for the "%s" application', $arguments['application']));
    /*************************************************************
     * Ajouter les 2 lignes ci-dessous
     **********************************************************/
        $databaseManager = new sfDatabaseManager($this->configuration);
        $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     
    /*************************************************************
     * Fin de l'ajout
     **********************************************************/
        // get i18n configuration from factories.yml
        $config = sfFactoryConfigHandler::getConfiguration($this->configuration->getConfigPaths('config/factories.yml'));
     
        $class = $config['i18n']['class'];
        $params = $config['i18n']['param'];
        unset($params['cache']);
     
        $extract = new sfI18nApplicationExtract(new $class($this->configuration, new sfNoCache(), $params), $arguments['culture']);
        $extract->extract();
     
        $this->logSection('i18n', sprintf('found "%d" new i18n strings', count($extract->getNewMessages())));
        $this->logSection('i18n', sprintf('found "%d" old i18n strings', count($extract->getOldMessages())));
     
        if ($options['display-new'])
        {
          $this->logSection('i18n', sprintf('display new i18n strings', count($extract->getOldMessages())));
          foreach ($extract->getNewMessages() as $message)
          {
            $this->log('               '.$message."\n");
          }
        }
     
        if ($options['auto-save'])
        {
          $this->logSection('i18n', 'saving new i18n strings');
          $extract->saveNewMessages();
        }
     
        if ($options['display-old'])
        {
          $this->logSection('i18n', sprintf('display old i18n strings', count($extract->getOldMessages())));
          foreach ($extract->getOldMessages() as $message)
          {
            $this->log('               '.$message."\n");
          }
        }
     
        if ($options['auto-delete'])
        {
          $this->logSection('i18n', 'deleting old i18n strings');
     
          $extract->deleteOldMessages();
        }
      }
    }
    ensuite il faut éxécuter la commande suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ./symfony i18n:extract front fr --display-new
    cela devrait vous listez la liste de message contenu dans votre code.

    Pour les sauvegarder il faut executer cette commande :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    ./symfony i18n:extract front fr --display-new --auto-save
    Mais là ça ne marche plus. on tombe sur une exception
    not implemented
    j'ai trouvez ou ça doit s'implémenter. C'est dans le fichier : /lib/vendor/diem/dmCorePlugin/lib/i18n/sfMessageSource_dm.php on a la methode :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
      /**
       * Saves the list of untranslated blocks to the translation source.
       * If the translation was not found, you should add those
       * strings to the translation source via the <b>append()</b> method.
       *
       * @param string $catalogue the catalogue to add to
       * @return boolean true if saved successfuly, false otherwise.
       */
      function save($catalogue = 'messages')
      {
          echo "\ntoto";
        throw new dmException('not implemented');
      }
    Donc normale, iljuste trouver la bonne requête SQL a faire et l'exécuter avec dmDb::pdo

    Vous remarquerez que les méthode delete et update ne sont pas implémenter également.
    Voilà ou j'en suis ce soir. Si quelqu'un à une idée pour les requête SQL je suis preneur. ça me ferais gagner un peut de temps. ça fais 3 jours que je me casse les dents sur ce problème en dormant 4 heures par nuit. Là je vais me piotter pour reprendre un peu de force.

    Bonne soiréé.

  5. #5
    Membre éclairé Avatar de guiyomh
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    328
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2007
    Messages : 328
    Par défaut
    Je peux pas dormir faut que je code ce truc.

    voici ce que ça donne et ça marche pas trop mal. ça insert en base :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
      /**
       * Saves the list of untranslated blocks to the translation source.
       * If the translation was not found, you should add those
       * strings to the translation source via the <b>append()</b> method.
       *
       * @param string $catalogue the catalogue to add to
       * @return boolean true if saved successfuly, false otherwise.
       */
      function save($catalogue = 'messages')
      {
        $name_catalogue = $catalogue.".".$this->culture;
        $catalogue = Doctrine_Core::getTable('DmCatalogue')->findOneByName($name_catalogue);
        foreach($this->untranslated as $message){
            $DmTransUnit = new DmTransUnit();
            $DmTransUnit->source = $message;
            $DmTransUnit->DmCatalogue = $catalogue;
            $DmTransUnit->save();
        }
        return true;
      }

  6. #6
    Expert confirmé
    Avatar de Michel Rotta
    Homme Profil pro
    DPO
    Inscrit en
    Septembre 2005
    Messages
    4 954
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : DPO
    Secteur : Distribution

    Informations forums :
    Inscription : Septembre 2005
    Messages : 4 954
    Par défaut

    Super, je suis sur que tu vas aider beaucoup de développeur avec cet implémentation.

    Peut-être peux-tu même la proposer pour qu'elle soit intégrée dans Diem ?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [EasyPHP] Could not connect to MySQL
    Par sky88 dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 6
    Dernier message: 03/12/2014, 15h31
  2. Réponses: 0
    Dernier message: 18/11/2007, 20h53
  3. [MAMP] Error: Could not connect to MySQL server!
    Par midiweb dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 4
    Dernier message: 22/10/2007, 11h07
  4. [Erreur] [sql-dmo] this server objet is not connected
    Par MaxBoys dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 14/09/2007, 08h53
  5. Getpeername (in.ftpd): Transport endpoint is not connected
    Par vbcasimir dans le forum Administration système
    Réponses: 1
    Dernier message: 04/08/2006, 14h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo