Browse Source

use Polyglot.js to translate in JS and in HTML templates

master
Msjoinder 11 years ago
parent
commit
5b1ed424c4
  1. 2
      css/style.css
  2. 12
      following.html
  3. 22
      home.html
  4. 1
      index.html
  5. 47
      interface_common.js
  6. 2
      interface_home.js
  7. 226
      interface_localization.js
  8. 2
      interface_login.js
  9. 14
      interface_profile-edit.js
  10. 20
      network.html
  11. 17
      polyglot.min.js
  12. 8
      tmobile.js
  13. 10
      twister_actions.js
  14. 6
      twister_directmsg.js
  15. 8
      twister_following.js
  16. 6
      twister_io.js
  17. 17
      twister_network.js
  18. 18
      twister_user.js

2
css/style.css

@ -443,7 +443,7 @@ button.disabled:hover @@ -443,7 +443,7 @@ button.disabled:hover
{
color: #b43e34;
}
.profile-data li a span
.profile-data li a span.posts-count, .profile-data li a span.following-count, .profile-data li a span.followers-count
{
font-weight: bold;
display: block;

12
following.html

@ -12,6 +12,8 @@ @@ -12,6 +12,8 @@
<script src="jquery.storageapi.js"></script>
<script src="mobile_abstract.js"></script>
<script src="twister_io.js"></script>
<script src="polyglot.min.js"></script>
<script src="interface_localization.js"></script>
<script src="twister_network.js"></script>
<script src="twister_user.js"></script>
<script src="twister_formatpost.js"></script>
@ -347,9 +349,9 @@ @@ -347,9 +349,9 @@
</div>
</div>
<ul class="module profile-data">
<li><a href="#"><span class="posts-count">&nbsp;</span>Posts</a></li>
<li><a href="#" class="open-following-modal"><span class="following-count">&nbsp;</span>Following</a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span>Followers</a></li>
<li><a href="#"><span class="posts-count">&nbsp;</span><span class="label">Posts</span></a></li>
<li><a href="#" class="open-following-modal"><span class="following-count">&nbsp;</span><span class="label">Following</span></a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span><span class="label">Followers</span></a></li>
</ul>
<button class="follow" href="#">Follow</button>
<button class="direct-messages-with-user" href="#">Direct Messages</button>
@ -362,7 +364,7 @@ @@ -362,7 +364,7 @@
<h2>
Posts
<!-- o botão de novas postagens deve ser ocultado quando o usuário clicá-lo via javascript -->
<button class="postboard-news" style="display:none;">5 novos posts</button>
<button class="postboard-news" style="display:none;"></button>
</h2>
<ol id="profile-posts" class="postboard-posts">
@ -382,7 +384,7 @@ @@ -382,7 +384,7 @@
<h2>
Posts
<!-- o botão de novas postagens deve ser ocultado quando o usuário clicá-lo via javascript -->
<button class="postboard-news" style="display:none;">5 novos posts</button>
<button class="postboard-news" style="display:none;"></button>
</h2>
<ol id="profile-posts" class="postboard-posts">

22
home.html

@ -12,6 +12,8 @@ @@ -12,6 +12,8 @@
<script src="jquery.storageapi.js"></script>
<script src="mobile_abstract.js"></script>
<script src="twister_io.js"></script>
<script src="polyglot.min.js"></script>
<script src="interface_localization.js"></script>
<script src="twister_network.js"></script>
<script src="twister_user.js"></script>
<script src="twister_formatpost.js"></script>
@ -106,9 +108,9 @@ @@ -106,9 +108,9 @@
<span class="mini-profile-view">View</span>
</div>
<ul class="module profile-data">
<li><a href="#" class="open-profile-modal"><span class="posts-count">&nbsp;</span>Posts</a></li>
<li><a href="following.html"><span class="following-count">&nbsp;</span>Following</a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span>Followers *</a></li>
<li><a href="#" class="open-profile-modal"><span class="posts-count">&nbsp;</span><span class="label">Posts</span></a></li>
<li><a href="following.html"><span class="following-count">&nbsp;</span><span class="label">Following</span></a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span><span class="label">Followers</span> *</a></li>
</ul>
<div class="post-area">
@ -143,7 +145,7 @@ @@ -143,7 +145,7 @@
<h2>
Postboard
<!-- o botão de novas postagens deve ser ocultado quando o usuário clicá-lo via javascript -->
<button class="postboard-news" style="display: none;">5 novos posts</button>
<button class="postboard-news" style="display: none;"></button>
</h2>
<ol id="posts" class="postboard-posts">
@ -354,9 +356,9 @@ @@ -354,9 +356,9 @@
</div>
</div>
<ul class="module profile-data">
<li><a href="#"><span class="posts-count">&nbsp;</span>Posts</a></li>
<li><a href="#" class="open-following-modal"><span class="following-count">&nbsp;</span>Following</a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span>Followers</a></li>
<li><a href="#"><span class="posts-count">&nbsp;</span><span class="label">Posts</span></a></li>
<li><a href="#" class="open-following-modal"><span class="following-count">&nbsp;</span><span class="label">Following</span></a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span><span class="label">Followers</span></a></li>
</ul>
<button class="follow" href="#">Follow</button>
<button class="direct-messages-with-user" href="#">Direct Messages</button>
@ -369,7 +371,7 @@ @@ -369,7 +371,7 @@
<h2>
Posts
<!-- o botão de novas postagens deve ser ocultado quando o usuário clicá-lo via javascript -->
<button class="postboard-news" style="display:none;">5 novos posts</button>
<button class="postboard-news" style="display:none;"></button>
</h2>
<ol id="profile-posts" class="postboard-posts">
@ -389,7 +391,7 @@ @@ -389,7 +391,7 @@
<h2>
Posts
<!-- o botão de novas postagens deve ser ocultado quando o usuário clicá-lo via javascript -->
<button class="postboard-news" style="display:none;">5 novos posts</button>
<button class="postboard-news" style="display:none;"></button>
</h2>
<ol id="profile-posts" class="postboard-posts">
@ -403,7 +405,7 @@ @@ -403,7 +405,7 @@
<!-- MODAL DE FOLLOWING -->
<div id="following-modal-template">
<!-- ÁREA DE PROFILE PHOTO INIT -->
<h2>All users publicly followed by <span class="following-screen-name">@<b></b></span></h2>
<h2><span class="label">All users publicly followed by<span><span class="following-screen-name">@<b></b></span></h2>
<!-- ÁREA DE PROFILE END -->
<!-- ÁREA DE FOLLOWING INIT -->

1
index.html

@ -22,7 +22,6 @@ @@ -22,7 +22,6 @@
});
</script>
<script src="jquery.mobile-1.3.2.min.js"></script>
<link rel="icon" type="image/png" href="img/twister_mini.png" />
</head>
<body>

