
    Ti*                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
  S SKJr  S rS rS r\S	:X  a  \" 5         gg)
    N)
create_app)DEFAULT_ARGUMENTS)
run_simple)DispatcherMiddlewarec                  r	   [         R                  " SS9n U R                  S[        S[        S   S9  U R                  S[
        S[        S	   S9  U R                  S
[        S   [
        SSS9  U R                  S[        S   [
        SSS9  U R                  S[        S   [        SSS9  U R                  S[        S   [
        SSS9  U R                  S[        S   [
        SSS9  U R                  S[        S   [
        SSS9  U R                  S [        S!   [
        SS"S9  U R                  S#[        S$   [
        SS%S9  U R                  S&[        S'   [
        S(S)S9  U R                  S*[        S+   S,S-S.9  U R                  S/[        S0   S,S1S.9  U R                  S2[        [        S3   S4S5S69  U R                  S7[        [        S8   S4S9S69  U R                  S:[        [        S;   S4S<S69  U R                  S=[        [        S>   S?S@S69  U R                  SA[
        [        SB   SCSDS69  U R                  SE[        SF   S,SGS.9  U R                  SH[        SI   [        SJSK9  U R                  SL[        SM   [        SNSK9  U R                  SO[        SP   [        SQSK9  U R                  SR[        [        SS   STSU9  U R                  SV[        SW   S,SXS.9  U R                  SY[        SZ   S,S[S.9  U R                  S\[        S]   S,S^S.9  U R                  S_[        S`   S,SaS.9  U R                  Sb[        [        Sc   SSdS69  U R                  Se[        Sf   S,SgS.9  U R                  Sh[        R                  " SiSj5      [        Sk   SlSmS69  U R                  Sn[        So   [
        SpSqS9  U R                  Sr[        Ss   [
        StSuS9  U R                  Sv[        Sw   S,SxS.9  U R                  Sy[        Sz   S,S{S.9  U R                  S|[        S}   S,S~S.9  U R                  S[        S   S,SS.9  U R                  S[        S   S,SS.9  U R                  S[        S   S,SS.9  U R                  S[        S   [        SSK9  U R                  S[        R                  " SiSj5      [        S   SSS69  U R                  S[        S   [        SSK9  U $ )Nz5LibreTranslate - Free and Open Source Translation API)descriptionz--hostzHostname (%(default)s)HOST)typehelpdefaultz--portzPort (%(default)s)PORTz--char-limit
CHAR_LIMITz<number of characters>z!Set character limit (%(default)s))r   r
   metavarr   z--req-limit	REQ_LIMITz<number>zNSet the default maximum number of requests per minute per client (%(default)s)z--req-limit-storageREQ_LIMIT_STORAGEz<Storage URI>zStorage URI to use for request limit data storage. See https://flask-limiter.readthedocs.io/en/stable/configuration.html. (%(default)s)z--hourly-req-limitHOURLY_REQ_LIMITzgSet the default maximum number of requests per hour per client, in addition to req-limit. (%(default)s)z--hourly-req-limit-decayHOURLY_REQ_LIMIT_DECAYzWhen used in combination with hourly-req-limit, adds additional hourly restrictions that logaritmically decrease for each additional hour. (%(default)s)z--daily-req-limitDAILY_REQ_LIMITzfSet the default maximum number of requests per day per client, in addition to req-limit. (%(default)s)z--req-flood-thresholdREQ_FLOOD_THRESHOLDzlSet the maximum number of request limit offences that a client can exceed before being banned. (%(default)s)z--req-time-costREQ_TIME_COSTzConsiders a time cost (in seconds) for request limiting purposes. If a request takes 10 seconds and this value is set to 5, the request cost is either 2 or the actual request cost (whichever is greater). (%(default)s)z--batch-limitBATCH_LIMITz<number of texts>zISet maximum number of texts to translate in a batch request (%(default)s)z--debugDEBUG
store_truezEnable debug environment)r   actionr   z--sslSSLzWhether to enable SSLz--frontend-language-sourceFRONTEND_LANGUAGE_SOURCEz<language code>z4Set frontend default language - source (%(default)s))r
   r   r   r   z--frontend-language-targetFRONTEND_LANGUAGE_TARGETz4Set frontend default language - target (%(default)s)z--frontend-languageFRONTEND_LANGUAGEz-Set frontend interface language (%(default)s)z--frontend-titleFRONTEND_TITLEz<title>z Set frontend title (%(default)s)z--frontend-timeoutFRONTEND_TIMEOUTz<milliseconds>z.Set frontend translation timeout (%(default)s)z
--api-keysAPI_KEYSz8Enable API keys database for per-user rate limits lookupz--api-keys-db-pathAPI_KEYS_DB_PATHzjUse a specific path inside the container for the local database. Can be absolute or relative (%(default)s))r   r
   r   z--api-keys-remoteAPI_KEYS_REMOTEzXUse this remote endpoint to query for valid API keys instead of using the local databasez--get-api-key-linkGET_API_KEY_LINKz=Show a link in the UI where to direct users to get an API keyz--require-api-key-originREQUIRE_API_KEY_ORIGINzkRequire use of an API key for programmatic access to the API, unless the request origin matches this domain)r
   r   r   z--require-api-key-secretREQUIRE_API_KEY_SECRETziRequire use of an API key for programmatic access to the API, unless the client also sends a secret matchz--require-api-key-fingerprintREQUIRE_API_KEY_FINGERPRINTzjRequire use of an API key for programmatic access to the API, unless the client also matches a fingerprintz
--hide-apiHIDE_APIz4Hide the API request/response fields in the frontendz--under-attackUNDER_ATTACKzMEnable under attack mode. When enabled, requests must be made with an API keyz--shared-storageSHARED_STORAGEzLShared storage URI to use for multi-process data sharing (e.g. via gunicorn)z--secondary	SECONDARYzhMark this instance as a secondary instance to avoid conflicts with the primary node in multi-node setupsz--load-onlysplit,	LOAD_ONLYz <comma-separated language codes>z@Set available languages (ar,de,en,es,fr,ga,hi,it,ja,ko,pt,ru,zh)z--alternatives-limitALTERNATIVES_LIMITz-<maximum number of alternatives translations>zJSet the maximum number of supported alternative translations (%(default)s)z	--threadsTHREADSz<number of threads>z#Set number of threads (%(default)s)z--suggestionsSUGGESTIONSzAllow user suggestionsz--disable-files-translationDISABLE_FILES_TRANSLATIONzDisable files translationz--disable-web-uiDISABLE_WEB_UIzDisable web uiz--update-modelsUPDATE_MODELSz!Update language models at startupz--force-update-modelsFORCE_UPDATE_MODELSz,Install/Reinstall language models at startupz	--metricsMETRICSzCEnable the /metrics endpoint for exporting Prometheus usage metricsz--metrics-auth-tokenMETRICS_AUTH_TOKENzqProtect the /metrics endpoint by allowing only clients that have a valid Authorization Bearer token (%(default)s)z--translation-cacheTRANSLATION_CACHEz#<comma separated API keys or 'all'>zaCache translation output for users with a particular API key (or 'all' to cache all translations)z--url-prefix
URL_PREFIXzBAdd a prefix like /url-prefix to URL: example.com:5000/url-prefix/)argparseArgumentParseradd_argumentstrDEFARGSintoperatormethodcaller)parsers    e/var/www/html/backend/Backoffice_Marketplace/venv/lib/python3.13/site-packages/libretranslate/main.py
get_parserrD      s   $$KF s!976?   s1EwW]_
%(0   $]   +, W   *+v   "01 h   )*u   -.{   ( i   &#X   77+LGa   CZ   $23!C   $23!C   +,!<   ()/   *+ =   
#G	   *+y	   )*g	   *+L	   "01z	   "01x	   '56y	   
#C	   '\	   ()[   $w	   ""7C0$2O   ,-?Y   	"%2   !7Sk   %w7R/S\h(   G,<$=lYi   7?#;LWz   1F)GP\  dR   	"R	   ,- A	   ""7C0+,5p   %Q	   M    c                      [        5       n U R                  5       nUR                  (       a4  UR                  R                  S5      (       d  SUR                  -   Ul        U$ )N/)rD   
parse_args
url_prefix
startswith)rB   argss     rC   get_argsrL      sG    \FDt99#>>/KrE   c            	        ^ [        5       mTR                  (       a(  U4S jn [        U TR                  [        T5      05      nO[        [        T5      5      nS[        R
                  ;   a  U$ TR                  (       a  TR                  S:X  a  STl        TR                  (       a"  [        TR                  TR                  U5        g SSK
Jn  TR                  (       a  SOSn[        S	U S
TR                   STR                   TR                   35        U" UTR                  TR                  UTR                  S9  g )Nc              3   D   >#    U" SSSTR                   4/5        Sv   g 7f)Nz301 REDIRECT)zContent-Typez
text/plainLocations   Redirect...)rI   )environstart_responserK   s     rC   redirectmain.<locals>.redirect
  s(     >,JZY]YhYhLi+jk  s    z--wsgi*z::r   )servehttpshttpzRunning on z://:)hostport
url_schemethreads)rL   rI   r   r   sysargvdebugrY   r   rZ   waitressrU   sslprintr\   )rR   apprU   r[   rK   s       @rC   mainrd     s    :D	! #8OOZ-.
  #:d#34388
::$))s*DI::tyy$))S1&$(HH&JK
|3tyyk499+dooEVWXYYYY%rE   __main__)r:   r@   r]   oslibretranslate.appr   libretranslate.default_valuesr   r>   werkzeug.servingr   werkzeug.middleware.dispatcherr   rD   rL   rd   __name__ rE   rC   <module>rm      sC      
 	 ) F ' ?qf#L zF rE   