Brunwo commited on
Commit
5143ceb
·
1 Parent(s): bf90d9e

changed locale deault

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -7,6 +7,7 @@ from pathlib import Path
7
  from tempfile import NamedTemporaryFile
8
  from typing import List, Literal
9
 
 
10
  import gradio as gr
11
  from loguru import logger
12
  from openai import OpenAI
@@ -29,11 +30,23 @@ from gradio.themes.utils.theme_dropdown import create_theme_dropdown
29
  import litellm
30
  litellm.set_verbose=True
31
 
 
 
 
 
 
 
 
 
 
 
 
32
  # Setup gettext
33
  def setup_translation(lang_code):
34
 
35
- locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
36
  locale_path = os.path.join(os.path.dirname(__file__), 'locales')
 
37
  try:
38
  translation = gettext.translation('messages', localedir=locale_path, languages=[lang_code])
39
  translation.install()
@@ -639,7 +652,10 @@ demo.queue(max_size=20, default_concurrency_limit=32)
639
  if __name__ == "__main__":
640
 
641
  load_dotenv() # This line brings all environment variables from .env into os.environ
642
- demo.launch(share=True)
 
 
 
643
 
644
  # # Create a FastAPI app
645
  # app = FastAPI()
 
7
  from tempfile import NamedTemporaryFile
8
  from typing import List, Literal
9
 
10
+ from flask_cors import CORS
11
  import gradio as gr
12
  from loguru import logger
13
  from openai import OpenAI
 
30
  import litellm
31
  litellm.set_verbose=True
32
 
33
+
34
+ def set_locale(locale_name):
35
+ try:
36
+ # Try to set the desired locale
37
+ locale.setlocale(locale.LC_ALL, locale_name)
38
+ print(f"Locale set to: {locale_name}")
39
+ except locale.Error:
40
+ # Fallback to the default system locale
41
+ locale.setlocale(locale.LC_ALL, '')
42
+ print("Unsupported locale, falling back to default locale")
43
+
44
  # Setup gettext
45
  def setup_translation(lang_code):
46
 
47
+ set_locale('en_US.UTF-8')
48
  locale_path = os.path.join(os.path.dirname(__file__), 'locales')
49
+
50
  try:
51
  translation = gettext.translation('messages', localedir=locale_path, languages=[lang_code])
52
  translation.install()
 
652
  if __name__ == "__main__":
653
 
654
  load_dotenv() # This line brings all environment variables from .env into os.environ
655
+ app, local_url, share_url = demo.launch(share=False)
656
+
657
+ # app.app_context()
658
+ # CORS(app.servers) # This line enables CORS for all routes
659
 
660
  # # Create a FastAPI app
661
  # app = FastAPI()