diff --git a/package.json b/package.json index 50f7770..01f5b94 100644 --- a/package.json +++ b/package.json @@ -95,5 +95,6 @@ "devDependencies": { "@types/lodash": "^4.14.184" }, - "description": "An Ionic project" + "description": "An Ionic project", + "postinstall": "npx patch-package" } diff --git a/patches/localized-strings+0.2.4.patch b/patches/localized-strings+0.2.4.patch new file mode 100644 index 0000000..765dab7 --- /dev/null +++ b/patches/localized-strings+0.2.4.patch @@ -0,0 +1,15 @@ +diff --git a/node_modules/localized-strings/lib/LocalizedStrings.js b/node_modules/localized-strings/lib/LocalizedStrings.js +index eefa6c8..e0a3cae 100644 +--- a/node_modules/localized-strings/lib/LocalizedStrings.js ++++ b/node_modules/localized-strings/lib/LocalizedStrings.js +@@ -192,8 +192,8 @@ var LocalizedStrings = function () { + if (_this4._opts.logsEnabled) { + console.log("\uD83D\uDEA7 \uD83D\uDC77 key '" + key + "' not found in localizedStrings for language " + _this4._language + " \uD83D\uDEA7"); + } +- } else if (typeof strings[key] !== "string") { +- // It's an object ++ } else if (typeof strings[key] !== "string" && defaultStrings[key].$$typeof === undefined) { ++ // It's an object (and it's not a React component) + _this4._fallbackValues(defaultStrings[key], strings[key]); + } + }); diff --git a/src/components/map/GpxRecord.tsx b/src/components/map/GpxRecord.tsx index d633c35..dd2701b 100644 --- a/src/components/map/GpxRecord.tsx +++ b/src/components/map/GpxRecord.tsx @@ -29,6 +29,9 @@ import { useDispatch, useSelector } from 'react-redux'; import { mapActions } from '../../store/map'; import { SettingsState } from '../../store/settings'; +import i18n from '../../i18n/index'; + + declare global { var $lastValidLocationTime: number; } @@ -144,9 +147,9 @@ const GpxRecord: React.FC<{}> = () => { leaveAnimation={leaveAnimation} > - Track recording + {i18n.trackRecording} - dismiss()}>Close + dismiss()}>{i18n.close} @@ -159,9 +162,9 @@ const GpxRecord: React.FC<{}> = () => { > {hasCurrentTrack ? ( - Resume recording + {i18n.resumeRecording} ) : ( - Start recording + {i18n.startRecording} )} )} @@ -172,7 +175,7 @@ const GpxRecord: React.FC<{}> = () => { size='large' onClick={pauseRecording} > - Pause + {i18n.pauseRecording} )} {hasCurrentTrack && ( @@ -183,9 +186,7 @@ const GpxRecord: React.FC<{}> = () => { size='large' onClick={stopRecording} > - Stop recording -
- (and save track) + {i18n.stopRecording} = () => { size='large' onClick={deleteRecording} > - Cancel - recording -
- (and clear track) + {i18n.cancelRecording}
)} diff --git a/src/components/map/TileServerChooserDialog.tsx b/src/components/map/TileServerChooserDialog.tsx index 7fda5a1..976b5cd 100644 --- a/src/components/map/TileServerChooserDialog.tsx +++ b/src/components/map/TileServerChooserDialog.tsx @@ -16,6 +16,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { enterAnimation, leaveAnimation } from '../../lib/animation'; import { mapActions, MapState } from '../../store/map'; import { tileProviders } from './tile'; +import i18n from '../../i18n/index'; const TileServerChooserDialog: React.FC<{}> = () => { const tileProvider = useSelector( @@ -35,7 +36,6 @@ const TileServerChooserDialog: React.FC<{}> = () => { dismiss(); }; - return ( = () => { leaveAnimation={leaveAnimation} > - Choose your map + {i18n.chooseYourMap} - dismiss()}>Close + dismiss()}>{i18n.close} diff --git a/src/components/map/TracksBrowser.tsx b/src/components/map/TracksBrowser.tsx index d2876f9..4a46870 100644 --- a/src/components/map/TracksBrowser.tsx +++ b/src/components/map/TracksBrowser.tsx @@ -21,6 +21,7 @@ import { enterAnimation, leaveAnimation } from '../../lib/animation'; import phoneRoute from '../../theme/icons/font-gis/svg/routing/uEB08-phone-route-nons.svg'; import GpxImport from './gpx-import'; import GpxExport from './GpxExport'; +import i18n from '../../i18n/index'; const TrackBrowser: React.FC<{}> = () => { const gpxes = useFind({ @@ -50,10 +51,10 @@ const TrackBrowser: React.FC<{}> = () => { leaveAnimation={leaveAnimation} > - Tracks + {i18n.tracks} - dismiss()}>Close + dismiss()}>{i18n.close} diff --git a/src/i18n/index.ts b/src/i18n/index.ts deleted file mode 100644 index 68084ca..0000000 --- a/src/i18n/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -import LocalizedStrings from 'react-localization'; - -const strings = new LocalizedStrings({ - en: { - colonize: (input: string): any => strings.formatString('{0}:', input), - - save: 'Save', - cancel: 'Cancel', - close: 'Close', - settings: 'Settings', - user: 'User', - pseudo: 'Pseudo', - geolocation: 'Geolocation', - minTimeInt: 'Minimal time interval (ms)', - minDist:'Minimal distance (m)', - }, - fr: { - colonize: (input: string): any => strings.formatString('{0} :', input), - - save: 'Sauvegarder', - cancel: 'Annuler', - close: 'Fermer', - settings: 'Paramètres', - user: 'Utilisateur', - pseudo: 'Pseudo', - geolocation: 'Géolocalisation', - minTimeInt: 'Interval minimal (ms)', - minDist:'Distance minimale (m)', -}, -}); - -export default strings; diff --git a/src/i18n/index.tsx b/src/i18n/index.tsx new file mode 100644 index 0000000..fb6c549 --- /dev/null +++ b/src/i18n/index.tsx @@ -0,0 +1,81 @@ +import { Fragment } from 'react'; +import LocalizedStrings from 'react-localization'; + +const strings = new LocalizedStrings({ + en: { + colonize: (input: string): any => strings.formatString('{0}:', input), + + save: 'Save', + cancel: 'Cancel', + close: 'Close', + settings: 'Settings', + user: 'User', + pseudo: 'Pseudo', + geolocation: 'Geolocation', + minTimeInt: 'Minimal time interval (ms)', + minDist: 'Minimal distance (m)', + + trackRecording: 'Track recording', + resumeRecording: 'Resume recording', + startRecording: 'Start recording', + pauseRecording: 'Pause', + // stopRecording: 'stop', + // cancelRecording: 'cancel', + stopRecording: ( + + Stop recording +
+ (and save track) +
+ ), + cancelRecording: ( + + Cancel recording +
+ (and clear track) +
+ ), + + chooseYourMap: 'Choose your map', + + tracks: 'Tracks', + }, + fr: { + colonize: (input: string): any => strings.formatString('{0} :', input), + + save: 'Sauvegarder', + cancel: 'Annuler', + close: 'Fermer', + settings: 'Paramètres', + user: 'Utilisateur', + pseudo: 'Pseudo', + geolocation: 'Géolocalisation', + minTimeInt: 'Interval minimal (ms)', + minDist: 'Distance minimale (m)', + + trackRecording: 'Enregistrement de trace', + resumeRecording: "Reprendre l'enregistrement", + startRecording: "Démarre l'enregistrement", + pauseRecording: 'Pause', + stopRecording: ( + + Arrêter +
+ (et sauvegarder) +
+ ), + cancelRecording: ( + + Annuler +
+ (et effacer) +
+ ), + + chooseYourMap: 'Choisissez votre carte', + + tracks: 'Traces', + }, +}); + +export default strings;