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

Move translation helper from sidebar to an "alert" box at top of page #1808

Closed
jywarren opened this issue Nov 29, 2017 · 14 comments · Fixed by #2553
Closed

Move translation helper from sidebar to an "alert" box at top of page #1808

jywarren opened this issue Nov 29, 2017 · 14 comments · Fixed by #2553
Labels
enhancement explains that the issue is to improve upon one of our existing features fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute HTML Ruby

Comments

@jywarren
Copy link
Member

This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @jywarren to get it labelled. Or, if this is not your first time, try to solve it yourself!


Please describe the problem (or idea)

This page is now tagged with lang:zh which triggers a Translation widget to appear at the top of the sidebar. But it's not easy to notice.

The code is here:

<div id="google_translate_element"></div><script type="text/javascript">

Solution

Let's move it to the top of the page, into an alert box, using Bootstrap, as in these lines of code:

https://github.com/publiclab/plots2/blob/master/app/views/notes/show.html.erb#L6-L11

@jywarren jywarren added enhancement explains that the issue is to improve upon one of our existing features fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute HTML Ruby labels Nov 29, 2017
@kkavita92
Copy link

I can claim this!

@jywarren
Copy link
Member Author

jywarren commented Nov 30, 2017 via email

@jywarren
Copy link
Member Author

jywarren commented Dec 7, 2017

Hi, just checking if you've gotten stuck on this at all, or if I could help in any way? Thanks!

@tungla
Copy link
Contributor

tungla commented Dec 10, 2017

@jywarren could you show me which screen does the side appear? I'd like to claim this issue

@jywarren
Copy link
Member Author

jywarren commented Dec 10, 2017 via email

@tungla
Copy link
Contributor

tungla commented Dec 11, 2017

is this the correct position the ticket's aiming @jywarren?
image

@jywarren
Copy link
Member Author

jywarren commented Dec 11, 2017 via email

@tungla
Copy link
Contributor

tungla commented Dec 13, 2017

Updated @jywarren. Is that ok?
One problem is i have to use javasciprt to edit HTML of google translate element (to add a span to its div). Is it fine to use this approach?
image

<% if @node && (@node.has_power_tag('iso') || @node.has_power_tag('lang')) %>
    <div id="google_translate_element" class="alert alert-info">
      <script type="text/javascript">
      function googleTranslateElementInit() {
        new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, 'google_translate_element');
        addLabelTranslateElement();
      }
      function addLabelTranslateElement() {
        var paragraph = document.createElement('span');
        paragraph.innerHTML = "Translation: ";
        paragraph.style.fontSize = '125%';
        document.getElementsByClassName("skiptranslate goog-te-gadget")[0].prepend(paragraph);
      }
    </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
  </div>
  <% end %>

@jywarren
Copy link
Member Author

Hmm, interesting! This looks cool -- what does the span add? I also was hoping to get it to display in the main column above the title and main image, but this is looking good! Can you open a pull request with your solution? Thank you!

@jywarren
Copy link
Member Author

Hi, @tungla -- just checking if you're able to open a pull request with this code. Thanks!

@tungla
Copy link
Contributor

tungla commented Jan 10, 2018

Yes @jywarren, gonna open a PR soon, sorry for being late

@jywarren
Copy link
Member Author

no problem! Thanks!

@jywarren jywarren added this to the UI improvements milestone Jan 17, 2018
@raunaks13
Copy link
Contributor

@jywarren - This is my first time contributing. Since this issue has been inactive for a while can I try to submit a PR?

@jywarren
Copy link
Member Author

jywarren commented Mar 28, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement explains that the issue is to improve upon one of our existing features fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute HTML Ruby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants