Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 committed Nov 16, 2023
2 parents bd2e6ae + fbc575d commit 930a8c2
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/axm_helper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

use Axm\Views\View;
use Illuminate\Support\Str;
use Illuminate\Support\Carbon;
Expand Down Expand Up @@ -274,20 +275,17 @@ function randomId($size = 50)
* @param string $key The key representing the message to be translated.
* @return string The translated message, with optional placeholders replaced.
*/
function lang(string $key)
function lang(string $key, array $args = [])
{
// Get the message translation using the provided key.
$message = I18n::gettext($key);
// Get an instance of Lang
$lang = Lang::make();

// Check if multiple parameters are passed.
if (func_num_args() > 1) {
$args = func_get_args();
unset($args[0]);
// Replace placeholders in the message using vsprintf.
$message = vsprintf($message, $args);
if (empty($args)) {
return $lang->trans('file.message');
}

return $message;
// Translate a key
return $lang->trans('file.message', $args);
}
}

Expand Down Expand Up @@ -352,6 +350,17 @@ function baseUrl(string $dir = ''): string
}
}

if (!function_exists('asset')) {

function asset(string $dirFile): string
{
$pathAssets = 'resources/assets/';
$file = baseUrl($pathAssets.$dirFile);

return $file;
}
}

if (!function_exists('go')) {

/**
Expand Down

0 comments on commit 930a8c2

Please sign in to comment.