Skip to content

Instantly share code, notes, and snippets.

@DominikStyp
Created December 7, 2016 09:58
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 DominikStyp/02ea17cbb44825313833964dd6e69d9f to your computer and use it in GitHub Desktop.
Save DominikStyp/02ea17cbb44825313833964dd6e69d9f to your computer and use it in GitHub Desktop.
Przykład na modyfikacje funkcji trans()
<?php
function trans($key){
static $translates = [
'months_1' => 'Styczeń',
'months_2' => 'Luty',
'months_3' => 'Marzec',
'months_4' => 'Kwiecień',
'months_5' => 'Maj',
'months_6' => 'Czerwiec',
'months_7' => 'Lipiec',
'months_8' => 'Sierpień',
'months_9' => 'Wrzesień',
'months_10' => 'Październik',
'months_11' => 'Listopad',
'months_12' => 'Grudzień',
'writtenChars' => 'Napisano #chars znaków',
];
return $translates[$key];
}
?>
<script>
var translateJS = {
months: [ "<?=trans('month_1')?>",
"<?=trans('month_2')?>",
"<?=trans('month_3')?>",
"<?=trans('month_4')?>",
"<?=trans('month_5')?>",
"<?=trans('month_6')?>",
"<?=trans('month_7')?>",
"<?=trans('month_8')?>",
"<?=trans('month_9')?>",
"<?=trans('month_10')?>",
"<?=trans('month_11')?>"
"<?=trans('month_12')?>" ],
writtenChars: "<?=trans('writtenChars'?>"
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment