Skip to content

Commit

Permalink
Soften the language tag constraint
Browse files Browse the repository at this point in the history
remove constraint, that if the second part of lang tag exists, it must be a region

See #157
  • Loading branch information
zrgt authored and s-heppner committed Nov 16, 2023
1 parent 03c1579 commit f6074ee
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions basyx/aas/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,10 @@ def __init__(self, dict_: Dict[str, str]):
@classmethod
def _check_language_tag_constraints(cls, ltag: str):
split = ltag.split("-", 1)
if len(split[0]) != 2 or not split[0].isalpha() or not split[0].islower():
raise ValueError(f"The language code '{split[0]}' of the language tag '{ltag}' doesn't consist of exactly "
"two lower-case letters!")
if len(split) > 1 and (len(split[1]) != 2 or not split[1].isalpha() or not split[1].isupper()):
raise ValueError(f"The extension '{split[1]}' of the language tag '{ltag}' doesn't consist of exactly "
"two upper-case letters!")
lang_code = split[0]
if len(lang_code) != 2 or not lang_code.isalpha() or not lang_code.islower():
raise ValueError(f"The language code of the language tag must consist of exactly two lower-case letters! "
f"Given language tag and language code: '{ltag}', '{lang_code}'")

def __getitem__(self, item: str) -> str:
return self._dict[item]
Expand Down

0 comments on commit f6074ee

Please sign in to comment.