Skip to content

Commit

Permalink
Merge pull request #41 from IgniteUI/i18n-toc-groups-main-page
Browse files Browse the repository at this point in the history
feat(*): i18n of toc section and groups of main page
  • Loading branch information
zdrawku authored Oct 25, 2019
2 parents 62859f0 + 664f3fa commit cf86aaf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion components/render-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class RenderComponenet extends RendererComponent {
}

private updateComment(reflection, dataObj) {
if (!reflection.comment || !dataObj[Constants.COMMENT]) {
if (!reflection.comment || (dataObj && !dataObj[Constants.COMMENT])) {
return;
}

Expand Down
31 changes: 20 additions & 11 deletions components/theme-component.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
import * as path from 'path';

import { RendererEvent } from "typedoc/dist/lib/output/events";
import { RendererEvent, PageEvent } from "typedoc/dist/lib/output/events";
import { Component } from 'typedoc/dist/lib/utils';
import { RendererComponent } from 'typedoc/dist/lib/output/components';
import { Constants } from '../utils/constants';
import { GlobalFuncs } from '../utils/global-funcs';
import { HardcodedStrings } from '../utils/template-strings';
import { ReflectionKind } from 'typedoc/dist/lib/models';
import { NavigationItem } from 'typedoc/dist/lib/output/models/NavigationItem';

@Component({ name: 'theme-component' })
export class ThemeComponent extends RendererComponent {
initialize() {
this.listenTo(this.owner, {
[RendererEvent.BEGIN]: this.onRenderBegin
[RendererEvent.BEGIN]: this.onRenderBegin,
[PageEvent.BEGIN]: this.onRenderingBeginPage
});
}

private onRenderBegin(event) {
this.registerHelpers();

this.localizeGroupTitles(event.project.groups);
this.run(event.project.reflections);
}

private onRenderingBeginPage(event: PageEvent) {
const navigationItems: Array<NavigationItem> = event.navigation.children;
navigationItems.forEach((item: NavigationItem) => {
item.title = this.getLocaleValue(item.title);
});
}

private run(reflections) {
const keys = Object.keys(reflections);
keys.forEach(key => {
const reflection = reflections[key];
this.updateTemplateRepresentations(reflection)
this.localizeReflectionDeffinitions(reflection)
})
}

Expand All @@ -35,20 +44,20 @@ export class ThemeComponent extends RendererComponent {
* and Object abbreviations(Class, Interface, Enum).
* @param reflection
*/
private updateTemplateRepresentations(reflection) {
private localizeReflectionDeffinitions(reflection) {
if (reflection.kind === ReflectionKind.Class ||
reflection.kind === ReflectionKind.Enum ||
reflection.kind === ReflectionKind.Interface) {
if (reflection.groups) {
this.replaceGroupsTitle(reflection.groups);
this.localizeGroupTitles(reflection.groups);
}

this.updateReflectionAbbreviation(reflection);
this.localizeReflectionAbbriviation(reflection);
}

if (reflection.parameters && reflection.parameters.length) {
reflection.parameters.forEach(e => {
this.replaceParameterFlags(e);
this.localizeParameterFlags(e);
});
}
}
Expand All @@ -57,21 +66,21 @@ export class ThemeComponent extends RendererComponent {
* Localize Object abbreviatons(Class, Interface, Enum)
* @param reflection
*/
private updateReflectionAbbreviation(reflection) {
private localizeReflectionAbbriviation(reflection) {
reflection.kindString = this.getLocaleValue(reflection.kindString);
}

/**
* Localize template groups like (Accessors, Methods, Properties, etc.)
* @param groups
*/
private replaceGroupsTitle(groups) {
private localizeGroupTitles(groups) {
groups.forEach(element => {
element.title = this.getLocaleValue(element.title);
});
}

private replaceParameterFlags(param) {
private localizeParameterFlags(param) {
if (param.flags && param.flags.length) {
param.flags.forEach((f, idx) => {
param.flags[idx] = this.getLocaleValue(f);
Expand Down

0 comments on commit cf86aaf

Please sign in to comment.