+ Reply to Thread
Results 1 to 3 of 3

Thread: Zend_Application & Zend_Translate - How to use the array adapter ?

  1. #1
    pmuller is offline Junior Member
    Join Date
    Jul 2009
    Posts
    2

    Default Zend_Application & Zend_Translate - How to use the array adapter ?

    I (think I) configured Zend_Applicate's translate resource to use arrays :
    [PHP]
    resources.translate.adapter = "array"
    resources.translate.data.fileExt = ".php"
    resources.translate.data.directory = APPLICATION_PATH "/translations/"
    resources.translate.options.scan = "directory"
    resources.translate.options.disableNotices = true
    resources.translate.options.logUntranslated = true[/PHP]

    I wrote 2 translation files :
    [PHP]
    $ ls -l application/translations/
    total 16
    -rw-r--r-- 1 pmuller staff 2153 Jul 16 02:47 en.php
    -rw-r--r-- 1 pmuller staff 2269 Jul 16 02:47 fr.php[/PHP]

    Each file contains a "return array()", like this excerpt from fr.php :
    [PHP]
    <?php
    return array(
    // Errors
    'Page not found' => 'La page que vous avez demandé est introuvable',
    'An error occurred' => 'Une erreur est survenue',
    'Application error' => 'Erreur interne',
    // Home page
    'Read more' => 'Suite',
    );[/PHP]

    I think I missed something, because nothing is being translated.

    To troubleshoot further, I enabled Zend_Translate logging feature. The logs confirm that nothing can be translated :
    [PHP]
    Untranslated message within 'fr': Page not found
    Untranslated message within 'fr': An error occurred
    Untranslated message within 'fr': Help[/PHP]
    (it's the same for 'en')

    I tried to rename fr.php to fr_FR.php and en.php to en_US.php, but I got no improvement.
    I want Zend_Translate to translate fr_* using fr.php and en_* using en.php.

    I hope someone knows what I missed.. Thanks!

  2. #2
    matthijsvandenbos is offline Junior Member
    Join Date
    Jul 2009
    Posts
    2

    Default

    I think you have an error in your ini settings for the translate resource. 'resources.translate.data' is not an array, it should be a string pointing to your data:
    [PHP]resources.translate.adapter = "array"
    resources.translate.data = APPLICATION_PATH "/translations/"
    resources.translate.options.scan = "directory"
    resources.translate.options.disableNotices = true
    resources.translate.options.logUntranslated = true [/PHP]

    The 'fileExt' and 'directory' settings don't exist.

    If you want to know more about setting translation for multiple modules using Zend_Application and a custom translate resource, check my article about it: ZF: per module translations sources.

  3. #3
    pmuller is offline Junior Member
    Join Date
    Jul 2009
    Posts
    2

    Default

    Thanks!

    You are right, these options doesn't exists. And now, it's working !

    The other parameter I had to fix was :
    [PHP]resources.translate.options.scan = "filename"
    [/PHP]

    Otherwise, Zend_Translate can't map filenames to language codes.

+ Reply to Thread

Similar Threads

  1. Replies: 2
    Last Post: 12-15-2009, 08:52 PM
  2. Zend_Application & MVC
    By muan in forum General Q&A on Zend Framework
    Replies: 2
    Last Post: 05-30-2009, 08:22 PM
  3. Zend_Translate tmx adapter
    By Nicolas Milesi in forum Internationalization (i18n) & Localization (l10n)
    Replies: 1
    Last Post: 03-16-2009, 03:23 PM
  4. Zend_Translate & Zend_Cache (with TMX adapter)
    By Nicolas Milesi in forum Internationalization (i18n) & Localization (l10n)
    Replies: 1
    Last Post: 03-04-2009, 07:54 AM
  5. Db adapter for Zend_Translate
    By Cristian in forum Internationalization (i18n) & Localization (l10n)
    Replies: 2
    Last Post: 02-16-2009, 06:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts