Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Language select updates #86

Merged
merged 8 commits into from
Jan 12, 2018
Merged

Language select updates #86

merged 8 commits into from
Jan 12, 2018

Conversation

mateoclarke
Copy link
Contributor

@mateoclarke mateoclarke commented Jan 12, 2018

Updates UX of Language Select Bar. Closes #35

mobile_lang_select

desktop_lang_select

Copy link
Contributor

@benweatherman benweatherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really rad!

🐐

}

getPathname = () => {
let pathArray = this.props.location.pathname.split('/').filter(n => n)
let pathArray = this.props.location.pathname.split('/').filter(n => n);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😻

@mateoclarke mateoclarke changed the base branch from mc_links_and_stuff to master January 12, 2018 19:33
# Conflicts:
#	src/js/components/LanguageWrapper.js
#	src/js/modules/ListLink.js
#	src/js/page_sections/Header.js
#	src/js/page_sections/Navmenu.js
#	src/js/page_sections/RelatedLinks.js
#	src/js/pages/Service.js
@mateoclarke mateoclarke merged commit a0d2e28 into master Jan 12, 2018
@mateoclarke mateoclarke deleted the mc_lang_select_updates branch January 12, 2018 19:40
@@ -0,0 +1,16 @@
import Cookies from 'js-cookie';

const getPathWithLangCode = (linkTo, lang) => {
Copy link
Contributor Author

@mateoclarke mateoclarke Jan 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ifsimicoded, I merged this without your review so I wanted to call this out for your attention. Instead of finding a solution at the routing level, I chose to make this helper function, that can take a path and an optional lang parameters.

It looks up the cookie lang settings is there is no lang passed and returns the full path with language code.

This might be tedious to remember to use, but it felt like the quickest safest thing to do while there is still uncertainty about how our routing get moved into an SSR world.

@mateoclarke mateoclarke mentioned this pull request Jan 12, 2018
4 tasks
Copy link
Contributor

@ifsimicoded ifsimicoded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is A LOT! thanks for taking on such a complex thing. If you get a sec, I'd love a talk through what react intl does for us and your thought process for how you structured this. I have close to zero i18n experience. YAY LEARNING!!!

@@ -37,3 +37,9 @@
content: "|";
}
}

.link {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, can we namespace our helpers with coa-

@@ -11,7 +12,7 @@ class ListLink extends Component {
<Link
className={ `coa-ListLink ${(isBoxType && "coa-ListLink--boxprimary" )}` }
key={id}
to={url}
to={getPathWithLangCode(url)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you're trying to cover all app links to include language codes when present, but I think trying to manually build links with a helper this way is really fragile. We may forget to use this helper method/it requires a dev to KNOW to use a helper. Some links may come from Joplin's WYSIWYG editors or third party content. Maybe we can build a component wrapper for router Link components that do the language modification. And then devs only have to remember to use Link components for Links and this change is made in 1 place rather than many.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup yup. Agreed on fragile and easy to forget.

For Joplin/3rd party content, I'm not sure that we should intervene and change links in that content. That seems a little unwieldy in a different way. But you're right, it should be a consideration. That type of parsing may also be a responsible we could give to the server. That would do the job more holistically for a world where the authored content goes to many clients, not just Janis.

As far as your suggestion around building a component wrapper for the Link... Are you saying, we write a new component called <Link> that itself imports the react-router-dom version of <Link> and we just move this getPathWithLangCode function into that component? That seems like a solid plan to me. Then the onus on the developer is to remember to import Link from the module we've created instead of from the standard library. Should we call it Link? Or LanguageLink? what do you think?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants