Skip to content

Commit

Permalink
added localization strings (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvgaliev authored and ignatvilesov committed Apr 13, 2018
1 parent 6e78fc4 commit 4673c43
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 18 deletions.
9 changes: 5 additions & 4 deletions capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"displayName": "Force display",
"displayNameKey": "Visual_Force_Display",
"description": "Display all labels anyway",
"descriptionKey": "Visual_Description_Force_Display",
"type": {
"bool": true
}
Expand Down Expand Up @@ -256,13 +257,13 @@
"displayNameKey": "Visual_Cycles",
"properties": {
"drawCycles": {
"displayName": "Dublicate nodes",
"displayNameKey": "Visual_DublicateNodes",
"displayName": "Duplicate nodes",
"displayNameKey": "Visual_DuplicateNodes",
"type": {
"enumeration": [
{
"displayName": "Dublicate",
"displayNameKey": "Visual_Dublicate",
"displayName": "Duplicate",
"displayNameKey": "Visual_Duplicate",
"value": "0"
},
{
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"package": "pbiviz package",
"lint": "node node_modules/tslint/bin/tslint \"+(src|test)/**/*.ts\"",
"pretest": "pbiviz package --resources --no-minify --no-pbiviz --no-plugin",
"test": "karma start"
"test": "karma start",
"cert": "pbiviz --create-cert"
},
"author": {
"name": "Microsoft",
Expand Down Expand Up @@ -56,7 +57,7 @@
"powerbi-models": "1.0.3",
"powerbi-visuals-utils-interactivityutils": "3.1.0",
"powerbi-visuals-utils-svgutils": "^0.2.1",
"powerbi-visuals-utils-testutils": "^0.2.1",
"powerbi-visuals-utils-testutils": "1.2.1",
"powerbi-visuals-utils-tooltiputils": "^0.3.0",
"powerbi-visuals-utils-typeutils": "^0.2.0",
"tslint": "4.0.2",
Expand Down
4 changes: 2 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module powerbi.extensibility.visual {
import DataViewObjectsParser = powerbi.extensibility.utils.dataview.DataViewObjectsParser;

export enum CyclesDrawType {
Dublicate,
Duplicate,
Backward
}

Expand Down Expand Up @@ -67,7 +67,7 @@ module powerbi.extensibility.visual {
}

export class SankeyNodeCycles {
public drawCycles: number = CyclesDrawType.Dublicate;
public drawCycles: number = CyclesDrawType.Duplicate;
public selfLinksWeight: boolean = true;
}

Expand Down
23 changes: 14 additions & 9 deletions src/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ module powerbi.extensibility.visual {
private static MinRangeOfScale = 0;
private static DefaultMaxRangeOfScale = 100;

public static DublicatedNamePostfix: string = "_SK_SELFLINK";
public static DuplicatedNamePostfix: string = "_SK_SELFLINK";

private static DefaultWeightOfLink: number = 1;

Expand Down Expand Up @@ -203,6 +203,7 @@ module powerbi.extensibility.visual {

private colorPalette: IColorPalette;
private visualHost: IVisualHost;
private localizationManager: ILocalizationManager;

private viewport: IViewport;

Expand Down Expand Up @@ -234,6 +235,7 @@ module powerbi.extensibility.visual {

private init(options: VisualConstructorOptions): void {
this.visualHost = options.host;
this.localizationManager = this.visualHost.createLocalizationManager();

this.root = d3.select(options.element)
.append("svg")
Expand Down Expand Up @@ -369,7 +371,7 @@ module powerbi.extensibility.visual {

let cycles: SankeyDiagramCycleDictionary = this.checkCycles(nodes);

if (settings.cyclesLinks.drawCycles === CyclesDrawType.Dublicate) {
if (settings.cyclesLinks.drawCycles === CyclesDrawType.Duplicate) {
links = this.processCyclesForwardLinks(cycles, nodes, links, settings);
}

Expand Down Expand Up @@ -412,7 +414,7 @@ module powerbi.extensibility.visual {
let firstCyclesNode: SankeyDiagramNode = cycles[nodeName][cycles[nodeName].length - 1];
// create a clone of the node and save a link to each other. In selection behavior, selection of clone lead to select original and visa versa
let nodeCopy: SankeyDiagramNode = _.cloneDeep(firstCyclesNode);
nodeCopy.label.name += SankeyDiagram.DublicatedNamePostfix;
nodeCopy.label.name += SankeyDiagram.DuplicatedNamePostfix;
firstCyclesNode.cloneLink = nodeCopy;
nodeCopy.cloneLink = firstCyclesNode;

Expand Down Expand Up @@ -500,7 +502,7 @@ module powerbi.extensibility.visual {
});
}

// remove dublicated links
// remove Duplicated links
private static fixLinksCount(node: SankeyDiagramNode) {
node.links = _.uniq(node.links);
}
Expand Down Expand Up @@ -615,7 +617,7 @@ module powerbi.extensibility.visual {
let categories: any[] = sourceCategories.concat(destinationCategories);

categories.forEach((item: any, index: number) => {
let formattedValue: string = valueFormatterForCategories.format((<string>labelsDictionary[item].toString()).replace(SankeyDiagram.DublicatedNamePostfix, "")),
let formattedValue: string = valueFormatterForCategories.format((<string>labelsDictionary[item].toString()).replace(SankeyDiagram.DuplicatedNamePostfix, "")),
label: SankeyDiagramLabel,
selectableDataPoint: SelectableDataPoint,
textProperties: TextProperties = {
Expand All @@ -627,7 +629,7 @@ module powerbi.extensibility.visual {
label = {
internalName: item,
name: item,
formattedName: valueFormatterForCategories.format((<string>labelsDictionary[item].toString()).replace(SankeyDiagram.DublicatedNamePostfix, "")),
formattedName: valueFormatterForCategories.format((<string>labelsDictionary[item].toString()).replace(SankeyDiagram.DuplicatedNamePostfix, "")),
width: textMeasurementService.measureSvgTextWidth(textProperties),
height: textMeasurementService.estimateSvgTextHeight(textProperties),
color: settings.labels.fill
Expand Down Expand Up @@ -770,10 +772,12 @@ module powerbi.extensibility.visual {
nodes.inputWeight
? nodes.inputWeight
: nodes.outputWeight,
this.localizationManager,
nodes.inputWeight > 0 && nodes.outputWeight > 0 ? `${sourceFieldName}-${destinationFieldName}` : nodes.outputWeight > 0
? sourceFieldName
: destinationFieldName,
valueFieldName);
valueFieldName
);

});

Expand Down Expand Up @@ -889,8 +893,9 @@ module powerbi.extensibility.visual {
valueFormatter: IValueFormatter,
nodeName: string,
nodeWeight: number,
localizationManager: ILocalizationManager,
nodeDisplayName?: string,
valueDisplayName?: string,
valueDisplayName?: string
): VisualTooltipDataItem[] {

let formattedNodeWeigth: string;
Expand All @@ -903,7 +908,7 @@ module powerbi.extensibility.visual {

return [
{
displayName: nodeDisplayName || SankeyDiagram.TooltipDisplayName,
displayName: localizationManager.getDisplayName("Visual_TooltipDisplayName"),
value: nodeName
}, {
displayName: valueDisplayName || SankeyDiagram.RoleNames.values,
Expand Down
9 changes: 8 additions & 1 deletion stringResources/en-US/resources.resjson
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,12 @@
"Visual_SankeySettings": "Sankey settigns",
"Visual_NodePositions": "Node positions",
"Visual_ViewportSize": "Viewport sizes",
"Visual_Display_Units": "Display units"
"Visual_Display_Units": "Display units",
"Visual_Cycles": "Cycles displaying",
"Visual_DuplicateNodes": "Duplicate nodes",
"Visual_Duplicate": "Duplicate",
"Visual_DrawBackwardLink": "Draw backward link",
"Visual_SelflinkWeight": "Ignore weight of self links",
"Visual_TooltipDisplayName": "Name",
"Visual_Description_Force_Display": "Display all labels anyway"
}

0 comments on commit 4673c43

Please sign in to comment.