Skip to content

Instantly share code, notes, and snippets.

@gusrub
Created April 26, 2018 03:56
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 gusrub/bbbb87c3469108353a082f8502f865ec to your computer and use it in GitHub Desktop.
Save gusrub/bbbb87c3469108353a082f8502f865ec to your computer and use it in GitHub Desktop.
I18n helper
<?php
namespace Helpers\I18n {
// I18N support information here
$language = 'es_MX.utf8';
putenv("LC_ALL=$language");
putenv("LC_LANG=$language");
setlocale(LC_ALL, $language);
// // Set the text domain as 'messages'
$domain = 'messages';
bindtextdomain($domain, "Locale");
textdomain($domain);
function translate($str, ...$args)
{
return sprintf(_($str), ...$args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment