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

I18n for titles #67

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ If you have valid facebook app id, we recommend you configure it to use Facebook
});
```

## I18n

```js
ShareIt.configure({
titles: {
'facebook': function() {return TAPi18n.__('Share on Facebook');},
'googleplus': function() {return TAPi18n.__('Share on Google+');},
'pinterest': function() {return TAPi18n.__('Share on Pinterest');},
'twitter': function() {return TAPi18n.__('Share on Twitter');}
}
});
```

## Roadmap

Expand Down
2 changes: 1 addition & 1 deletion client/views/facebook/facebook.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template name="shareit_facebook">
<a target="_blank" class="{{classes}}{{#if applyColors}} shareit-facebook-colors{{/if}} fb-share" href="#">
<i class="fa fa-facebook{{faClass}} {{faSize}}"></i>
{{#if showText}} Share on Facebook{{/if}}
{{#if showText}} {{titleShareIt "facebook"}} {{/if}}
</a>
</template>
2 changes: 1 addition & 1 deletion client/views/googleplus/googleplus.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template name="shareit_googleplus">
<a class="{{classes}}{{#if applyColors}} shareit-google-colors{{/if}} googleplus-share" href="https://plus.google.com/share?url=#{url}"
onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
<i class="fa fa-google-plus{{faClass}} {{faSize}}"></i>{{#if showText}} Share on Google+{{/if}}
<i class="fa fa-google-plus{{faClass}} {{faSize}}"></i>{{#if showText}} {{titleShareIt "googleplus"}} {{/if}}
</a>
</template>
2 changes: 1 addition & 1 deletion client/views/pinterest/pinterest.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="shareit_pinterest">
<a class="{{classes}}{{#if applyColors}} shareit-pinterest-colors{{/if}} pinterest-share" href="https://www.pinterest.com/pin/create/button/?url={{url}}&media={{media}}&description={{description}}">
<i class="fa fa-pinterest{{faClass}} {{faSize}}"></i>{{#if showText}} Share on Pinterest{{/if}}
<i class="fa fa-pinterest{{faClass}} {{faSize}}"></i>{{#if showText}} {{titleShareIt "pinterest"}} {{/if}}
</a>
</template>
2 changes: 1 addition & 1 deletion client/views/twitter/twitter.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="shareit_twitter">
<a class="{{classes}}{{#if applyColors}} shareit-twitter-colors{{/if}} tw-share" href="https://twitter.com/intent/tweet?url={{url}}&text={{text}}">
<i class="fa fa-twitter{{faClass}} {{faSize}}"></i>{{#if showText}} Share on Twitter{{/if}}
<i class="fa fa-twitter{{faClass}} {{faSize}}"></i>{{#if showText}} {{titleShareIt "twitter"}} {{/if}}
</a>
</template>
12 changes: 11 additions & 1 deletion shareit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ ShareIt = {
iconOnly: false,
faSize: '',
faClass: '',
applyColors: true
applyColors: true,
titles: {
'facebook': 'Share on Facebook',
'googleplus': 'Share on Google+',
'pinterest': 'Share on Pinterest',
'twitter': 'Share on Twitter'
}
},
configure: function(hash) {
return this.settings = $.extend(true, this.settings, hash);
Expand Down Expand Up @@ -55,6 +61,10 @@ ShareIt = {
}
};

Template.registerHelper('titleShareIt', function(name) {
return typeof(ShareIt.settings.titles[name]) == "function" ? ShareIt.settings.titles[name]() : ShareIt.settings.titles[name];
});

ShareIt.init = function(hash) {
this.settings = $.extend(true, this.settings, hash);
window.twttr = (function(d, s, id) {
Expand Down