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

Lets translate texts #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jfgartol
Copy link

Add translation for the titles of the buttons, three sample languages in the source code, english, spanish and french.
some code optimizations for window.open and some repeated html code

Add translation for the titles of the buttons, three sample languages in the source code, english, spanish and french.
some code optimizations for window.open and some repeated html code
Copy link
Collaborator

@shri3k shri3k left a comment

Choose a reason for hiding this comment

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

I like the idea but there are couple of left-over debugging code and lot of formatting issue.

Regarding the formating issues I went ahead and added all the toolings for proper coding standard (we should have done this sooner - so apologies).

If it's not too much trouble then would you mind pulling the develop branch and working off of that? Let me know if there are any issue so that I can help merge this change.

You can run npm run prettier to auto-format all the js code in src/ directory.
You can run npm run lint to check for lint errors. (This should happen automatically when you try to push your changes to remote - this should also check for css lint errors along with js)

Unfortunately, there isn't one css auto-formatter like there is for js so you'd have to manually format css if there are any issues with css files.

}
};
var sharer = new SelectionSharer({elements:'p',lang:'ca',langs:langs});
console.log(sharer);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Even though this is demo file can we get rid of console.log to keep the demo clean?

}
};
var sharer = new SelectionSharer({elements:'p',lang:'ca',langs:langs});
console.log(sharer);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here with console.log

@@ -14,10 +14,32 @@
var SelectionSharer = function(options) {

var self = this;

this.lang = 'en';
this.langs={
Copy link
Collaborator

Choose a reason for hiding this comment

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

The formatting is a bit off here.

'shareOn':'Partagez la sélection sur %s',
'shareByMail':'Partagez la sélection par email',
'quoteFrom':"Citation de "

Copy link
Collaborator

Choose a reason for hiding this comment

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

Might want to get rid of extra line here as well.

options = { elements: options };
options = { elements: options };
if(options.lang)
this.lang=options.lang;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting issue here as well.

if(options.lang)
this.lang=options.lang;
if(options.langs)
this.langs=options.langs;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting.

var top = (screen.height - h) /2 - 100;
window.open(url, name, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
self.hide();
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably needs just 4 space indentation here.

var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2)-100;
window.open(url, "share_twitter", 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
self.windowOpen(url, "share_twitter");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs 4 space indent too.

};

this.shareEmail = function(e) {
var text = self.textSelection.replace(/<p[^>]*>/ig,'\n').replace(/<\/p>| /ig,'').trim();
var email = {};
email.subject = encodeURIComponent("Quote from "+document.title);
email.subject = encodeURIComponent(salf.translate('quoteFrom')+document.title);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably has typo is this supposed to be self?

email.body = encodeURIComponent("“"+text+"”")+"%0D%0A%0D%0AFrom: "+document.title+"%0D%0A"+window.location.href;
$(this).attr("href","mailto:?subject="+email.subject+"&body="+email.body);
self.hide();
return true;
};

this.translate = function(varText,Replace){
// check for illegal language assignement, if lang is not defined uses english by default
Copy link
Collaborator

Choose a reason for hiding this comment

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

Formatting issue in this block also.

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

Successfully merging this pull request may close these issues.

2 participants