tonic commited on
Commit
501d3ce
1 Parent(s): 76c7a79

fix error in language code

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -51,8 +51,12 @@ def get_language_code(language_name):
51
  """
52
  Extracts the first two letters of the language code based on the language name.
53
  """
54
- code = df.loc[df['name'] == language_name, 'code'].values[0]
55
- return code[:2]
 
 
 
 
56
 
57
  def translate_text(text, instructions=translatetextinst):
58
  """
 
51
  """
52
  Extracts the first two letters of the language code based on the language name.
53
  """
54
+ try:
55
+ code = df.loc[df['name'].str.lower() == language_name.lower(), 'code'].values[0]
56
+ return code
57
+ except IndexError:
58
+ print(f"Language name '{language_name}' not found.")
59
+ return None
60
 
61
  def translate_text(text, instructions=translatetextinst):
62
  """