-
Notifications
You must be signed in to change notification settings - Fork 16
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
[WIP] [Locale] Intl C4R #741
Conversation
Pull Request Test Coverage Report for Build 6236847753
💛 - Coveralls |
Visit the preview URL for this PR (updated for commit e4b04b6): https://cartodb-fb-storybook-react-dev--pr741-feature-menusal-zassqukm.web.app (expires Fri, 21 Jul 2023 07:01:04 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 517cc4d31d7e09cf277774e034094b67c301cd4c |
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.
looks good 👍 , only minor comments
packages/react-ui/src/widgets/TimeSeriesWidgetUI/TimeSeriesWidgetUI.js
Outdated
Show resolved
Hide resolved
@@ -182,7 +187,14 @@ function Header({ | |||
</Tooltip> | |||
)} | |||
{switchable && ( | |||
<Tooltip title={(visible ? 'Hide' : 'Show') + ' layer'}> |
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.
create two proper distinct translations for 'Hide layer' and 'Show layer'
(current approach assumes language without declension like polish: layer=warstwa, Show layer=Pokaż warstwę)
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.
fixed
Hi @aaranadev this is almost there. If you can please have a general look / do some basic cleanup I think we'll be ready for an alpha. With the alpha, we will make a PR on cloud-native to check it works and we will appreciate a very small PR in carto-react-template to validate it works as expected |
@VictorVelarde @zbigg @aaranadev Update: After testing Imperative APICannot be used with Option A (currently implemented in the PR)
// Widget
<CategoryWidget
id='revenueByStoreType'
title='Category'
dataSource={source.id}
column='storetype'
operationColumn='revenue'
operation={AggregationTypes.SUM}
intlConfig={INTL_CONFIG}
/> Pros
Cons
import { setItlConfig } from 'from '@carto/react-redux'
dispatch(setItlConfig(INTL_CONFIG)) Pros
Cons
NOTE: Both options use the same object to pass the Intl configuration: // External application using Carto for React
export const INTL_CONFIG = {
locale: 'id',
messages: {
c4r: {
widgets: {
category: {
apply: 'Apply',
unlock: 'Unlock',
lock: 'Lock',
clear: 'Clear',
noResults: 'No results',
noResultsMessage:
'Your search "{searchValue}" did not yield any matches.',
// Rest of the messages
}
},
},
},
}; Option B: IntlProvider (Not tested)
|
const messagesLocale = findMatchingMessagesLocale(locale); | ||
const intMessages = intlConfig?.messages | ||
? flattenMessages(intlConfig?.messages) | ||
: messages[messagesLocale]; |
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.
i think all lines above should be in memo together with createIntl
mainly findMatchingMessagesLocale
and flattenMessages
are not trivial and everything depends only on intlConfig
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.
Done
@@ -81,6 +81,7 @@ const EMPTY_ARRAY = []; | |||
* @param {string[]=} [props.palette] - Optional palette | |||
* @param {object} [props.wrapperProps] - Extra props to pass to [WrapperWidgetUI](https://storybook-react.carto.com/?path=/docs/widgets-wrapperwidgetui--default). | |||
* @param {object} [props.noDataAlertProps] - Extra props to pass to [NoDataAlert](). | |||
* @param {object} [props.intlConfig] - Object with intl configuration. If not provided, default messages will be used. |
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.
please use {object=}
to indicate that this is optional parameter
(not necessarily here, as there is proper .d.ts, but mainly for other widgets and places when you add optional param
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.
I'm going to remove all intlConfig props, and we are to implement the Provider option.
Closed in favor to B option |
Description
Shortcut: 145211
Use multi-language in projects
Type of change
(choose one and remove the others)
Acceptance
Please describe how to validate the feature or fix
If feature deals with theme / UI or internal elements used also in CARTO 3, please also add a note on how to do acceptance on that part.
Basic checklist