Add support for variables in translation (#250)
This commit is contained in:
parent
6fb1cbaa6c
commit
850fc80622
8 changed files with 145 additions and 101 deletions
|
@ -140,7 +140,11 @@ class LocaleManager
|
|||
*/
|
||||
public function smartyTranslate(array $params, $text)
|
||||
{
|
||||
return $this->t($text);
|
||||
if (isset($params['params'])) {
|
||||
return $this->t($text, $params['params']);
|
||||
} else {
|
||||
return $this->t($text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,9 +154,9 @@ class LocaleManager
|
|||
*
|
||||
* @return string Translated string
|
||||
*/
|
||||
public function t($string)
|
||||
public function t($string, array $params = [])
|
||||
{
|
||||
return $this->translator->trans($string);
|
||||
return $this->translator->trans($string, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -358,8 +358,9 @@ class Video
|
|||
if (!$this->checkCommand([$this->config->avconv, '-version'])) {
|
||||
throw new Exception(
|
||||
$this->localeManager->t(
|
||||
'Can\'t find avconv or ffmpeg at '
|
||||
) . $this->config->avconv . '.'
|
||||
"Can't find avconv or ffmpeg at @path.",
|
||||
['@path' => $this->config->avconv]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -373,14 +374,14 @@ class Video
|
|||
|
||||
if (!empty($from)) {
|
||||
if (!preg_match($durationRegex, $from)) {
|
||||
throw new Exception($this->localeManager->t('Invalid start time: ') . $from . '.');
|
||||
throw new Exception($this->localeManager->t('Invalid start time: @from.', ['@from' => $from]));
|
||||
}
|
||||
$afterArguments[] = '-ss';
|
||||
$afterArguments[] = $from;
|
||||
}
|
||||
if (!empty($to)) {
|
||||
if (!preg_match($durationRegex, $to)) {
|
||||
throw new Exception($this->localeManager->t('Invalid end time: ') . $to . '.');
|
||||
throw new Exception($this->localeManager->t('Invalid end time: @to.', ['@to' => $to]));
|
||||
}
|
||||
$afterArguments[] = '-to';
|
||||
$afterArguments[] = $to;
|
||||
|
@ -461,8 +462,9 @@ class Video
|
|||
if (!$this->checkCommand([$this->config->avconv, '-version'])) {
|
||||
throw new Exception(
|
||||
$this->localeManager->t(
|
||||
'Can\'t find avconv or ffmpeg at '
|
||||
) . $this->config->avconv . '.'
|
||||
"Can't find avconv or ffmpeg at @path.",
|
||||
['@path' => $this->config->avconv]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue