Skip to content

Commit

Permalink
Update log messages to use translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Feb 11, 2024
1 parent a345741 commit 61a24a0
Show file tree
Hide file tree
Showing 43 changed files with 516 additions and 277 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"mochaExplorer.configFile": ".config/mocha.test-explorer.json",
"cSpell.words": [
"cname",
"Combinatorially",
"deserializers",
"githubprivate",
"linkcode",
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Beta

## Breaking Changes

- Removed deprecated `navigation.fullTree` option.

# Unreleased

## Features
Expand Down
19 changes: 12 additions & 7 deletions src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ import { findTsConfigFile } from "./utils/tsconfig";
import { deriveRootDir, glob, readFile } from "./utils/fs";
import { resetReflectionID } from "./models/reflections/abstract";
import { addInferredDeclarationMapPaths } from "./models/reflections/ReflectionSymbolId";
import { Internationalization } from "./internationalization/internationalization";
import {
Internationalization,
TranslatedString,
} from "./internationalization/internationalization";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageInfo = require("../../package.json") as {
Expand Down Expand Up @@ -175,6 +178,7 @@ export class Application extends ChildableComponent<

this.converter = this.addComponent<Converter>("converter", Converter);
this.renderer = this.addComponent<Renderer>("renderer", Renderer);
this.logger.i18n = this.i18n;
}

/**
Expand Down Expand Up @@ -235,19 +239,20 @@ export class Application extends ChildableComponent<
}
this.trigger(ApplicationEvents.BOOTSTRAP_END, this);

// GERRIT: Add locales to i18n here.
if (!this.internationalization.hasTranslations(this.lang)) {
// Not internationalized as by definition we don't know what to include here.
this.logger.warn(
`Options specified "${this.lang}" as the language to use, but TypeDoc does not support it.`,
`Options specified "${this.lang}" as the language to use, but TypeDoc does not support it.` as TranslatedString,
);
this.logger.info(
"The supported languages are:\n\t" +
("The supported languages are:\n\t" +
this.internationalization
.getSupportedLanguages()
.join("\n\t"),
.join("\n\t")) as TranslatedString,
);
this.logger.info(
"You can define/override local locales with the `locales` option, or contribute them to TypeDoc!",
"You can define/override local locales with the `locales` option, or contribute them to TypeDoc!" as TranslatedString,
);
}
}
Expand All @@ -259,7 +264,7 @@ export class Application extends ChildableComponent<
} catch (error) {
ok(error instanceof Error);
if (reportErrors) {
this.logger.error(error.message);
this.logger.error(error.message as TranslatedString); // GERRIT review
}
}
}
Expand Down Expand Up @@ -433,7 +438,7 @@ export class Application extends ChildableComponent<
ts.flattenDiagnosticMessageText(
status.messageText,
newLine,
),
) as TranslatedString,
);
},
);
Expand Down
11 changes: 7 additions & 4 deletions src/lib/converter/comments/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ export function discoverComment(
return discovered[0];
default: {
logger.warn(
`${symbol.name} has multiple declarations with a comment. An arbitrary comment will be used.`,
logger.i18n.symbol_0_has_multiple_declarations_with_comment(
symbol.name,
),
);
const locations = discovered.map(({ file, ranges: [{ pos }] }) => {
const path = nicePath(file.fileName);
Expand All @@ -210,9 +212,10 @@ export function discoverComment(
return `${path}:${line}`;
});
logger.info(
`The comments for ${
symbol.name
} are declared at:\n\t${locations.join("\n\t")}`,
logger.i18n.comments_for_0_are_declared_at_1(
symbol.name,
locations.join("\n\t"),
),
);
return discovered[0];
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/converter/comments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export function getJsDocComment(
// we'd have to search for any @template with a name starting with the first type parameter's name
// which feels horribly hacky.
logger.warn(
`TypeDoc does not support multiple type parameters defined in a single @template tag with a comment.`,
logger.i18n.multiple_type_parameters_on_template_tag_unsupported(),
declaration,
);
return;
Expand All @@ -301,7 +301,7 @@ export function getJsDocComment(

if (!tag) {
logger.error(
`Failed to find JSDoc tag for ${name} after parsing comment, please file a bug report.`,
logger.i18n.failed_to_find_jsdoc_tag_for_name_0(name),
declaration,
);
} else {
Expand Down
Loading

0 comments on commit 61a24a0

Please sign in to comment.