Skip to main content
Version: 1.0

aixplain.enums.language

__author__

Copyright 2023 The aiXplain SDK authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Author: aiXplain team Date: March 22th 2023 Description: Language Enum

LanguageMetadata Objects

@dataclass
class LanguageMetadata()

[view_source]

Metadata container for language information.

This class holds metadata about a language including its identifier, value, label, dialects, and supported scripts.

Attributes:

  • id str - ID of the language.
  • value str - Language code or value.
  • label str - Label for the language.
  • dialects List[Dict[str, str]] - List of dialect specifications.
  • scripts List[Any] - List of supported scripts for the language.

to_dict

def to_dict() -> dict

[view_source]

Convert the language metadata to a dictionary.

Returns:

  • dict - Dictionary representation of the language metadata.

from_dict

@classmethod
def from_dict(cls, data: dict) -> "LanguageMetadata"

[view_source]

Create a LanguageMetadata instance from a dictionary.

Arguments:

  • data dict - Dictionary containing language metadata.

Returns:

  • LanguageMetadata - New instance created from the dictionary data.

load_languages

def load_languages() -> Enum

[view_source]

Load language definitions from the backend or cache.

This function attempts to load language definitions from the cache first. If the cache is invalid or doesn't exist, it fetches the data from the backend API. It creates a dynamic Enum class containing all available languages and their dialects.

Returns:

  • Enum - Dynamically created Language enum class with language codes and dialects.

Raises:

  • Exception - If languages cannot be loaded due to invalid API key or other errors.