Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:upper case lang codes #76

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lingua_franca/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def get_full_lang_code(lang=''):
except UnsupportedLanguageError:
warn(InvalidLangWarning)
lang = get_default_loc()
return lang
return lang.lower()


def __get_full_lang_code_deprecation_warning(lang=''):
Expand Down Expand Up @@ -436,6 +436,8 @@ def nice_number(number, lang='', speech=True, denominators=None):
"received this value:\n" + str(run_own_code_on))
# TODO deprecate these kwarg values 6-12 months after v0.3.0 releases

# TODO - deprecate the whole dynamic loading thing instead? this abandonware is hell to maintain....

JarbasAl marked this conversation as resolved.
Show resolved Hide resolved
if run_own_code_on != [None]:
def is_error_type(_type):
if not callable(_type):
Expand Down Expand Up @@ -495,6 +497,7 @@ def _call_localized_function(func, *args, **kwargs):

# Turns out, we aren't passing a lang code at all
lang_code = lang_code or get_default_lang()
lang_code = lang_code.lower() # to allow standardized lang codes with upper case
if not lang_code:
if load_langs_on_demand:
raise ModuleNotFoundError("No language module loaded "
Expand Down
1 change: 1 addition & 0 deletions lingua_franca/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def extract_color_spans(text, lang=''):

@localized_function(run_own_code_on=[FunctionNotLocalizedError])
def yes_or_no(text, lang=""):
lang = get_full_lang_code(lang)
text = normalize(text, lang=lang, remove_articles=True).lower()
return match_yes_or_no(text, lang)

Expand Down
Loading