bryantgillespie / directus-sdk-typegen

MIT License
5 stars 1 forks source link

Translations #2

Open zawoj opened 21 hours ago

zawoj commented 21 hours ago

Hi, thanks for this extenstion! TBH this one is very close to perfect!

I notified a problem with translations, but it could be my problem how I create them in directus models settings. But let me explain the problem.

I have global settings (check the snapshot for more details) which are generated like this:

export interface Globals {
    /** @required */
    id: string;
    /** @description What's is the base url for the site? */
    url?: string | null;
    favicon?: DirectusFile | string | null;
}

export interface GlobalsTranslation {
    /** @required */
    id: number;
    globals_id?: Global | string | null;
    languages_code?: Language | string | null;
    /** @required */
    title: string;
    tagline?: string | null;
    /** @required */
    description: string;
    og_image?: DirectusFile | string | null;
    social_links?: Array<{ service: 'facebook' | 'instagram' | 'linkedin' | 'twitter' | 'vimeo' | 'youtube' | 'github' | 'discord' | 'docker'; url: string }> | null;
    routes?: Array<{ collection: string; route: string }> | null;
    /** @description URL for the build / deploy hook that starts a new build */
    build_hook_url?: string | null;
    street_address?: string | null;
    address_locality?: string | null;
    address_region?: string | null;
    postal_code?: string | null;
    address_country?: string | null;
    email?: string | null;
    phone?: string | null;
}

But ideally will be genereted like this:

export interface Globals {
    /** @required */
    id: string;
    /** @description What's is the base url for the site? */
    url?: string | null;
    favicon?: DirectusFile | string | null;
        translations: GlobalsTranslation[] | null; // WE NEED THAT
}

export interface GlobalsTranslation {
    /** @required */
    id: number;
    globals_id?: Global | string | null;
    languages_code?: Language | string | null;
    /** @required */
    title: string;
    tagline?: string | null;
    /** @required */
    description: string;
    og_image?: DirectusFile | string | null;
    social_links?: Array<{ service: 'facebook' | 'instagram' | 'linkedin' | 'twitter' | 'vimeo' | 'youtube' | 'github' | 'discord' | 'docker'; url: string }> | null;
    routes?: Array<{ collection: string; route: string }> | null;
    /** @description URL for the build / deploy hook that starts a new build */
    build_hook_url?: string | null;
    street_address?: string | null;
    address_locality?: string | null;
    address_region?: string | null;
    postal_code?: string | null;
    address_country?: string | null;
    email?: string | null;
    phone?: string | null;
}

FYI: I am also a member of directus-plus

snapshot.zip