Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module 'vue-gettext/types' has no exported member 'translate'. #116

Open
evgeniyparanyuk-textmagic opened this issue Jul 11, 2020 · 5 comments

Comments

@evgeniyparanyuk-textmagic

dSN4CmR

@evgeniyparanyuk-textmagic
Copy link
Author

I use typescript 3.9.5

@Pavel-Son
Copy link

+1, the same issue. Seems like simple d.ts could fix it

@Thomas-1985
Copy link

+1 here, using typescript 4.7.3

@annyanich
Copy link

I believe that the following code snippet may help those of you who would like to add types for the exported member translate themselves in their own project. In ours, I created a file vue-gettext.d.ts with the following content:

declare module 'vue-gettext' {
    const translate: {
        getTranslation(msgid: any, n?: number, context?: any, defaultPlural?: any, language?: string): any;
        gettext(msgid: any, language?: string): any;
        pgettext(context: any, msgid: any, language?: string): any;
        ngettext(msgid: any, plural: any, n: any, language?: string): any;
        npgettext(context: any, msgid: any, plural: any, n: any, language?: string): any;
        initTranslations(translations: any, config: any): void;
        gettextInterpolate: any;
    }
}

There are a lot of 'any' types in there which should probably be replaced with more specific types. But I hope this is a useful scaffolding to help you or anyone reading this in the future get started.

@wbolster
Copy link

wbolster commented Dec 9, 2024

thanks @annyanich for the inspiration. i've adapted your shims to more comprehensive type definitions, which can be copy-pasted into a file named vue-gettext.d.ts:

import GetTextPlugin from 'vue-gettext';

declare module 'vue-gettext' {
  export default GetTextPlugin;
  const translate: {
    gettext(msgid: string, language?: string): string;
    ngettext(
      msgid: string,
      plural: string,
      n: number,
      language?: string
    ): string;
    npgettext(
      context: string,
      msgid: string,
      plural: string,
      n: number,
      language?: string
    ): string;
    pgettext(context: string, msgid: string, language?: string): string;
    gettextInterpolate(
      msgid: string,
      context: object,
      disableHtmlEscaping?: boolean
    ): string;
  };
  export { translate };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants