Zend Framework

Lazy loading files with translations

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Not an Issue
  • Affects Version/s: 1.10.1
  • Fix Version/s: 1.10.2
  • Component/s: Zend_Translate
  • Labels:
    None

Description

Seems to be nice load files with translations at the time when Zend_Translate_Adapter::translate() method call.
This will load only the translations for the language you want at the moment.

Activity

Hide
Thomas Weidner added a comment - - edited

This does not work like expected:

It leads to the problem that "translate" throws out exceptions due to

    • false locale
    • non existing files
    • corrupt files

All these problems are caught by loading the files before translating.

Lazy loading would also negotate caching.
It adds a performance problem at translation when using formats which are very excessive like TMX as you delay the loading time into the application time instead of session start.

Additionally it would mean that you must traverse the complete directory tree when calling a translation and read all files to know if a translation is available.

Show
Thomas Weidner added a comment - - edited This does not work like expected: It leads to the problem that "translate" throws out exceptions due to
    • false locale
    • non existing files
    • corrupt files
All these problems are caught by loading the files before translating. Lazy loading would also negotate caching. It adds a performance problem at translation when using formats which are very excessive like TMX as you delay the loading time into the application time instead of session start. Additionally it would mean that you must traverse the complete directory tree when calling a translation and read all files to know if a translation is available.
Hide
Andrew Kozlov added a comment -

An example: my site on ZF uses 3 (en, de, ru) languages and about 10 files with translations for each language. Basically, I use only one language, for example "en". Оn all pages of my site I see the text in english, until I choose a different language from menu.
Since I need only one language (en), so why do ZF load files for the other two languages? This is overhead IMHO.

Are there no ways to load only files with necessary translations (en)?

Show
Andrew Kozlov added a comment - An example: my site on ZF uses 3 (en, de, ru) languages and about 10 files with translations for each language. Basically, I use only one language, for example "en". Оn all pages of my site I see the text in english, until I choose a different language from menu. Since I need only one language (en), so why do ZF load files for the other two languages? This is overhead IMHO. Are there no ways to load only files with necessary translations (en)?
Hide
Thomas Weidner added a comment -

The files are loaded because you say that they all have to be loaded.

Why don't you simply define that only the wished language should be loaded?
Look into the manual for details about loading translations.

Show
Thomas Weidner added a comment - The files are loaded because you say that they all have to be loaded. Why don't you simply define that only the wished language should be loaded? Look into the manual for details about loading translations.
Hide
Thomas Weidner added a comment -

Closing as non-issue

Show
Thomas Weidner added a comment - Closing as non-issue

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: