-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat(i18n): new locale interface, and translation configs #1710
Changes from 1 commit
fbbfde3
b54bc7a
4894219
1701c4e
568da6a
b8813a6
d7ef3df
0ca33ac
40b9032
4fae08f
57cf915
04bc907
f6259bb
2db59ad
e799a2a
2d8273d
72459c4
ab1a29c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,14 +1,9 @@ | ||||||
import { select } from 'd3' | ||||||
import { flipDomainAndRangeBasedOnOrientation, generateSVGPathString } from '@/tools' | ||||||
import { flipDomainAndRangeBasedOnOrientation, generateSVGPathString, getProperty } from '@/tools' | ||||||
import { boxplot as boxplotConfigs } from '@/configuration' | ||||||
import { BoxplotChartModel } from '@/model/boxplot' | ||||||
import { Component } from '@/components/component' | ||||||
import { | ||||||
CartesianOrientations, | ||||||
ColorClassNameTypes, | ||||||
Events, | ||||||
RenderTypes | ||||||
} from '@/interfaces/enums' | ||||||
import { CartesianOrientations, ColorClassNameTypes, Events, RenderTypes } from '@/interfaces/enums' | ||||||
import { Roles } from '@/interfaces/a11y' | ||||||
|
||||||
export class Boxplot extends Component { | ||||||
|
@@ -339,7 +334,9 @@ export class Boxplot extends Component { | |||||
hoveredElement, | ||||||
items: [ | ||||||
{ | ||||||
label: options.tooltip.groupLabel, | ||||||
label: | ||||||
getProperty(options, 'locale', 'translations', 'group') || | ||||||
getProperty(options, 'tooltip', 'groupLabel'), | ||||||
value: datum[groupMapsTo], | ||||||
class: self.model.getColorClassName({ | ||||||
classNameTypes: [ColorClassNameTypes.TOOLTIP] | ||||||
|
@@ -447,7 +444,9 @@ export class Boxplot extends Component { | |||||
hoveredElement, | ||||||
items: [ | ||||||
{ | ||||||
label: options.tooltip.groupLabel, | ||||||
label: | ||||||
getProperty(options, 'locale', 'translations', 'group') || | ||||||
getProperty(options, 'tooltip', 'groupLabel'), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
value: datum[groupMapsTo], | ||||||
class: self.model.getColorClassName({ | ||||||
classNameTypes: [ColorClassNameTypes.TOOLTIP] | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||||
import { extent, scaleLinear, select } from 'd3' | ||||||
import cloud from 'd3-cloud' | ||||||
import { debounce } from 'lodash-es' | ||||||
import { debounce, get } from 'lodash-es' | ||||||
import { Component } from '@/components/component' | ||||||
import { DOMUtils } from '@/services/essentials/dom-utils' | ||||||
import { Events, ColorClassNameTypes, RenderTypes } from '@/interfaces/enums' | ||||||
|
@@ -217,7 +217,8 @@ export class WordCloud extends Component { | |||||
value: datum.value | ||||||
}, | ||||||
{ | ||||||
label: options.tooltip.groupLabel, | ||||||
label: | ||||||
get(options, 'locale.translations.group') || get(options, 'tooltip.groupLabel'), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
value: datum[groupMapsTo], | ||||||
class: self.model.getColorClassName({ | ||||||
classNameTypes: [ColorClassNameTypes.TOOLTIP], | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ import { | |
StackedBarOptions, | ||
ToolbarOptions, | ||
ZoomBarsOptions, | ||
Locale | ||
} from '@/interfaces/components' | ||
|
||
/* | ||
|
@@ -70,6 +71,23 @@ const standardTruncationOptions = { | |
numCharacter: 14 | ||
} | ||
|
||
/** | ||
* Locale options | ||
*/ | ||
const locale: Locale = { | ||
code: navigator.language, // read from browser's navigator.language | ||
number: value => value.toLocaleString(navigator.language), // based on code property if specified | ||
date: value => value.toLocaleDateString(navigator.language), // based on code property if specified | ||
translations: { | ||
group: 'Group', | ||
total: 'Total', | ||
toolbarTabularModalTitle: 'Tabular representation', | ||
toolbarExportAsCSV: 'Export to CSV', | ||
toolbarExportAsJPG: 'Export to JPG', | ||
toolbarExportAsPNG: 'Export to PNG' | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RiyaJethwa pls make this object a bit more organized, could be this way {
group: 'Group',
total: 'Total',
tabularRep: {
title: "Tabular representation'",
downloadAsCSV: 'Download as CSV'
},
toolbar: {
exportAsCSV: 'Export to CSV',
exportAsJPG: 'Export to JPG',
exportAsPNG: 'Export to PNG',
}
} |
||
} | ||
|
||
/** | ||
* Legend options | ||
*/ | ||
|
@@ -179,6 +197,7 @@ const chart: BaseChartOptions = { | |
theme: ChartTheme.WHITE, | ||
tooltip: baseTooltip, | ||
legend, | ||
locale, | ||
style: { | ||
prefix: 'cc' | ||
}, | ||
|
@@ -229,9 +248,9 @@ const chart: BaseChartOptions = { | |
*/ | ||
const thematicChart: ThematicChartOptions = merge({}, chart, { | ||
thematic: { | ||
projection: Projection.geoNaturalEarth1, | ||
}, | ||
}); | ||
projection: Projection.geoNaturalEarth1 | ||
} | ||
}) | ||
|
||
/** | ||
* Options common to any chart with an axis | ||
|
@@ -474,10 +493,10 @@ const gaugeChart: GaugeChartOptions = merge({}, chart, { | |
const donutChart: DonutChartOptions = merge({}, pieChart, { | ||
donut: { | ||
center: { | ||
numberFontSize: (radius) => `${Math.min((radius / 100) * 24, 24)}px`, | ||
titleFontSize: (radius) => `${Math.min((radius / 100) * 15, 15)}px`, | ||
titleYPosition: (radius) => Math.min((radius / 80) * 20, 20), | ||
numberFormatter: (number) => Math.floor(number).toLocaleString() | ||
numberFontSize: radius => `${Math.min((radius / 100) * 24, 24)}px`, | ||
titleFontSize: radius => `${Math.min((radius / 100) * 15, 15)}px`, | ||
titleYPosition: radius => Math.min((radius / 80) * 20, 20), | ||
numberFormatter: number => Math.floor(number).toLocaleString() | ||
}, | ||
alignment: Alignments.LEFT | ||
} | ||
|
@@ -520,7 +539,7 @@ const radarChart: RadarChartOptions = merge({}, chart, { | |
gridline: { | ||
enabled: true | ||
}, | ||
valueFormatter: (value) => (value !== null && value !== undefined ? value : 'N/A') | ||
valueFormatter: value => (value !== null && value !== undefined ? value : 'N/A') | ||
} | ||
} as RadarChartOptions) | ||
|
||
|
@@ -589,10 +608,10 @@ const heatmapChart: HeatmapChartOptions = merge({}, chart, { | |
const choroplethChart: ChoroplethChartOptions = merge({}, thematicChart, { | ||
choropleth: { | ||
colorLegend: { | ||
type: 'linear', | ||
}, | ||
}, | ||
} as ChoroplethChartOptions); | ||
type: 'linear' | ||
} | ||
} | ||
} as ChoroplethChartOptions) | ||
|
||
export const options = { | ||
alluvialChart, | ||
|
@@ -623,7 +642,7 @@ export const options = { | |
thematicChart, | ||
treeChart, | ||
treemapChart, | ||
wordCloudChart, | ||
wordCloudChart | ||
} | ||
|
||
export { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.