Skip to content

Instantly share code, notes, and snippets.

@jboonstra
Forked from rissajeanne/i18nPOStrings
Created September 12, 2011 19:18
Show Gist options
  • Save jboonstra/1212107 to your computer and use it in GitHub Desktop.
Save jboonstra/1212107 to your computer and use it in GitHub Desktop.
<?php
function i18nPOStrings() {
$locale = str_replace('-', '_', get_instance()->config->item('language_ui')->locale);
//$default = str_replace('-', '_', get_instance()->config->item('language_ui_default')->locale);
$dir = APPPATH . 'language/locale/' . $locale . '/LC_MESSAGES/';
$files = glob($dir . '*.po');
foreach ($files as $file) {
$contents .= file_get_contents($file) or die('Could not read from file.');
preg_match_all('/msgid "(.*?[^\\])"/', $contents, $keys);
preg_match_all('/msgstr "(.*?[^\\])"/', $contents, $strings);
$output = array_combine($keys[1], $strings[1]);
}
return $output;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment