-
Notifications
You must be signed in to change notification settings - Fork 36
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(base-map): Add support for i18n on map controls #718
Merged
amy-corson-ibigroup
merged 10 commits into
opentripplanner:master
from
ibi-group:i18n-base-map-controls
Apr 8, 2024
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8d3660f
feat(base-map): Add support for i18n on map controls
amy-corson-ibigroup f21243b
Clean up translation object
amy-corson-ibigroup 9482952
Add return type on mapControlTranslation
amy-corson-ibigroup 2617f18
Address PR feedback
amy-corson-ibigroup 7411eea
Update packages/base-map/i18n/i18n-exceptions.json
amy-corson-ibigroup 8aa43e5
chore(base-map/i18n): Add French text
binh-dam-ibigroup bec4e84
fix i18n exceptions file
amy-corson-ibigroup 4fc0f49
Address PR feedback
amy-corson-ibigroup 4152883
chore(base-map): Add select translations files and entries.
binh-dam-ibigroup 03a17c1
update i18n translations for base-map
amy-corson-ibigroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
otpUi: | ||
mapControls: | ||
CooperativeGesturesHandler: | ||
MacHelpText: Use ⌘ + scroll to zoom the map | ||
MobileHelpText: Use two fingers to move the map | ||
WindowsHelpText: Use Ctrl + scroll to zoom the map | ||
NavigationControl: | ||
ResetBearing: Reset bearing to north | ||
ZoomIn: Zoom in | ||
ZoomOut: Zoom out | ||
ScaleControl: | ||
Feet: ft | ||
Kilometers: km | ||
Meters: m | ||
Miles: mi | ||
NauticalMiles: nm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
otpUi: | ||
mapControls: | ||
CooperativeGesturesHandler: | ||
MacHelpText: Utilisez ⌘ + défil pour zoomer sur la carte | ||
MobileHelpText: Utilisez deux doigts pour déplacer la carte | ||
WindowsHelpText: Utilisez Ctrl + défil pour zoomer sur la carte | ||
NavigationControl: | ||
ResetBearing: Repositioner le nord en haut de la carte | ||
ZoomIn: Zoom avant | ||
ZoomOut: Zoom arrière | ||
ScaleControl: | ||
Feet: ft | ||
Kilometers: km | ||
Meters: m | ||
Miles: mi | ||
NauticalMiles: nm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
miles-grant-ibigroup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"groups": { | ||
"otpUi.mapControls.CooperativeGesturesHandler.*": [ | ||
"MacHelpText", | ||
"MobileHelpText", | ||
"WindowsHelpText" | ||
], | ||
"otpUi.mapControls.NavigationControl.*": [ | ||
"ResetBearing", | ||
"ZoomIn", | ||
"ZoomOut" | ||
], | ||
"otpUi.mapControls.ScaleControl.*": [ | ||
"Feet", | ||
"Kilometers", | ||
"Meters", | ||
"Miles", | ||
"NauticalMiles" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { IntlShape } from "react-intl"; | ||
|
||
// Creates a language file to pass to MapLibre that has this format: | ||
// https://github.com/maplibre/maplibre-gl-js/blob/main/src/ui/default_locale.ts | ||
|
||
const MAP_CONTROL_TRANSLATION_KEYS = [ | ||
amy-corson-ibigroup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"NavigationControl.ResetBearing", | ||
"NavigationControl.ZoomIn", | ||
"NavigationControl.ZoomOut", | ||
"ScaleControl.Feet", | ||
"ScaleControl.Meters", | ||
"ScaleControl.Kilometers", | ||
"ScaleControl.Miles", | ||
"ScaleControl.NauticalMiles", | ||
"CooperativeGesturesHandler.WindowsHelpText", | ||
"CooperativeGesturesHandler.MacHelpText", | ||
"CooperativeGesturesHandler.MobileHelpText" | ||
]; | ||
|
||
const mapControlTranslationObject = ( | ||
amy-corson-ibigroup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
intl: IntlShape | ||
): Record<string, string> => { | ||
const languageObject = {}; | ||
|
||
MAP_CONTROL_TRANSLATION_KEYS.forEach(x => { | ||
languageObject[x] = intl.formatMessage({ | ||
id: `otpUi.mapControls.${x}` | ||
amy-corson-ibigroup marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
}); | ||
|
||
return languageObject; | ||
}; | ||
|
||
export default mapControlTranslationObject; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Where does the scale control get used? I don't see a scale on most maps.
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.
This is in the "with optional controls" story, but we can always remove that scale from the map if it's not representative of how we use it?