-
Notifications
You must be signed in to change notification settings - Fork 709
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
Internationalization support #2475
Comments
No plans to do this today, #2332 is what I'd recommend at this point |
Thanks for reply, I'll think of some implementation options. Until then, I will post it in this issue. |
Ah, you meant for pieces of the site itself! I thought you were referring to including multiple languages in comments for the source code. I'm certainly open to including options for localization in TypeDoc, but have concerns with the implementation method you went with:
With all this in mind, the design I'm thinking of is: // interface with all translatable strings so that:
// 1. TypeDoc's schema generator for JSON options can provide reasonably good autocomplete for builtin strings.
// 2. Translation `t` calls can be properly type checked.
// 3. Plugins which add additional translated strings can use declaration merging to add new keys to this interface.
interface TranslatableStrings {
settings: string;
content: string;
}
// New member added to the Application class
// Defined here for easy access on plugins, and because it will be used in multiple phases of TypeDoc's run
class Application {
i18n: I18N;
}
class I18N {
setActiveLanguage(lang: string): void; // Called by Application.bootstrap after options have been read.
translate(key: keyof TranslatableStrings): string;
// may be called by plugins
// will be called by Application.bootstrap to merge in any translations added by user configuration
addTranslations(lang: string, translations: Partial<TranslatableStrings>, override = false): void;
private translations: Record<string, Record<string, string>>;
}
// t method should be on context, not PageEvent
class DefaultThemeRenderContext {
t(key: keyof TranslatableStrings): string;
}
// Users should be able to specify translations with:
// typedoc.json:
{
"locales": {
"default" { // or a language identifier like zh
"settings": "Settings"
}
}
}
// If someone wanted to use json files
// typedoc.js
export default {
locales: {
zh: JSON.parse(readFileSync("./locales/zh.json"))
}
} I'd like to unify the |
You do think better! Do you have a schedule for this feature? What can I do to help? |
If you consider a website like crowdin to provide translating contribution. You can create a blank translation project first. And then I can start picking out some pieces that need to be translated. |
I try not to give dates for features, as that tends to be a recipe for disappointment as I don't always have time to work on typedoc, or get excited about other projects and abandon it for a few weeks. That said, this is a fairly straightforward update... going to spend an hour or two looking at it today, so who knows. Could you help me understand why I should use something like crowdin rather than just a folder of localizations in this repo? I'm having difficulty getting past their marketing to the why |
These words don't taste too good 6 hours in. There's an i18n branch on the this repo with my current progress.
|
Initial pass through all of TypeDoc with adding support for localized strings is done! the i18n branch has the current state of everything. There are ~250 strings that can be customized, visible in translatable.ts. It's also worth pointing at internationalization.ts which discusses which strings I considered translatable, vs which were left directly as English in the source. The internal-docs/internationalization.md page discusses adding translations to TypeDoc. Remaining work:
|
@shlomiassaf it looks like you own the |
Fixed with TypeDoc 0.26, which is releasing 2024/06/21 |
Search terms
Question
The project currently only provides English. Are there any plans to provide other languages? Maybe we can use i18n to achieve that.
The text was updated successfully, but these errors were encountered: