mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-06-28 11:59:53 +00:00
Merge pull request #814 from DL6ER/new/web_title
Add user-customizable <title>
This commit is contained in:
commit
a63984bc9f
5 changed files with 27 additions and 2 deletions
|
@ -220,7 +220,8 @@ Arguments passed to the process or set via environment variables are split into
|
|||
| --ga-id | Enable Google Analytics on the API client page by providing an ID | `Empty (no tracking)` | LT_GA_ID |
|
||||
| --frontend-language-source | Set frontend default language - source | `auto` | LT_FRONTEND_LANGUAGE_SOURCE |
|
||||
| --frontend-language-target | Set frontend default language - target | `locale` (match site's locale) | LT_FRONTEND_LANGUAGE_TARGET |
|
||||
| --frontend-language | Set frontend web interface language | `(empty)` (auto-detect) | LT_FRONTEND_LANGUAGE |
|
||||
| --frontend-language | Set frontend web interface language | `(empty)` (auto-detect) | LT_FRONTEND_LANGUAGE |
|
||||
| --frontend-title | Set frontend web interface title | `LibreTranslate` | LT_FRONTEND_TITLE |
|
||||
| --frontend-timeout | Set frontend translation timeout | `500` | LT_FRONTEND_TIMEOUT |
|
||||
| --api-keys-db-path | Use a specific path inside the container for the local database. Can be absolute or relative | `db/api_keys.db` | LT_API_KEYS_DB_PATH |
|
||||
| --api-keys-remote | Use this remote endpoint to query for valid API keys instead of using the local database | `Empty (use local db instead)` | LT_API_KEYS_REMOTE |
|
||||
|
|
|
@ -33,6 +33,7 @@ from libretranslate.locales import (
|
|||
gettext_html,
|
||||
lazy_swag,
|
||||
)
|
||||
from libretranslate.default_values import DEFAULT_FRONTEND_TITLE
|
||||
|
||||
from .api_keys import Database, RemoteDatabase
|
||||
from .suggestions import Database as SuggestionsDatabase
|
||||
|
@ -447,6 +448,8 @@ def create_app(args):
|
|||
alternate_locales=get_alternate_locale_links(),
|
||||
under_attack=args.under_attack,
|
||||
hide_api=args.hide_api,
|
||||
frontend_title=args.frontend_title,
|
||||
use_custom_title=args.frontend_title != DEFAULT_FRONTEND_TITLE,
|
||||
))
|
||||
|
||||
if args.require_api_key_secret:
|
||||
|
|
|
@ -2,6 +2,7 @@ import os
|
|||
|
||||
_prefix = 'LT_'
|
||||
|
||||
DEFAULT_FRONTEND_TITLE = 'LibreTranslate'
|
||||
|
||||
def _get_value_str(name, default_value):
|
||||
env_value = os.environ.get(name)
|
||||
|
@ -126,6 +127,11 @@ _default_options_objects = [
|
|||
'default_value': 500,
|
||||
'value_type': 'int'
|
||||
},
|
||||
{
|
||||
'name': 'FRONTEND_TITLE',
|
||||
'default_value': DEFAULT_FRONTEND_TITLE,
|
||||
'value_type': 'str'
|
||||
},
|
||||
{
|
||||
'name': 'API_KEYS',
|
||||
'default_value': False,
|
||||
|
|
|
@ -111,6 +111,13 @@ def get_args():
|
|||
metavar="<language code>",
|
||||
help="Set frontend interface language (%(default)s)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--frontend-title",
|
||||
type=str,
|
||||
default=DEFARGS['FRONTEND_TITLE'],
|
||||
metavar="<title>",
|
||||
help="Set frontend title (%(default)s)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--frontend-timeout",
|
||||
type=int,
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<title>LibreTranslate - {{ _h("Free and Open Source Machine Translation API") }} 🌐</title>
|
||||
<meta name="description" content="{{ _h('Free and Open Source Machine Translation API. Free to download, offline capable and easy to setup. Run your own API server in just a few minutes.') }}">
|
||||
<meta name="keywords" content="{{ _h('translation') }},{{ _h('api') }}">
|
||||
{% else %}
|
||||
<title>{{ frontend_title }}</title>
|
||||
{% endif %}
|
||||
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
|
@ -179,7 +181,13 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<h3 class="header center">{{ _h("Translation API") }}</h3>
|
||||
<h3 class="header center">
|
||||
{% if use_custom_title %}
|
||||
{{ frontend_title }}
|
||||
{% else %}
|
||||
{{ _h("Translation API") }}
|
||||
{% endif %}
|
||||
</h3>
|
||||
<div id="translation-type-btns" class="s12 center" v-if="filesTranslation === true">
|
||||
<button type="button" class="btn btn-switch-type" @click="switchType('text')" :class="{'active': translationType === 'text'}" :disabled="disableInput">
|
||||
<i aria-hidden="true" class="material-icons">title</i>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue