Translation

Follow i18n for your applications - dynamically.

Table name: languages

Description: Storing translated texts

The translation key must be unique

Model

use SaasReady\Models\Translation;

Response Entity

type LanguageCode = 'en' | 'vi' | ...;

type Translation = {
    uuid: string;
    key: string;
    label: string;
    translations: Record<LanguageCode, string>; // {en: 'seth', vi: 'phat',...}
    created_at: string;
    updated_at: string;
}

Endpoints

[GET] saas/translations

Get a list of Translations

Request payload:

{
    limit: int; // required
    page: int; // required
    search?: string; // search by keyword
}

Response payload:

{
    data: Translation[],
}

[GET] saas/translations/{languageUuid}

Get single Translation

Response payload:

{
    data: Translation,
}

[POST] saas/translations

Create a new Translation

Request payload:

{
    key: string;
    label: string;
    translations: Record<LanguageCode, string>; // {en: 'seth', vi: 'phat',...}
}

Response payload:

{
    uuid: string,
}

[PUT] saas/translations/{translationUuid}

Update an existing Translation

Request payload:

{
    key: string;
    label: string;
    translations: Record<LanguageCode, string>; // {en: 'seth', vi: 'phat',...}
}

Response payload:

{
    uuid: string,
}

[DELETE] saas/translations/{translationUuid}

Delete an existing Translation (soft)

Response payload:

{}

Use Dynamic Translations

Visit Service/Dynamic Translations for more information.

Last updated