diff --git a/Tekst-API/openapi.json b/Tekst-API/openapi.json index ea8cfadc..183cdc40 100644 --- a/Tekst-API/openapi.json +++ b/Tekst-API/openapi.json @@ -9968,54 +9968,22 @@ "sourceLanguage": { "anyOf": [ { - "$ref": "#/components/schemas/DeepLSourceLanguage" + "type": "null" }, { - "type": "null" + "type": "string", + "maxLength": 16, + "minLength": 1 } ], - "description": "Source language" + "title": "Sourcelanguage", + "description": "DeepL source language code" } }, "type": "object", "title": "DeepLLinksConfig", "description": "Resource configuration model for DeepL translation links.\nThe corresponding field MUST be named `deepl_links`!" }, - "DeepLSourceLanguage": { - "type": "string", - "enum": [ - "ar", - "bg", - "cs", - "da", - "de", - "el", - "en", - "es", - "et", - "fi", - "fr", - "hu", - "id", - "it", - "ja", - "ko", - "lt", - "lv", - "nb", - "nl", - "pl", - "pt", - "ro", - "ru", - "sk", - "sl", - "sv", - "tr", - "uk", - "zh" - ] - }, "DeleteLocationResult": { "properties": { "contents": { diff --git a/Tekst-API/tekst/resources/plain_text.py b/Tekst-API/tekst/resources/plain_text.py index a0e44ab4..708a5889 100644 --- a/Tekst-API/tekst/resources/plain_text.py +++ b/Tekst-API/tekst/resources/plain_text.py @@ -3,7 +3,7 @@ from pathlib import Path from typing import Annotated, Any, Literal -from pydantic import Field +from pydantic import AfterValidator, Field from tekst.models.common import ModelBase from tekst.models.content import ContentBase @@ -19,6 +19,7 @@ from tekst.resources import ResourceSearchQuery, ResourceTypeABC from tekst.types import ( ConStr, + ConStrOrNone, ContentCssProperties, SchemaOptionalNullable, SearchReplacements, @@ -186,40 +187,6 @@ class LineLabellingConfig(ModelBase): ] = "numbersOneBased" -type DeepLSourceLanguage = Literal[ - "ar", - "bg", - "cs", - "da", - "de", - "el", - "en", - "es", - "et", - "fi", - "fr", - "hu", - "id", - "it", - "ja", - "ko", - "lt", - "lv", - "nb", - "nl", - "pl", - "pt", - "ro", - "ru", - "sk", - "sl", - "sv", - "tr", - "uk", - "zh", -] - - class DeepLLinksConfig(ModelBase): """ Resource configuration model for DeepL translation links. @@ -233,10 +200,14 @@ class DeepLLinksConfig(ModelBase): ), ] = False source_language: Annotated[ - DeepLSourceLanguage | None, + ConStrOrNone( + max_length=16, + cleanup="oneline", + ), Field( - description="Source language", + description="DeepL source language code", ), + AfterValidator(lambda x: x.lower() if x else None), ] = None diff --git a/Tekst-Web/src/api/index.ts b/Tekst-Web/src/api/index.ts index aef77bdd..9b4ffcd9 100644 --- a/Tekst-Web/src/api/index.ts +++ b/Tekst-Web/src/api/index.ts @@ -162,72 +162,244 @@ export const resourceTypes = [ ]; export const deeplSourceLanguages = [ + 'ace', + 'af', + 'an', 'ar', + 'as', + 'ay', + 'az', + 'ba', + 'be', 'bg', + 'bho', + 'bn', + 'br', + 'bs', + 'ca', + 'ceb', + 'ckb', 'cs', + 'cy', 'da', 'de', 'el', 'en', + 'eo', 'es', 'et', + 'eu', + 'fa', 'fi', 'fr', + 'ga', + 'gl', + 'gn', + 'gom', + 'gu', + 'ha', + 'he', + 'hi', + 'hr', + 'ht', 'hu', + 'hy', 'id', + 'ig', + 'is', 'it', 'ja', + 'jv', + 'ka', + 'kk', + 'kmr', 'ko', + 'ky', + 'la', + 'lb', + 'lmo', + 'ln', 'lt', 'lv', + 'mai', + 'mg', + 'mi', + 'mk', + 'ml', + 'mn', + 'mr', + 'ms', + 'mt', + 'my', 'nb', + 'ne', 'nl', + 'oc', + 'om', + 'pa', + 'pag', + 'pam', 'pl', + 'prs', + 'ps', 'pt', + 'qu', 'ro', 'ru', + 'sa', + 'scn', 'sk', 'sl', + 'sq', + 'sr', + 'st', + 'su', 'sv', + 'sw', + 'ta', + 'te', + 'tg', + 'th', + 'tk', + 'tl', + 'tn', 'tr', + 'ts', + 'tt', 'uk', + 'ur', + 'uz', + 'vi', + 'wo', + 'xh', + 'yi', + 'yue', 'zh', + 'zu', ]; export const deeplTargetLanguages = [ + 'ace', + 'af', + 'an', 'ar', + 'as', + 'ay', + 'az', + 'ba', + 'be', 'bg', + 'bho', + 'bn', + 'br', + 'bs', + 'ca', + 'ceb', + 'ckb', 'cs', + 'cy', 'da', 'de', 'el', + 'en', 'en-gb', 'en-us', + 'eo', 'es', + 'es-419', 'et', + 'eu', + 'fa', 'fi', 'fr', + 'ga', + 'gl', + 'gn', + 'gom', + 'gu', + 'ha', + 'he', + 'hi', + 'hr', + 'ht', 'hu', + 'hy', 'id', + 'ig', + 'is', 'it', 'ja', + 'jv', + 'ka', + 'kk', + 'kmr', 'ko', + 'ky', + 'la', + 'lb', + 'lmo', + 'ln', 'lt', 'lv', + 'mai', + 'mg', + 'mi', + 'mk', + 'ml', + 'mn', + 'mr', + 'ms', + 'mt', + 'my', 'nb', + 'ne', 'nl', + 'oc', + 'om', + 'pa', + 'pag', + 'pam', 'pl', + 'prs', + 'ps', + 'pt', 'pt-br', 'pt-pt', + 'qu', 'ro', 'ru', + 'sa', + 'scn', 'sk', 'sl', + 'sq', + 'sr', + 'st', + 'su', 'sv', + 'sw', + 'ta', + 'te', + 'tg', + 'th', + 'tk', + 'tl', + 'tn', 'tr', + 'ts', + 'tt', 'uk', + 'ur', + 'uz', + 'vi', + 'wo', + 'xh', + 'yi', + 'yue', + 'zh', 'zh-hans', 'zh-hant', + 'zu', ]; // export components types for use throughout codebase diff --git a/Tekst-Web/src/api/schema.d.ts b/Tekst-Web/src/api/schema.d.ts index c66aebc5..b3c3d59c 100644 --- a/Tekst-Web/src/api/schema.d.ts +++ b/Tekst-Web/src/api/schema.d.ts @@ -2536,41 +2536,12 @@ export interface components { * @default false */ enabled: boolean; - /** @description Source language */ - sourceLanguage?: components['schemas']['DeepLSourceLanguage'] | null; + /** + * Sourcelanguage + * @description DeepL source language code + */ + sourceLanguage?: null | string; }; - /** @enum {string} */ - DeepLSourceLanguage: - | 'ar' - | 'bg' - | 'cs' - | 'da' - | 'de' - | 'el' - | 'en' - | 'es' - | 'et' - | 'fi' - | 'fr' - | 'hu' - | 'id' - | 'it' - | 'ja' - | 'ko' - | 'lt' - | 'lv' - | 'nb' - | 'nl' - | 'pl' - | 'pt' - | 'ro' - | 'ru' - | 'sk' - | 'sl' - | 'sv' - | 'tr' - | 'uk' - | 'zh'; /** DeleteLocationResult */ DeleteLocationResult: { /** Contents */