Skip to content

Instantly share code, notes, and snippets.

@mamchenkov
Created December 12, 2012 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamchenkov/4266276 to your computer and use it in GitHub Desktop.
Save mamchenkov/4266276 to your computer and use it in GitHub Desktop.
Return JavaScript with translated strings
<script type="text/javascript">
<?php
define('DEFAULT_LANGUAGE', 'en');
$lang = !empty($_REQUEST['lang']) ? $_REQUEST['lang'] : DEFAULT_LANGUAGE;
$translations = get_translations($lang);
if (!empty($translations)) {
foreach ($translations as $key => $value) {
print $key . ' : "' . $value . '"' . "\n";
}
}
function get_translations($lang) {
$result = array(
'lbl_test' => 'Some message',
'lbl_notest' => 'No message',
);
return $result;
}
?>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment