symfony - Caching catalogues from Symfony2 Translation component -


i have been trying figure out way of handling i18n within fuelphp (see here).

i decided import symfony2 translation component (using composer) fuel vendor , manage i18n xliff files.

here (simplified) code:

use \symfony\component\translation\translator; use \symfony\component\translation\messageselector; use \symfony\component\translation\loader\xlifffileloader;  ...  class i18n {      private static $translator = null;      ....      public static function get($key)     {         # load , configure translator         self::$translator = new translator('en_gb', new messageselector());         self::$translator->addloader('xliff', new xlifffileloader());         self::$translator->addresource('xliff', 'path/to/xliff/file', 'en');          # translation         $translation = self::$translator->trans($key, $params);          # return translation         return $translation;     }  } 

so @ first thought working great since testing on small xliff file i've generated complete xliff catalogue (about 1400 entries) entire application, each request slow.

so question is, there way cache translations when using translation component same way whole symfony2 framework caches natively?

the translator class frameworkbundle has constructor accepts options in can define cache_dir. anyway can achieve using translation component?

thanks on matter.

so did generate own cache xliff files, if doesn't exist, nothing more translations php array , make translator component load resources arrayloader instead of xlifffileloader. it's lightning fast now. touki in comments interest.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -