Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. function i18nPOStrings() {
  3.     $locale = str_replace('-', '_', get_instance()->config->item('language_ui')->locale);
  4.     //$default = str_replace('-', '_', get_instance()->config->item('language_ui_default')->locale);
  5.  
  6.     $dir = APPPATH . 'language/locale/' . $locale . '/LC_MESSAGES/';
  7.     $files = glob($dir . '*.po');
  8.  
  9.     foreach ($files as $file) {
  10.         $contents .= file_get_contents($file) or die('Could not read from file.');
  11.  
  12.         preg_match_all('/msgid "(.*?[^\\])"/', $contents, $keys);
  13.         preg_match_all('/msgstr "(.*?[^\\])"/', $contents, $strings);
  14.  
  15.         $output = array_combine($keys[1], $strings[1]);
  16.     }
  17.  
  18.     return $output;
  19. }
  20. ?>