Skip to content

Commit

Permalink
feat(i18n): 11243 - all translations around DN are replaced with tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
propakov committed Aug 23, 2022
1 parent 0fac393 commit 71cb805
Show file tree
Hide file tree
Showing 54 changed files with 306 additions and 144 deletions.
12 changes: 7 additions & 5 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ const { PopupTooltip } = lazily(() => import('~features/tooltip'));
const DEFAULT_HEADER_TITLE = 'Disaster Ninja';
const PAGE_TITLES_BY_ROUTE = {
[ROUTES.base]: () => DEFAULT_HEADER_TITLE,
[ROUTES.reports]: () => <LinkableTitle title={i18n.t('Reports')} />,
[ROUTES.reportPage]: () => <LinkableTitle title={i18n.t('Reports')} />,
[ROUTES.reports]: () => <LinkableTitle title={i18n.t('sidebar.reports')} />,
[ROUTES.reportPage]: () => (
<LinkableTitle title={i18n.t('sidebar.reports')} />
),
[ROUTES.bivariateManager]: () => (
<LinkableTitle title={i18n.t('Appearance administration')} />
<LinkableTitle title={i18n.t('biv_color_manager.title')} />
),
};

Expand All @@ -106,7 +108,7 @@ const afterChatContent = (loginFeature: boolean) => {
className={s.link}
rel="noreferrer"
>
<Text type="heading-m">{i18n.t('About')}</Text>
<Text type="heading-m">{i18n.t('about')}</Text>
</a>
{loginFeature && <UserProfile />}
</div>
Expand Down Expand Up @@ -190,7 +192,7 @@ const LinkableTitle = ({ title }: { title: string }) => {
<span
className={s.clickable}
onClick={goBase}
title={i18n.t('to main page')}
title={i18n.t('to_main_page')}
>
Disaster Ninja
</span>{' '}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ConnectedMap/useDrawings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function useDrawings() {
setDrawings(updatedData);
break;
case 'skipSelfIntersection':
alert(t('Self intersections are not supported'));
alert(t('drawings.self_directions_not_supported'));
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/components/LoadingSpinner/LoadingSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { KonturSpinner } from './KonturSpinner';
import s from './LoadingSpinner.module.css';

export function LoadingSpinner({
message = i18n.t('Gathering data'),
message = i18n.t('spinner_text'),
}: {
message?: string;
}) {
Expand Down
12 changes: 6 additions & 6 deletions src/core/api_client/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,17 @@ export class ApiClient {

switch (errorResponse.kind) {
case 'timeout':
return 'Request Timeout';
return 'errors.timeout';
case 'cannot-connect':
return "Can't connect to server";
return 'errors.cannot_connect';
case 'forbidden':
return 'Forbidden';
return 'errors.forbidden';
case 'not-found':
return 'Not found';
return 'errors.not_found';
case 'unknown':
return 'Unknown';
return 'errors.unknown';
default:
return 'Server Error';
return 'errors.server_error';
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/draw_tools/atoms/toolboxAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const toolboxAtom = createAtom(
return actions.push(
currentNotificationAtom.showNotification(
'info',
{ title: i18n.t('No drawn geometry to download') },
{ title: i18n.t('draw_tools.no_geometry_error') },
5,
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const DrawToolsToolbox = () => {
onClick={() => toggleDrawMode(drawModes.DrawPolygonMode)}
>
<div className={s.btnContent}>
<Area24 /> {i18n.t('Area')}
<Area24 /> {i18n.t('draw_tools.area')}
</div>
</Button>
),
Expand All @@ -59,7 +59,7 @@ export const DrawToolsToolbox = () => {
onClick={() => toggleDrawMode(drawModes.DrawLineMode)}
>
<div className={s.btnContent}>
<Line24 /> {i18n.t('Line')}
<Line24 /> {i18n.t('draw_tools.line')}
</div>
</Button>
),
Expand All @@ -71,7 +71,7 @@ export const DrawToolsToolbox = () => {
onClick={() => toggleDrawMode(drawModes.DrawPointMode)}
>
<div className={s.btnContent}>
<PointOutline24 /> {i18n.t('Point')}
<PointOutline24 /> {i18n.t('draw_tools.point')}
</div>
</Button>
),
Expand All @@ -93,7 +93,7 @@ export const DrawToolsToolbox = () => {
<Download24 />
</Button>,
<Button key="finish" onClick={onFinishClick}>
{settings.finishButtonText || i18n.t('Finish Drawing')}
{settings.finishButtonText || i18n.t('draw_tools.finish_drawing')}
</Button>,
],
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -105,7 +105,7 @@ export const DrawToolsToolbox = () => {
{!drawingIsStarted && (
<div className={s.drawHint}>
<Text type="caption">
<span>{i18n.t('Click on the map to begin drawing')}</span>
<span>{i18n.t('draw_tools.caption')}</span>
</Text>
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/core/draw_tools/modes/drawPolygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class LocalDrawPolygonMode extends CustomDrawPolygonMode {
if (this.intersectionsTest(props, polygonCoords)) {
currentNotificationAtom.showNotification.dispatch(
'error',
{ title: i18n.t('Polygon should not overlap itself') },
{ title: i18n.t('draw_tools.overlap_error') },
5,
);
this['resetClickSequence']();
Expand Down Expand Up @@ -117,7 +117,7 @@ export class LocalDrawPolygonMode extends CustomDrawPolygonMode {
if (this.intersectionsTest(props, polygonCoords)) {
currentNotificationAtom.showNotification.dispatch(
'error',
{ title: i18n.t('Polygon should not overlap itself') },
{ title: i18n.t('draw_tools.overlap_error') },
5,
);
this['resetClickSequence']();
Expand Down
2 changes: 1 addition & 1 deletion src/core/draw_tools/renderers/DrawModeRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class DrawModeRenderer extends LogicalLayerDefaultRenderer<CombinedAtom>
if (hasIntersections(feature)) {
this._showNotificationAction(
'error',
{ title: i18n.t('Polygon should not overlap itself') },
{ title: i18n.t('draw_tools.overlap_error') },
5,
);
return this._updateData(this._previousValidGeometry);
Expand Down
1 change: 0 additions & 1 deletion src/core/localization/TranslationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ i18n
fallbackLng: 'en',
debug: false,
defaultNS: 'common',
keySeparator: '/',
interpolation: {
escapeValue: false,
},
Expand Down
162 changes: 158 additions & 4 deletions src/core/localization/translations/en/common-messages.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,122 @@
{
"common": {
"Request Timeout": "Request Timeout!",
"No administrative boundaries": "No administrative boundaries here!",
"Self intersections are not supported": "Self intersections are not supported!",
"km": "km",
"m": "m",

"to": "to",

"save": "Save",
"cancel": "Cancel",
"create": "Create",

"disasters": "Disasters",
"loading": "Loading...",
"loading_events": "Loading Events",
"about": "About",
"to_main_page": "to main page",
"legend": "Legend",
"maps": "maps",
"vertical_direction": "Vertical Direction",
"horizontal_direction": "Horizontal Direction",
"legend_presentation": "Legend Presentation",
"layers": "Layers",
"feed": "Feed",
"details": "Details",

"deselect": "Deselect",
"spinner_text": "Gathering data",

"errors": {
"timeout": "Request Timeout!",
"cannot_connect": "Can't connect to server",
"forbidden": "Forbidden",
"not_found": "Not found",
"unknown": "Unknown",
"server_error": "Server Error"
},

"event_list": {
"title": "Focus to disasters",
"warning_title": "Can't use map as filter",
"warning_description": "Map not ready yet, try later",
"bbox_filter_button": "Use map view as filter",

"analytics": {
"affected_people": {
"tooltip": "Affected People",
"value": "No humanitarian impact"
},
"settled_area.tooltip": "Settled Area",
"osm_gaps_percentage.tooltip": "OSM Gaps Percentage (lower is better)",
"loss.tooltip": "Estimated loss"
}
},

"create_layer": {
"edit_layers": "Edit Layers",
"edit_features": "Edit Features",
"delete_layer": "Delete Layer",
"create_layer": "Create Layer",
"saving_layer": "Saving layer...",
"field_name": "Field name",
"layer_name": "Layer name",
"marker_icon": "Marker icon",
"type": "Type",
"select": "Select",
"short_text": "Short Text",
"long_text": "Long Text",
"link": "Link",
"image": "Image",
"fields": "Fields",
"add_field": "Add field",
"location": "Location",
"edit_feature_placeholder": "Select some feature for start edit feature properties"
},

"advanced_analytics_panel_header": {
"loading": "Loading advanced analytics...",
"other": "Advanced analytics"
},

"analytics_panel_header": {
"init": "Select Geometry",
"loading": "Loading analytics...",
"error": "Error",
"other": "Analytics"
},

"advanced_analytics_empty": {
"not_found": "Sorry, requested event not found.",
"error": "An error occured!",
"please_select": "Please, select an area again",
"to_see_map": "to see state of the map",
"pick": "Pick disaster from the list",
"draw": "Draw polygon on the map",
"select": "Select boundary on the map",
"upload": "Upload your own geoJSON"
},

"draw_tools": {
"area": "Area",
"line": "Line",
"point": "Point",
"finish_drawing": "Finish Drawing",
"caption": "Click on the map to begin drawing",
"no_geometry_error": "No drawn geometry to download",
"overlap_error": "Polygon should not overlap itself",
"save_features": "Save features"
},

"boundary_selector.title": "Focus to administrative boundary",

"geometry_uploader.title": "Focus to uploaded geometry",
"geometry_uploader.warning": "Not a valid geojson file",
"geometry_uploader.error": "Error while reading uploaded file",

"focus_geometry.title": "Focus to freehand geometry",
"focus_geometry_layer.settings.name": "Selected Areay",

"drawings.self_directions_not_supported": "Self intersections are not supported!",

"bivariate.matrix.icon.population": "Value divided by Population",
"bivariate.matrix.icon.area_km2": "Value divided by Area",
Expand All @@ -14,6 +128,46 @@
"bivariate.legend.high": "High",
"bivariate.legend.low": "Low",

"sidebar.biv-color-manager": "Bivariate color manager"
"sidebar": {
"biv_color_manager": "Bivariate color manager",
"reports": "Reports",
"edit_osm": "Edit in OpenStreetMap",
"ruler": "Ruler"
},

"biv_color_manager": {
"layers_filter": "Layers",
"title": "Appearance administration",
"no_legends": "There are no legends satisfying the conditions.",
"no_data": "No Data."
},

"login": {
"email": "Email",
"password": "Password",
"login_button": "Login",
"sign_up": "Sign up",
"error": {
"email_empty": "Email has not to be empty!",
"email_invalid": "Email has to be valid!",
"password": "Password has not to be empty!",
"connect": "Couldn't connect to authentication service"
},
"logging_in": "Logging in...",
"log_in": "Log in"
},

"reports": {
"title": "Disaster Ninja Reports",
"no_data": "No data for this report",
"sorting": "Sorting data...",
"loading": "Loading data",
"search_location": "Search location",
"open_josm": "Open via JOSM remote control",
"josm_logo_alt": "JOSM logo",
"updated": "Updated",
"see_all": "See all reports",
"wrong_id": "Wrong report ID"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@ export const AdvancedAnalyticsEmptyState = ({
<div className={s.stateContainer}>
{stateType === 'not-found' && (
<>
{i18n.t('Sorry, requested event not found.')}
{i18n.t('advanced_analytics_empty.not_found')}
<br />
</>
)}
{stateType === 'error' && (
<>
{i18n.t('An error occured!')}
{i18n.t('advanced_analytics_empty.error')}
<br />
</>
)}

{i18n.t('Please, select an area again')}
{i18n.t('advanced_analytics_empty.please_select')}
<br />
{i18n.t('to see state of the map')}
{i18n.t('advanced_analytics_empty.to_see_map')}

<div className={s.iconsContainer}>
<div className={s.iconRow}>
<DisastersListIcon /> {i18n.t('Pick disaster from the list')}
<DisastersListIcon /> {i18n.t('advanced_analytics_empty.pick')}
</div>
<div className={s.iconRow}>
<Poly24 /> {i18n.t('Draw polygon on the map')}
<Poly24 /> {i18n.t('advanced_analytics_empty.draw')}
</div>
<div className={s.iconRow}>
<SelectArea24 /> {i18n.t('Select boundary on the map')}
<SelectArea24 /> {i18n.t('advanced_analytics_empty.select')}
</div>
<div className={s.iconRow}>
<Plus24 /> {i18n.t('Upload your own geoJSON')}
<Plus24 /> {i18n.t('advanced_analytics_empty.upload')}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ const AdvancedAnalyticsPanelHeaderContainer = () => (
<AnalyticsPanelHeader
resourceAtom={advancedAnalyticsResourceAtom}
messages={{
init: 'Select Geometry',
loading: 'Loading advanced analytics...',
error: 'Error',
other: 'Advanced analytics'
init: 'analytics_panel_header.init',
loading: 'advanced_analytics_panel_header.loading',
error: 'analytics_panel_header.error',
other: 'advanced_analytics_panel_header.other',
}}
/>);
/>
);

export default AdvancedAnalyticsPanelHeaderContainer;
Loading

0 comments on commit 71cb805

Please sign in to comment.