Skip to content
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): 11243 - all translations around DN are replaced with tokens #116

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('bivariate.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
13 changes: 7 additions & 6 deletions src/core/api_client/apiClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import jwtDecode from 'jwt-decode';
import { i18n } from '~core/localization';
import config from '~core/app_config';
import { create } from '~utils/axios/apisauce/apisauce';
import { replaceUrlWithProxy } from '~utils/axios/replaceUrlWithProxy';
Expand Down Expand Up @@ -302,17 +303,17 @@ export class ApiClient {

switch (errorResponse.kind) {
case 'timeout':
return 'Request Timeout';
return i18n.t('errors.timeout');
case 'cannot-connect':
return "Can't connect to server";
return i18n.t('errors.cannot_connect');
case 'forbidden':
return 'Forbidden';
return i18n.t('errors.forbidden');
case 'not-found':
return 'Not found';
return i18n.t('errors.not_found');
case 'unknown':
return 'Unknown';
return i18n.t('errors.unknown');
default:
return 'Server Error';
return i18n.t('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
185 changes: 173 additions & 12 deletions src/core/localization/translations/en/common-messages.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,180 @@
{
"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",

"bivariate.matrix.icon.population": "Value divided by Population",
"bivariate.matrix.icon.area_km2": "Value divided by Area",
"bivariate.matrix.icon.total_building_count": "Value divided by Total Buildings Estimate",
"bivariate.matrix.icon.populated_area_km2": "Value divided by Populated Area",
"bivariate.matrix.icon.one": "Without divider",
"bivariate.matrix.icon.roads": "Value divided by Total Roads Length",
"save": "Save",
"cancel": "Cancel",
"create": "Create",

"bivariate.legend.high": "High",
"bivariate.legend.low": "Low",
"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",

"sidebar.biv-color-manager": "Bivariate color manager"
"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_layer": "Edit Layer",
"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",
"warning": "Not a valid geojson file",
"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",
"icon.area_km2": "Value divided by Area",
"icon.total_building_count": "Value divided by Total Buildings Estimate",
"icon.populated_area_km2": "Value divided by Populated Area",
"icon.one": "Without divider",
"icon.roads": "Value divided by Total Roads Length"
},

"legend": {
"high": "High",
"low": "Low"
},

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

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

"login": {
"email": "Email",
"password": "Password",
"login_button": "Login",
"sign_up": "Sign up",
"logging_in": "Logging in...",
"log_in": "Log in",
"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"
}
},

"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"
}
}
}
Loading