common.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. export declare enum MessageFormat {
  2. file = "file",
  3. bundle = "bundle",
  4. both = "both"
  5. }
  6. export declare enum BundleFormat {
  7. standalone = "standalone",
  8. languagePack = "languagePack"
  9. }
  10. export interface Options {
  11. locale?: string;
  12. cacheLanguageResolution?: boolean;
  13. messageFormat?: MessageFormat;
  14. bundleFormat?: BundleFormat;
  15. }
  16. export interface LocalizeInfo {
  17. key: string;
  18. comment: string[];
  19. }
  20. export interface LocalizeFunc {
  21. (info: LocalizeInfo, message: string, ...args: (string | number | boolean | undefined | null)[]): string;
  22. (key: string, message: string, ...args: (string | number | boolean | undefined | null)[]): string;
  23. }
  24. export interface LoadFunc {
  25. (file?: string): LocalizeFunc;
  26. }
  27. export declare type SingleFileJsonFormat = string[] | {
  28. messages: string[];
  29. keys: string[];
  30. };
  31. export interface NlsBundle {
  32. [key: string]: string[];
  33. }
  34. export declare type KeyInfo = string | LocalizeInfo;
  35. export interface MetaDataEntry {
  36. messages: string[];
  37. keys: KeyInfo[];
  38. }
  39. export interface MetadataHeader {
  40. id: string;
  41. type: string;
  42. hash: string;
  43. outDir: string;
  44. }
  45. export interface MetaDataFile {
  46. [key: string]: MetaDataEntry;
  47. }
  48. export interface TranslationConfig {
  49. [extension: string]: string;
  50. }
  51. export interface I18nBundle {
  52. version: string;
  53. contents: {
  54. [module: string]: {
  55. [messageKey: string]: string;
  56. };
  57. };
  58. }
  59. export interface LanguageBundle {
  60. header: MetadataHeader;
  61. nlsBundle: NlsBundle;
  62. }
  63. export declare function isDefined(value: any): boolean;
  64. export declare let isPseudo: boolean;
  65. export declare function setPseudo(pseudo: boolean): void;
  66. export declare function format(message: string, args: any[]): string;
  67. export declare function localize(_key: string | LocalizeInfo, message: string, ...args: any[]): string;
  68. export declare function loadMessageBundle(file?: string): LocalizeFunc;
  69. export declare function config(opts?: Options): LoadFunc;
  70. //# sourceMappingURL=common.d.ts.map