Remove Config dependency on LocaleManager

This commit is contained in:
Pierre Rudloff 2020-10-21 22:38:09 +02:00
parent 5c75dc2bb0
commit 5b0ee7651b
3 changed files with 32 additions and 32 deletions

View File

@ -124,7 +124,11 @@ class Config
* *
* @var string[] * @var string[]
*/ */
public $genericFormats = []; public $genericFormats = [
'best/bestvideo' => 'Best',
'bestvideo+bestaudio' => 'Remux best video with best audio',
'worst/worstvideo' => 'Worst',
];
/** /**
* Enable debug mode. * Enable debug mode.
@ -158,16 +162,6 @@ class Config
$this->applyOptions($options); $this->applyOptions($options);
$this->getEnv(); $this->getEnv();
$this->validateOptions(); $this->validateOptions();
$localeManager = new LocaleManager();
if (empty($this->genericFormats)) {
// We don't put this in the class definition so it can be detected by xgettext.
$this->genericFormats = [
'best/bestvideo' => $localeManager->t('Best'),
'bestvideo+bestaudio' => $localeManager->t('Remux best video with best audio'),
'worst/worstvideo' => $localeManager->t('Worst'),
];
}
foreach ($this->genericFormats as $format => $name) { foreach ($this->genericFormats as $format => $name) {
if (strpos($format, '+') !== false) { if (strpos($format, '+') !== false) {

View File

@ -45,43 +45,55 @@ msgstr ""
msgid "Generic formats" msgid "Generic formats"
msgstr "" msgstr ""
#: templates/info.tpl:35
msgid "Best"
msgstr ""
#: templates/info.tpl:36 #: templates/info.tpl:36
msgid "Remux best video with best audio"
msgstr ""
#: templates/info.tpl:37
msgid "Worst"
msgstr ""
#: templates/info.tpl:42
msgid "Detailed formats" msgid "Detailed formats"
msgstr "" msgstr ""
#: templates/info.tpl:80 #: templates/info.tpl:86
msgid "Stream the video through the server" msgid "Stream the video through the server"
msgstr "" msgstr ""
#: templates/info.tpl:86 #: templates/info.tpl:92
msgid "Convert into a custom format:" msgid "Convert into a custom format:"
msgstr "" msgstr ""
#: templates/info.tpl:87 #: templates/info.tpl:93
msgid "Custom format" msgid "Custom format"
msgstr "" msgstr ""
#: templates/info.tpl:87 #: templates/info.tpl:93
msgid "Format to convert to" msgid "Format to convert to"
msgstr "" msgstr ""
#: templates/info.tpl:92 #: templates/info.tpl:98
msgid "with" msgid "with"
msgstr "" msgstr ""
#: templates/info.tpl:93 #: templates/info.tpl:99
msgid "Bit rate" msgid "Bit rate"
msgstr "" msgstr ""
#: templates/info.tpl:94 #: templates/info.tpl:100
msgid "Custom bitrate" msgid "Custom bitrate"
msgstr "" msgstr ""
#: templates/info.tpl:97 #: templates/info.tpl:103
msgid "kbit/s audio" msgid "kbit/s audio"
msgstr "" msgstr ""
#: templates/info.tpl:101 templates/playlist.tpl:38 templates/password.tpl:11 #: templates/info.tpl:107 templates/playlist.tpl:38 templates/password.tpl:11
#: templates/index.tpl:19 #: templates/index.tpl:19
msgid "Download" msgid "Download"
msgstr "" msgstr ""
@ -142,18 +154,6 @@ msgstr ""
msgid "Bookmarklet" msgid "Bookmarklet"
msgstr "" msgstr ""
#: classes/Config.php:166
msgid "Best"
msgstr ""
#: classes/Config.php:167
msgid "Remux best video with best audio"
msgstr ""
#: classes/Config.php:168
msgid "Worst"
msgstr ""
#: classes/Controller/DownloadController.php:64 #: classes/Controller/DownloadController.php:64
#: classes/Controller/FrontController.php:166 #: classes/Controller/FrontController.php:166
msgid "Wrong password" msgid "Wrong password"

View File

@ -30,6 +30,12 @@
<select name="format" id="format" class="formats monospace"> <select name="format" id="format" class="formats monospace">
<optgroup label="{t}Generic formats{/t}"> <optgroup label="{t}Generic formats{/t}">
{foreach $config->genericFormats as $format => $name} {foreach $config->genericFormats as $format => $name}
{*
To make the default generic formats translatable:
{t}Best{/t}
{t}Remux best video with best audio{/t}
{t}Worst{/t}
*}
<option value="{$format}">{t}{$name}{/t}</option> <option value="{$format}">{t}{$name}{/t}</option>
{/foreach} {/foreach}
</optgroup> </optgroup>