47
interface_common.js

@ -48,10 +48,7 @@ function checkNetworkStatusAndAskRedirect(cbFunc, cbArg) { @@ -48,10 +48,7 @@ function checkNetworkStatusAndAskRedirect(cbFunc, cbArg) {
networkUpdate(function(args) {
if( !twisterdConnectedAndUptodate ) {
var redirect =
window.confirm("Local daemon is not connected to the network or\n" +
"block chain is outdated. If you stay in this page\n" +
"your actions may not work.\n" +
"Do you want to check Network Status page instead?");
window.confirm(polyglot.t("switch_to_network"));
if( redirect )
$.MAL.goNetwork();
} else {
@ -73,31 +70,19 @@ function timeSincePost(t) { @@ -73,31 +70,19 @@ function timeSincePost(t) {
var now = new Date();
var t_delta = Math.ceil((now - d) / 1000);
var expression = "";
if(t_delta < 2) {
expression = "1 second"
}
else if(t_delta < 60) {
expression = t_delta + " seconds"
}
else if(t_delta < 120) {
expression = "1 second"
if(t_delta < 60) {
expression = polyglot.t("seconds", { seconds: t_delta });
}
else if(t_delta < 60 * 60) {
expression = Math.floor(t_delta/60) + " minutes"
}
else if(t_delta < 2 * 60 * 60) {
expression = "1 hour"
expression = polyglot.t("minutes", { minutes: Math.floor(t_delta/60) });
}
else if(t_delta < 24 * 60 * 60) {
expression = Math.floor(t_delta/60/60) + " hours"
}
else if(t_delta < 2 * 24 * 60 * 60) {
expression = "1 day"
expression = polyglot.t("hours", { hours: Math.floor(t_delta/60/60) });
}
else {
expression = Math.floor(t_delta/24/60/60) + " days"
expression = polyglot.t("days", { days: Math.floor(t_delta/24/60/60) });
}
return expression + " ago";
return polyglot.t("time_ago", { time: expression });
}
//
@ -127,7 +112,7 @@ function openProfileModal(e) @@ -127,7 +112,7 @@ function openProfileModal(e)
profileModalContent.appendTo("." +profileModalClass + " .modal-content");
//título do modal
$( "."+profileModalClass + " h3" ).text( username + "'s Profile" );
$( "."+profileModalClass + " h3" ).text( polyglot.t("users_profile", { username: username }) );
}
function newHashtagModal(hashtag) {
@ -194,7 +179,7 @@ function openMentionsModal(e) @@ -194,7 +179,7 @@ function openMentionsModal(e)
hashtagModalContent.appendTo("." +hashtagModalClass + " .modal-content");
//título do modal
$( "."+hashtagModalClass + " h3" ).text( "Mentions of @" + username );
$( "."+hashtagModalClass + " h3" ).text( polyglot.t("users_mentions", { username: username }) );
resetMentionsCount();
}
@ -222,7 +207,7 @@ function openFollowingModal(e) @@ -222,7 +207,7 @@ function openFollowingModal(e)
followingModalContent.appendTo("." +followingModalClass + " .modal-content");
//título do modal
$( "."+followingModalClass + " h3" ).text( "Followed by " + username );
$( "."+followingModalClass + " h3" ).text( polyglot.t("followed_by", { username: username }) );
}
//
@ -235,7 +220,7 @@ var reTwistPopup = function( e ) @@ -235,7 +220,7 @@ var reTwistPopup = function( e )
openModal( reTwistClass );
//título do modal
$( ".reTwist h3" ).text( "Retransmit this post to your followers?" );
$( ".reTwist h3" ).text( polyglot.t("retransmit_this") );
var postdata = $(this).parents(".post-data").attr("data-userpost");
var postElem = postToElem($.evalJSON(postdata),"");
@ -252,7 +237,7 @@ var replyInitPopup = function(e, post) @@ -252,7 +237,7 @@ var replyInitPopup = function(e, post)
//título do modal
var fullname = post.find(".post-info-name").text();
$( ".reply h3" ).text( "Reply to " + fullname);
$( ".reply h3" ).text( polyglot.t("reply_to", { fullname: fullname }) );
//para poder exibir a thread selecionada...
var replyModalContent = $(".reply .modal-content").hide();
@ -307,7 +292,7 @@ var postExpandFunction = function( e, postLi ) @@ -307,7 +292,7 @@ var postExpandFunction = function( e, postLi )
originalPost.detach();
postLi.empty();
postLi.addClass( openClass );
$postInteractionText.text( "Collapse" );
$postInteractionText.text( polyglot.t("Collapse") );
var itemOl = $("<ol/>", {class:"expanded-post"}).appendTo(postLi);
var originalLi = $("<li/>", {class: "module post original"}).appendTo(itemOl);
@ -325,7 +310,7 @@ var postExpandFunction = function( e, postLi ) @@ -325,7 +310,7 @@ var postExpandFunction = function( e, postLi )
else
{
postLi.removeClass( openClass );
$postInteractionText.text( "Expand" );
$postInteractionText.text( polyglot.t("Expand") );
if( $postsRelated ) $postsRelated.slideUp( "fast" );
$postExpandedContent.slideUp( "fast", function()
@ -426,7 +411,7 @@ var postSubmit = function(e) @@ -426,7 +411,7 @@ var postSubmit = function(e)
newPostMsg($replyText.val(), $postOrig);
$replyText.val("");
$replyText.attr("placeholder", "Your message was sent!");
$replyText.attr("placeholder", polyglot.t("Your message was sent!"));
closeModal($this);
}
@ -467,4 +452,4 @@ function initInterfaceCommon() { @@ -467,4 +452,4 @@ function initInterfaceCommon() {
$( ".open-hashtag-modal").bind( "click", openHashtagModal );
$( ".open-following-modal").bind( "click", openFollowingModal );
$( ".userMenu-connections a").bind( "click", openMentionsModal );
}
}

2
interface_home.js

@ -23,7 +23,7 @@ var InterfaceFunctions = function() @@ -23,7 +23,7 @@ var InterfaceFunctions = function()
function initHome(cbFunc, cbArg) {
if( !defaultScreenName ) {
alert("Username undefined, login required.");
alert(polyglot.t("username_undefined"));
$.MAL.goLogin();
return;
}

226
interface_localization.js

@ -0,0 +1,226 @@ @@ -0,0 +1,226 @@
// interface_localization.js
//
// uses JavaScript to detect browser language
// uses Polyglot.js ( https://github.com/airbnb/polyglot.js ) to translate interface
// translators: add your language code here such as "es" for Spanish, "ru" for Russian
var knownLanguages = ["en"];
// detect language with JavaScript
var preferredLanguage = window.navigator.userLanguage || window.navigator.language || "en";
if(knownLanguages.indexOf(preferredLanguage) > -1){
// en for en or similar
preferredLanguage = preferredLanguage;
}
else if(knownLanguages.indexOf(preferredLanguage.split("-")[0]) > -1){
// en for en-US or similar
preferredLanguage = preferredLanguage.split("-")[0];
}
else{
// did not find match
preferredLanguage = "en";
}
// set up Polyglot
polyglot = new Polyglot();
var wordset = {};
if(preferredLanguage == "en"){
polyglot.locale("en");
wordset = {
"Actions ▼": "Actions ▼",
"Active DHT nodes:": "Active DHT nodes: ",
"Add DNS": "Add DNS",
"Add peer": "Add peer",
"ajax_error": "Ajax error: %{error}", // JavaScript error
"All users publicly followed by": "All users publicly followed by",
"Available": "Available", // username is available
"Block chain information": "Block chain information",
"Block chain is up-to-date, twister is ready to use!": "Block chain is up-to-date, twister is ready to use!",
"Block generation": "Block generation ",
"Cancel": "Cancel",
"Change user": "Change user",
"Checking...": "Checking...", // checking if username is available
"Collapse": "Collapse", // smaller view of a post
"Configure block generation": "Configure block generation",
"Connections:": "Connections: ", // to network
"Connection lost.": "Connection lost.",
"days": "%{days} day |||| %{days} days",
"Detailed information": "Detailed information",
"DHT network down.": "DHT network down.",
"Direct Messages": "Direct Messages",
"Disable": "Disable",
"Display mentions to @": "Display mentions to @",
"Display retransmissions": "Display retransmissions",
"DNS to obtain list of peers:": "DNS to obtain list of peers:",
"downloading_block_chain": "Downloading block chain, please wait before continuing (block chain is %{days} days old).",
"download_posts_status": "Downloaded %{portion} posts", // Downloaded 10/30 posts
"Enable": "Enable",
"error": "Error: %{error}",
"error_connecting_to_daemon": "Error connecting to local twister daemon.",
"Error in 'createwalletuser' RPC.": "Error in 'createwalletuser' RPC.",
"Error in 'importprivkey'": "Error in 'importprivkey' RPC: %{rpc}",
"Error in 'sendnewusertransaction' RPC.": "Error in 'sendnewusertransaction' RPC.",
"Expand": "Expand", // larger view of a post
"Favorite": "Favorite",
"File APIs not supported in this browser.": "File APIs not supported in this browser.",
"Follow": "Follow",
"Followed by": "Followed by",
"followed_by": "Followed by %{username}",
"Followers": "Followers",
"Following": "Following",
"Following users": "Following users",
"Force connection to peer:": "Force connection to peer:",
"General information": "General information",
"Generate blocks (send promoted messages)": "Generate blocks (send promoted messages)",
"Home": "Home", // homepage
"hours": "%{hours} hour |||| %{hours} hours",
"Internal error: lastPostId unknown (following yourself may fix!)": "Internal error: lastPostId unknown (following yourself may fix!)",
"Known peers:": "Known peers: ",
"Last block is ahead of your computer time, check your clock.": "Last block is ahead of your computer time, check your clock.",
"mentions_at": "Mentions @%{user}",
"minutes": "%{minutes} minute |||| %{minutes} minutes",
"Must be 16 characters or less.": "Must be 16 characters or less.", // username
"Network": "Network",
"Network config": "Network config",
"Network status": "Network status",
"New direct message...": "New direct message...",
"New Post...": "New Post...",
"new_posts": "%{count} new post |||| %{count} new posts",
"nobody": "nobody", // used to promote a post without attaching the user
"Not available": "Not available", // username is not available
"Number of blocks in block chain:": "Number of blocks in block chain: ",
"Number of CPUs to use": "Number of CPUs to use ",
"Only alphanumeric and underscore allowed.": "Only alphanumeric and underscore allowed.",
"peer address": "peer address",
"Private": "Private",
"Profile": "Profile",
"Postboard": "Postboard",
"post": "post", // verb - button to post a message
"Post to promote:": "Post to promote: ",
"Posts": "Posts",
"propagating_nickname": "Propagating nickname %{username} to the network...",
"Public": "Public",
"Refresh": "Refresh",
"retransmit_this": "Retransmit this post to your followers?",
"Reply": "Reply",
"Reply...": "Reply...",
"reply_to": "Reply to %{fullname}",
"Retransmit": "Retransmit",
"Retransmits": "Retransmits",
"Retransmitted by": "Retransmitted by",
"search": "search",
"seconds": "%{seconds} second |||| %{seconds} seconds",
"send": "send",
"Send post with username": "Send post with username ",
"Sent Direct Message": "Sent Direct Message",
"Sent Post to @": "Sent Post to @",
"Setup account": "Setup account",
"switch_to_network": "Local daemon is not connected to the network or\n" +
"block chain is outdated. If you stay in this page\n" +
"your actions may not work.\n" +
"Do you want to check Network Status page instead?",
"The File APIs are not fully supported in this browser.": "The File APIs are not fully supported in this browser.",
"time_ago": "%{time} ago", // 5 minutes ago
"Time of the last block:": "Time of the last block: ",
"Type message here": "Type message here",
"Unfollow": "Unfollow",
"Update": "Update",
"Updating status...": "Updating status...", // status of block chain
"user_not_yet_accepted": "Other peers have not yet accepted this new user.\n" +
"Unfortunately it is not possible to save profile\n" +
"or send any posts in this state.\n\n" +
"Please wait a few minutes to continue.\n\n" +
"The 'Save Changes' will be automatically enabled\n" +
"when the process completes. (I promise this is\n"+
"the last time you will have to wait before using\n" +
"twister).\n\n" +
"Tip: choose your avatar in the meantime!",
"users_mentions": "Mentions of @%{username}",
"users_profile": "%{username}'s Profile",
"username_undefined": "Username undefined, login required.",
"View": "View",
"View All": "View All",
"Who to Follow": "Who to Follow",
"Your message was sent!": "Your message was sent!"
};
}
// translators: sample adding a language
if(preferredLanguage == "ru"){
// polyglot.locale() is used to support plurals
// locales currently known by Polyglot.js:
/*
chinese: ['id', 'ja', 'ko', 'ms', 'th', 'tr', 'zh'],
german: ['da', 'de', 'en', 'es', 'fi', 'el', 'he', 'hu', 'it', 'nl', 'no', 'pt', 'sv'],
french: ['fr', 'tl'],
russian: ['hr', 'ru'],
czech: ['cs'],
polish: ['pl'],
icelandic: ['is']
*/
polyglot.locale("ru");
// list of the English words and translations
wordset = {
"Actions ▼": "Действия ▼" // , comma after each match except the last
};
}
// uncomment to see all translated words replaced with filler
//for(var word in wordset){
// wordset[word] = "AAAA";
//}
polyglot.extend(wordset);
// Text from HTML and not JavaScript is selected and translated at $(document).ready
// Add selectors here to translate the text and placeholders inside new UI
var fixedLabels = [
// An easy way to include new items in translation is to add the "label" class
".label",
// navbar and home
"button",
".userMenu > ul > li > a",
".postboard-news",
".post-area-new textarea",
".refresh-users, .view-all-users",
".who-to-follow h3",
".userMenu-search-field",
"a.dropdown-menu-item, a.direct-messages",
".post-interactions span",
".post-expand",
".post-context span",
".post-stats .stat-count span",
".postboard h2",
// following page
".following h2",
".mini-profile-actions span, .mini-profile-actions li",
// network page
".network h2, .network h3",
".network ul li span",
".network label",
".network textarea, .network input, .network option",
];
$(document).ready(function(){
for(var i=0;i<fixedLabels.length;i++){
var elems = $(fixedLabels[i]);
for(var e=0;e<elems.length;e++){
var content = $.trim($(elems[e]).text());
if(wordset[content]){
$(elems[e]).text( polyglot.t(content) );
}
else{
// uncomment to see translations not found
//console.log(content);
}
if(typeof $(elems[e]).attr("placeholder") != "undefined" && wordset[ $(elems[e]).attr("placeholder")]){
$(elems[e]).attr("placeholder", polyglot.t( $(elems[e]).attr("placeholder") ) );
}
}
}
});

2
interface_login.js

@ -13,7 +13,7 @@ function processCreateUser(username, secretKey) { @@ -13,7 +13,7 @@ function processCreateUser(username, secretKey) {
openModal( newUserClass );
//título do modal
$( "." + newUserClass + " h3" ).text( "Propagating nickname '"+ username + "' to the network..." );
$( "." + newUserClass + " h3" ).text( polyglot.t("propagating_nickname", { username: username }) );
var modalContent = $("." + newUserClass + " .modal-content");
var templateContent = $( "#new-user-modal-template" ).children().clone(true);

14
interface_profile-edit.js

@ -10,7 +10,7 @@ function initProfileEdit() { @@ -10,7 +10,7 @@ function initProfileEdit() {
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
} else {
alert('The File APIs are not fully supported in this browser.');
alert(polyglot.t("The File APIs are not fully supported in this browser."));
}
initInterfaceCommon();
@ -22,7 +22,7 @@ function initProfileEdit() { @@ -22,7 +22,7 @@ function initProfileEdit() {
initUser( function() {
if( !defaultScreenName ) {
alert("Username undefined, login required.");
alert(polyglot.t("username_undefined"));
$.MAL.goLogin();
return;
}
@ -91,15 +91,7 @@ function verifyUserAlreadyInBlockchain() @@ -91,15 +91,7 @@ function verifyUserAlreadyInBlockchain()
});
} else {
if( !newUserWarnDisplayed ) {
alert("Other peers have not yet accepted this new user.\n" +
"Unfortunately it is not possible to save profile\n" +
"or send any posts in this state.\n\n" +
"Please wait a few minutes to continue.\n\n" +
"The 'Save Changes' will be automatically enabled\n" +
"when the process completes. (I promise this is\n"+
"the last time you will have to wait before using\n" +
"twister).\n\n" +
"Tip: choose your avatar in the meantime!");
alert(polyglot.t("user_not_yet_accepted"));
newUserWarnDisplayed = true;
}
setTimeout("verifyUserAlreadyInBlockchain()", 5000);

20
network.html

@ -15,6 +15,8 @@ @@ -15,6 +15,8 @@
<script src="twister_formatpost.js"></script>
<script src="twister_following.js"></script>
<script src="twister_newmsgs.js"></script>
<script src="polyglot.min.js"></script>
<script src="interface_localization.js"></script>
<script src="twister_network.js"></script>
<script src="interface_common.js"></script>
@ -72,17 +74,17 @@ @@ -72,17 +74,17 @@
<div class="wrapper">
<div class="network singleBlock">
<h2> Network status </h2>
<h2>Network status</h2>
<div class="module">
<h3> General information</h3>
<h3>General information</h3>
<ul>
<li>
<span class="network-status highlight connection-status">Updating status...</span>
</li>
</ul>
<h3> Detailed information </h3>
<h3>Detailed information</h3>
<ul>
<li class="connections">
<label>Connections: </label>
@ -108,7 +110,7 @@ @@ -108,7 +110,7 @@
</li>
</ul>
<h3> Block chain information </h3>
<h3>Block chain information</h3>
<ul>
<li>
<label>Number of blocks in block chain:</label>
@ -124,25 +126,25 @@ @@ -124,25 +126,25 @@
<h2>Configure block generation</h2>
<div class="module">
<h3> Generate blocks (send promoted messages)</h3>
<h3>Generate blocks (send promoted messages)</h3>
<ul>
<li>
<label> Block generation </label>
<label>Block generation </label>
<select class="genblock">
<option value="disable">Disable</option>
<option value="enable">Enable</option>
</select>
</li>
<li>
<label> Number of CPUs to use </label>
<label>Number of CPUs to use </label>
<input class="genproclimit" type="textbox" value="1" size="3"/>
</li>
<li>
<label> Post to promote: </label>
<label>Post to promote: </label>
<textarea class="spam-msg" placeholder="Type message here"></textarea>
</li>
<li>
<label> Send post with username </label>
<label>Send post with username </label>
<select class="local-usernames spam-user">
<option value="nobody">nobody</option>
</select>

17
polyglot.min.js vendored

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
// (c) 2012 Airbnb, Inc.
//
// polyglot.js may be freely distributed under the terms of the BSD
// license. For all licensing information, details, and documention:
// http://airbnb.github.com/polyglot.js
//
//
// Polyglot.js is an I18n helper library written in JavaScript, made to
// work both in the browser and in Node. It provides a simple solution for
// interpolation and pluralization, based off of Airbnb's
// experience adding I18n functionality to its Backbone.js and Node apps.
//
// Polylglot is agnostic to your translation backend. It doesn't perform any
// translation; it simply gives you a way to manage translated phrases from
// your client- or server-side JavaScript application.
//
!function(e){"use strict";function t(e){e=e||{},this.phrases=e.phrases||{},this.currentLocale=e.locale||"en",this.allowMissing=!!e.allowMissing}function s(e){var t,n,r,i={};for(t in e)if(e.hasOwnProperty(t)){n=e[t];for(r in n)i[n[r]]=t}return i}function o(e){var t=/^\s+|\s+$/g;return e.replace(t,"")}function u(e,t,r){var i,s,u;return r!=null&&e?(s=e.split(n),u=s[f(t,r)]||s[0],i=o(u)):i=e,i}function a(e){var t=s(i);return t[e]||t.en}function f(e,t){return r[a(e)](t)}function l(e,t){for(var n in t)n!=="_"&&t.hasOwnProperty(n)&&(e=e.replace(new RegExp("%\\{"+n+"\\}","g"),t[n]));return e}function c(t){e.console&&e.console.warn&&e.console.warn("WARNING: "+t)}function h(e){var t={};for(var n in e)t[n]=e[n];return t}t.VERSION="0.2.0",t.prototype.locale=function(e){return e&&(this.currentLocale=e),this.currentLocale},t.prototype.extend=function(e){for(var t in e)e.hasOwnProperty(t)&&(this.phrases[t]=e[t])},t.prototype.clear=function(){this.phrases={}},t.prototype.replace=function(e){this.clear(),this.extend(e)},t.prototype.t=function(e,t){var n;t=t==null?{}:t,typeof t=="number"&&(t={smart_count:t});var r=this.phrases[e]||t._||(this.allowMissing?e:"");return r===""?(c('Missing translation for key: "'+e+'"'),n=e):(t=h(t),n=u(r,this.currentLocale,t.smart_count),n=l(n,t)),n};var n="||||",r={chinese:function(e){return 0},german:function(e){return e!==1?1:0},french:function(e){return e>1?1:0},russian:function(e){return e%10===1&&e%100!==11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},czech:function(e){return e===1?0:e>=2&&e<=4?1:2},polish:function(e){return e===1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},icelandic:function(e){return e%10!==1||e%100===11?1:0}},i={chinese:["id","ja","ko","ms","th","tr","zh"],german:["da","de","en","es","fi","el","he","hu","it","nl","no","pt","sv"],french:["fr","tl"],russian:["hr","ru"],czech:["cs"],polish:["pl"],icelandic:["is"]};typeof module!="undefined"&&module.exports?module.exports=t:e.Polyglot=t}(this);

8
tmobile.js

@ -180,7 +180,7 @@ var router=new $.mobile.Router( @@ -180,7 +180,7 @@ var router=new $.mobile.Router(
var params=router.getParams(match[1]);
initializeTwister( true, true, function() {
var $replyTextarea = $("#newmsg .post-area-new textarea");
$replyTextarea.attr("placeholder", "New Post...");
$replyTextarea.attr("placeholder", polyglot.t("New Post..."));
if( params && params.hasOwnProperty("replyto") ) {
$replyTextarea.val(params.replyto);
} else {
@ -227,7 +227,7 @@ var router=new $.mobile.Router( @@ -227,7 +227,7 @@ var router=new $.mobile.Router(
$newmsgLink.attr("href","#newmsg");
resetMentionsCount();
}
$("#mentions .rtitle").text("Mentions @" + user);
$("#mentions .rtitle").text(polyglot.t("mentions_at", { user: user }));
var $ulMentions = $("#mentions ul.posts");
setupHashtagOrMention( $ulMentions, user, "mention");
});
@ -375,7 +375,7 @@ function installSubmitClick() { @@ -375,7 +375,7 @@ function installSubmitClick() {
newPostMsg(s, $postOrig);
$replyText.val("");
$replyText.attr("placeholder", "Your message was sent!");
$replyText.attr("placeholder", polyglot.t("Your message was sent!"));
setTimeout( function() {$.MAL.goHome();}, 1000);
});
@ -451,7 +451,7 @@ function handleAvatarFileSelectMobile(evt) { @@ -451,7 +451,7 @@ function handleAvatarFileSelectMobile(evt) {
try {
reader = new FileReader();
} catch(e) {
alert('File APIs not supported in this browser.');
alert(polyglot.t('File APIs not supported in this browser.'));
return;
}

10
twister_actions.js

@ -130,9 +130,9 @@ function newPostMsg(msg, $postOrig) { @@ -130,9 +130,9 @@ function newPostMsg(msg, $postOrig) {
twisterRpc("newpostmsg", params,
function(arg, ret) { incLastPostId(); }, null,
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret;
alert("Ajax error: " + msg); }, null);
alert(polyglot.t("ajax_error", { error: msg })); }, null);
} else {
alert("Internal error: lastPostId unknown (following yourself may fix!)");
alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)"));
}
}
@ -150,9 +150,9 @@ function newRtMsg($postOrig) { @@ -150,9 +150,9 @@ function newRtMsg($postOrig) {
twisterRpc("newrtmsg", params,
function(arg, ret) { incLastPostId(); }, null,
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret;
alert("Ajax error: " + msg); }, null);
alert(polyglot.t("ajax_error", { error: msg })); }, null);
} else {
alert("Internal error: lastPostId unknown (following yourself may fix!)");
alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)"));
}
}
@ -214,7 +214,7 @@ function processHashtag(postboard, hashtag, data) { @@ -214,7 +214,7 @@ function processHashtag(postboard, hashtag, data) {
displayHashtagPending(postboard);
} else {
var newTweetsBar = postboard.closest("div").find(".postboard-news");
newTweetsBar.text(String(_hashtagPendingPosts.length) + " new posts");
newTweetsBar.text(polyglot.t("new_posts", { count: _hashtagPendingPosts.length }));
newTweetsBar.fadeIn("slow");
}
}

6
twister_directmsg.js

@ -59,7 +59,7 @@ function requestDmConversation(dmConvo,dm_screenname) { @@ -59,7 +59,7 @@ function requestDmConversation(dmConvo,dm_screenname) {
function(args, ret) { processDmConversation(args.dmConvo, args.dmUser, ret); },
{dmConvo:dmConvo,dmUser:dm_screenname},
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret;
alert("Ajax error: " + msg); }, null);
alert(polyglot.t("ajax_error", { error: msg })); }, null);
}
function processDmConversation(dmConvo, dm_screenname, dmData) {
@ -103,7 +103,7 @@ function newDirectMsg(msg, dm_screenname) { @@ -103,7 +103,7 @@ function newDirectMsg(msg, dm_screenname) {
function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret;
alert("Ajax error: " + msg); }, null);
} else {
alert("Internal error: lastPostId unknown (following yourself may fix!)");
alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)"));
}
}
@ -117,7 +117,7 @@ function directMessagesPopup() @@ -117,7 +117,7 @@ function directMessagesPopup()
$( directMessagesContent ).clone().appendTo( ".directMessages .modal-content" );
//título do modal
$( ".directMessages h3" ).text( "Direct Messages" );
$( ".directMessages h3" ).text( polyglot.t("Direct Messages") );
requestDMsnippetList($(".directMessages").find(".direct-messages-list"));
}

8
twister_following.js

@ -472,9 +472,9 @@ function followingListPublicCheckbox(e) { @@ -472,9 +472,9 @@ function followingListPublicCheckbox(e) {
var public = false;
$this.toggleClass( "private" );
if( $this.hasClass( "private" ) ) {
$this.text( "Private" );
$this.text( polyglot.t("Private") );
} else {
$this.text( "Public" );
$this.text( polyglot.t("Public") );
public = true;
}
@ -507,7 +507,7 @@ function processSwarmProgressFinal(lastHaves, numPieces) @@ -507,7 +507,7 @@ function processSwarmProgressFinal(lastHaves, numPieces)
var $userDiv = $(".mini-profile-info[data-screen-name='" + user + "']");
if( $userDiv.length ) {
var $status = $userDiv.find(".swarm-status");
$status.text("Downloaded " + numPieces[user] + "/" + (lastHaves[user]+1) + " posts");
$status.text(polyglot.t("download_posts_status", { portion: numPieces[user] + "/" + (lastHaves[user]+1) }));
$status.fadeIn();
}
}
@ -535,7 +535,7 @@ function initInterfaceFollowing() { @@ -535,7 +535,7 @@ function initInterfaceFollowing() {
initUser( function() {
if( !defaultScreenName ) {
alert("Username undefined, login required.");
alert(polyglot.t("username_undefined"));
$.MAL.goLogin();
return;
}

6
twister_io.js

@ -290,7 +290,7 @@ function clearAvatarAndProfileCache(username) { @@ -290,7 +290,7 @@ function clearAvatarAndProfileCache(username) {
function getFollowers( username, item ) {
dhtget( username, "tracker", "m",
function(args, ret) {
if( ret.length && ret[0]["followers"] ) {
if( ret && ret.length && ret[0]["followers"] ) {
args.item.text(ret[0]["followers"])
}
}, {username:username,item:item} );
@ -322,7 +322,7 @@ function checkPubkeyExists(username, cbFunc, cbArg) { @@ -322,7 +322,7 @@ function checkPubkeyExists(username, cbFunc, cbArg) {
args.cbFunc(args.cbArg, ret.length > 0);
}, {cbFunc:cbFunc, cbArg:cbArg},
function(args, ret) {
alert("Error connecting to local twister deamon.");
alert(polyglot.t("error_connecting_to_daemon"));
}, {cbFunc:cbFunc, cbArg:cbArg});
}
@ -336,7 +336,7 @@ function dumpPubkey(username, cbFunc, cbArg) { @@ -336,7 +336,7 @@ function dumpPubkey(username, cbFunc, cbArg) {
args.cbFunc(args.cbArg, ret);
}, {cbFunc:cbFunc, cbArg:cbArg},
function(args, ret) {
alert("Error connecting to local twister deamon.");
alert(polyglot.t("error_connecting_to_daemon"));
}, {cbFunc:cbFunc, cbArg:cbArg});
}

17
twister_network.js

@ -27,7 +27,7 @@ function requestNetInfo(cbFunc, cbArg) { @@ -27,7 +27,7 @@ function requestNetInfo(cbFunc, cbArg) {
$(".dht-nodes").text(twisterDhtNodes);
if( !twisterdConnections ) {
$.MAL.setNetworkStatusMsg("Connection lost.", false);
$.MAL.setNetworkStatusMsg(polyglot.t("Connection lost."), false);
twisterdConnectedAndUptodate = false;
}
@ -66,7 +66,7 @@ function addPeerClick() { @@ -66,7 +66,7 @@ function addPeerClick() {
$(".new-peer-addr").val("")
}, {},
function(args, ret) {
alert("Error: " + ret.message);
alert(polyglot.t("error", { error: ret.message }));
}, {});
}
@ -77,7 +77,7 @@ function addDNSClick() { @@ -77,7 +77,7 @@ function addDNSClick() {
$(".new-dns-addr").val("")
}, {},
function(args, ret) {
alert("Error: " + ret.message);
alert(polyglot.t("error", { error: ret.message }));
}, {});
}
@ -112,22 +112,19 @@ function networkUpdate(cbFunc, cbArg) { @@ -112,22 +112,19 @@ function networkUpdate(cbFunc, cbArg) {
var curTime = new Date().getTime() / 1000;
if( twisterdConnections ) {
if( twisterdLastBlockTime > curTime + 3600 ) {
$.MAL.setNetworkStatusMsg("Last block is ahead of your computer time, check your clock.", false);
$.MAL.setNetworkStatusMsg(polyglot.t("Last block is ahead of your computer time, check your clock."), false);
twisterdConnectedAndUptodate = false;
} else if( twisterdLastBlockTime > curTime - (2 * 3600) ) {
if( twisterDhtNodes ) {
$.MAL.setNetworkStatusMsg("Block chain is up-to-date, twister is ready to use!", true);
$.MAL.setNetworkStatusMsg(polyglot.t("Block chain is up-to-date, twister is ready to use!"), true);
twisterdConnectedAndUptodate = true;
} else {
$.MAL.setNetworkStatusMsg("DHT network down.", false);
$.MAL.setNetworkStatusMsg(polyglot.t("DHT network down."), false);
twisterdConnectedAndUptodate = true;
}
} else {
var daysOld = (curTime - twisterdLastBlockTime) / (3600*24);
$.MAL.setNetworkStatusMsg("Downloading block chain, please wait before continuing " +
"(block chain is " +
daysOld.toFixed(2) +
" days old).", false);
$.MAL.setNetworkStatusMsg(polyglot.t("downloading_block_chain", { days: daysOld.toFixed(2) }), false);
twisterdConnectedAndUptodate = false;
}
}

18
twister_user.js

@ -67,7 +67,7 @@ function loadWalletlUsers(cbFunc, cbArg) { @@ -67,7 +67,7 @@ function loadWalletlUsers(cbFunc, cbArg) {
args.cbFunc(args.cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg},
function(args, ret) {
alert("Error connecting to local twister deamon.");
alert(polyglot.t("error_connecting_to_daemon"));
}, {});
}
@ -103,25 +103,25 @@ function checkUsernameAvailability() { @@ -103,25 +103,25 @@ function checkUsernameAvailability() {
if( !username.length )
return;
if( username.length > 16 ) {
$availField.text("Must be 16 characters or less.");
$availField.text(polyglot.t("Must be 16 characters or less."));
return;
}
//Check for non-alphabetic characters and space
if(username.search(/[^a-z0-9_]/) != -1) {
$availField.text("Only alphanumeric and underscore allowed.");
$availField.text(polyglot.t("Only alphanumeric and underscore allowed."));
return;
}
$availField.text("Checking...");
$availField.text(polyglot.t("Checking..."));
dumpPubkey(username, function(dummy, pubkey) {
var notAvailable = pubkey.length > 0
var $availField = $(".availability");
if( notAvailable ) {
$availField.text("Not available");
$availField.text(polyglot.t("Not available"));
} else {
$availField.text("Available");
$availField.text(polyglot.t("Available"));
var $createButton = $(".create-user");
$.MAL.enableButton( $createButton );
@ -147,7 +147,7 @@ function createUserClick(cbFunc) { @@ -147,7 +147,7 @@ function createUserClick(cbFunc) {
args.cbFunc(args.username, ret);
}, {username:username, cbFunc:cbFunc},
function(args, ret) {
alert("Error in 'createwalletuser' RPC.");
alert(polyglot.t("Error in 'createwalletuser' RPC."));
}, {cbFunc:cbFunc});
} else {
// user exists in wallet but transaction not sent
@ -164,7 +164,7 @@ function sendNewUserTransaction(username, cbFunc) { @@ -164,7 +164,7 @@ function sendNewUserTransaction(username, cbFunc) {
args.cbFunc();
}, {cbFunc:cbFunc},
function(args, ret) {
alert("Error in 'sendnewusertransaction' RPC.");
alert(polyglot.t("Error in 'sendnewusertransaction' RPC."));
}, {});
}
@ -190,7 +190,7 @@ function importSecretKeyClick() { @@ -190,7 +190,7 @@ function importSecretKeyClick() {
processNewSecretKeyImported(args.username);
}, {username:username},
function(args, ret) {
alert("Error in 'importprivkey' RPC: " + ret.message);
alert(polyglot.t("Error in 'importprivkey'", {rpc: ret.message }));
}, {});
}

Loading…
Cancel
Save