-
Notifications
You must be signed in to change notification settings - Fork 190
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
feat(i18n): new locale interface, and translation configs #1710
Conversation
… implementation of translations property
✅ Deploy Preview for carbon-charts-angular ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for carbon-charts-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for carbon-charts-core ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I have read the DCO document and I hereby sign the DCO. |
/** | ||
* Locale configuration | ||
*/ | ||
locale?:Locale |
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.
Add space after colon
date?: (value: Date) => string | ||
translations?: { | ||
group?: string // used by Tooltip and Toolbar / Tabular Representation | ||
total?:string // ditto |
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.
add space after colon
…ormatter to table and tooltip
toolbarExportAsJPG: 'Export to JPG', | ||
toolbarExportAsPNG: 'Export to PNG', | ||
tabularDownloadAsCSV: 'Download as CSV' | ||
} |
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.
@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',
}
}
|
||
return format(date, formatString, { locale }) | ||
const { code, optionsObject } = localeObject | ||
if (interval === 'quarterly') { |
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.
could you explain this piece pls? it seems like we're formatting date values using our number
locale formatter
@@ -224,6 +224,7 @@ export class Axis extends Component { | |||
// create the right ticks formatter | |||
let formatter: any | |||
const userProvidedFormatter = getProperty(axisOptions, 'ticks', 'formatter') | |||
const { code, number: numberFormatter } = getProperty(options, 'locale') |
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.
const { code, number: numberFormatter } = getProperty(options, 'locale') | |
const { code: localeCode, number: numberFormatter } = getProperty(options, 'locale') |
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.
pls use more readable names. it's clear on this line that you're pulling a locale code, but in another line in this file when you will pass code
into a function, it's not clear (from the name) what code
is
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.
ok I'll keep this in mind, I have updated to localeCode.
@@ -84,8 +84,10 @@ export function formatTick( | |||
i: number, | |||
allTicks: Array<number>, | |||
interval: string, | |||
timeScaleOptions: TimeScaleOptions | |||
timeScaleOptions: TimeScaleOptions, | |||
options |
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.
options | |
localeOptions |
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.
let's just pass options.locale
into this function rather than the full options
@@ -18,16 +18,17 @@ export class MeterTitle extends Title { | |||
const options = this.getOptions() | |||
const svg = this.getComponentContainer() | |||
const { groupMapsTo } = options.data | |||
|
|||
const meterTitle = getProperty(options, 'locale', 'translations', 'meterTitle') |
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.
let's try to organize these better (e.g. options.locale.translations.meter.title
packages/core/src/configuration.ts
Outdated
}, | ||
pp: { | ||
obj: {}, | ||
type: 'time' | ||
}, | ||
'MMM d, p': { | ||
obj: { | ||
month: 'short', | ||
day: 'numeric', | ||
hour: 'numeric', | ||
minute: '2-digit' | ||
}, | ||
type: 'time' | ||
}, | ||
p: { | ||
obj: { | ||
hour: 'numeric', | ||
minute: '2-digit' | ||
}, | ||
type: 'time' | ||
}, | ||
'MMM d, h:mm:ss.SSS a': { | ||
obj: { | ||
month: 'short', | ||
day: 'numeric', | ||
hour: 'numeric', | ||
minute: '2-digit', | ||
fractionalSecondDigits: 3 | ||
}, | ||
type: 'time' | ||
}, | ||
'h:mm:ss.SSS a': { | ||
obj: { | ||
hour: 'numeric', | ||
minute: '2-digit', | ||
fractionalSecondDigits: 3 | ||
}, | ||
type: 'time' | ||
}, | ||
'MMM d': { | ||
obj: { | ||
month: 'short', | ||
day: 'numeric' | ||
}, | ||
type: 'date' | ||
}, | ||
d: { | ||
obj: { | ||
day: 'numeric' | ||
}, | ||
type: 'date' | ||
}, | ||
'MMM d, hh a': { | ||
obj: { | ||
month: 'short', | ||
day: 'numeric', | ||
hour: '2-digit' | ||
}, | ||
type: 'time' | ||
}, | ||
'hh a': { | ||
obj: { | ||
hour: '2-digit' | ||
}, | ||
type: 'time' | ||
}, | ||
'MMM yyyy': { | ||
obj: { | ||
month: 'short', | ||
year: 'numeric' | ||
}, | ||
type: 'date' | ||
}, | ||
MMM: { | ||
obj: { | ||
month: 'short' | ||
}, | ||
type: 'date' | ||
}, | ||
'eee, MMM d': { | ||
obj: { | ||
weekday: 'short', | ||
month: 'short', | ||
day: 'numeric' | ||
}, | ||
type: 'date' | ||
}, | ||
eee: { | ||
obj: { | ||
weekday: 'short' | ||
}, | ||
type: 'date' | ||
}, | ||
yyyy: { | ||
obj: { | ||
year: 'numeric' | ||
}, | ||
type: 'date' | ||
} | ||
}, |
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.
what is this object? what does it do?
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.
There are formats for date string, but this is a work in progress since it is a draft PR.
export interface Locale { | ||
code?: string // BCP 47 language tag | ||
number?: (value: number, language: string) => string | ||
date?: (value: Date, language: string, options) => string |
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.
what is the type for options? is it Intl.DateTimeFormatOptions
?
code?: string // BCP 47 language tag | ||
number?: (value: number, language: string) => string | ||
date?: (value: Date, language: string, options) => string | ||
time?: (value: Date, language: string, options) => string |
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.
what is the type for options? is it Intl.DateTimeFormatOptions
?
const binnedStackedData = this.getBinnedStackedData() | ||
|
||
const headers = [ | ||
console.log(code) |
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.
console.log
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
get(options, 'locale.translations.group') || get(options, 'tooltip.groupLabel'), | |
get(options, 'locale.translations.group') || get(options, 'tooltip.groupLabel') || 'Group', |
This release made our app crash when server side rendering ReferenceError: navigator is not defined
File "../../../../../../../../../../../../../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@carbon/charts/dist/color-scale-utils-eeC25Jjh.mjs", line 1867, col 9, in <anonymous>
code: navigator.language, |
@MathiasWP -Surprised to hear that I use |
I believe this PR has broken the use of numberFormatter for some charts.
These are wrapped in a |
I don't understand how this PR fixed the issue posted on Am i missing something here or it is still an open issue? |
Updates
Demo screenshot or recording