-
Notifications
You must be signed in to change notification settings - Fork 356
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
Very rough approach for implementing language settings #3742
Conversation
So there's a few ways around the icon problem, e.g. feeding in an actual react component as part of the "i18n"/language config, or the simplest way for now is to keep the existing components as "defaults" (with icon), then overrides means no icon-ability atm. |
I'll do a quick audit tomorrow of how many places we use components within regular HTML, if it's only the lightbulb icon in that empty workbench effected then I'm happy to have no icon-ability :) |
@rowanwins @soyarsauce why not use https://github.com/TerriaJS/terriajs/blob/master/lib/ReactViews/Custom/parseCustomMarkdownToReact.js to render the localized "strings". Then you can support icons by defining a custom component (https://github.com/TerriaJS/terriajs/blob/master/lib/ReactViews/Custom/registerCustomComponentTypes.js). It sanitizes the input too. |
Good idea @kring - I'll give it a whirlybird! |
Okay @kring & @soyarsauce - the latest commit adds support for Icon's as customComponents.
And are we happy to proceed and get this into On a sidenote there is also some similar stuff that we do via the config.json in TerriaMap (eg we have a |
Theoretically the |
reminder to @soyarsauce to review this one |
This is awesome work @rowanwins & looks good, hope you don't mind I just extended so we can also use any component/jsx, if the latest commit looks good to you, let's merge it |
Looks good to me @soyarsauce - it doesn't seem like I can merge it because I can't review it because I opened the PR, but I've looked over it and tested locally and it all makes sense. |
Sorry @rowanwins I thought I approved w/ my single comment review |
Related to #3707 where it's suggested to changing the naming of some buttons are parts of the interface.
This approach would see languageOverrides to be passed in from TerriaMap to via the options to
Terria.js
The main downside I've seen so far is that some text components occasionally include React components like Icons, for example empty workbench has a message which includes a lightbulb icon. The current approach doesn't render those react components. Someone much better with React would probably have a few ideas how to handle this.
What I've done in
TerriaMap/index.js
isThese overrides then get merged into the defaults.
Anyway this is my very naive approach :)