Best JavaScript code snippet using storybook-root
index.js
Source:index.js
...53}54function normalKeyboard(chatId, message) {55 util.getLanguage(connection, chatId, function(language) {56 if (language !== true) {57 i18n.setLocale(language);58 } else {59 i18n.setLocale('en');60 }61 fetchUserAccount(chatId, function(response) {62 if (response.length === 0) {63 var bal = "\uD83D\uDCB0" + i18n.__("Balance") + ": " + "\uD83D\uDCB0";64 var invest = i18n.__("Invest") + " \uD83D\uDCB5";65 var withdraw = i18n.__("Withdraw") + " \uD83D\uDCB3";66 var transaction = i18n.__("Transactions") + " \uD83D\uDCB1";67 var order = i18n.__("My Orders") + " \uD83D\uDCBC";68 var referral = i18n.__("Referral System") + " \uD83C\uDFC5";69 var language = i18n.__("Language") + " \uD83C\uDF0D";70 var help = i18n.__("Help");71 var support = i18n.__("Support") + " \u2709";72 var team = i18n.__("My Team") + " \u26BD";73 bot.sendMessage(chatId, message, {74 "reply_markup": {75 "keyboard": [76 [bal + "0.000000BTC"],77 [invest, withdraw],78 [transaction, order],79 [referral, language],80 [support, team]81 ]82 }83 });84 } else {85 var bal = "\uD83D\uDCB0" + i18n.__("Balance") + ": ";86 var invest = i18n.__("Invest") + " \uD83D\uDCB5";87 var withdraw = i18n.__("Withdraw") + " \uD83D\uDCB3";88 var transaction = i18n.__("Transactions") + " \uD83D\uDCB1";89 var order = i18n.__("My Orders") + " \uD83D\uDCBC";90 var referral = i18n.__("Referral System") + " \uD83C\uDFC5";91 var language = i18n.__("Language") + " \uD83C\uDF0D";92 var help = i18n.__("Help");93 var support = i18n.__("Support") + " \u2709";94 var team = i18n.__("My Team") + " \u26BD";95 bot.sendMessage(chatId, message, {96 "reply_markup": {97 "keyboard": [98 [bal + Number(response[0].balance).toFixed(6) + "BTC"],99 [invest, withdraw],100 [transaction, order],101 [referral, language],102 [support, team]103 ]104 }105 });106 }107 });108 });109}110util.on(config.BALANCE_CHANGED, function(balance, user) {111 util.getLanguage(connection, user, function(language) {112 if (language !== true) {113 i18n.setLocale(language);114 } else {115 i18n.setLocale('en');116 }117 util.getOrder(connection, user, function(response) {118 if (response !== true) {119 if (response === 0.02 || response === 0.05 || response === 0.1 || response === 0.5) {120 normalKeyboard(user, i18n.__("Your balance increments daily by 4% for the next 40 days"));121 } else {122 normalKeyboard(user, i18n.__("Your balance increments daily by 6% for the next 40 days"));123 }124 }125 });126 });127});128util.on(config.DAILY_BALANCE_CHANGED, function(balance, user) {129 util.getLanguage(connection, user, function(language) {130 if (language !== true) {131 i18n.setLocale(language);132 } else {133 i18n.setLocale('en');134 }135 normalKeyboard(user, i18n.__("You have earned") + " " + balance + i18n.__("BTC referral bonus."));136 });137});138function updateLanguage(language, chatId) {139 var sql = "update `users` set `language` = '" + language + "' where `chatId` = '" + chatId + "'";140 connection.query(sql, function(err, results) {141 util.getLanguage(connection, chatId, function(language) {142 if (language !== true) {143 i18n.setLocale(language);144 } else {145 i18n.setLocale('en');146 }147 bot.sendMessage(chatId, i18n.__("Crypto Smart Trader offers investors from around the globe favourable conditions to earn in the market of extensive crypto-currency exchange and trading. Our professional team of traders are ready to work round the clock to provide a steady and stable profit while your only effort is to freely register and invest in any of our affordable plans. Our trading platform offers highly profitable investment (up to 240%) to all investors globally, also our extensive experience in the crypto-currency market ensures stable income not just for the company but also to all our global investors.")).then(function(success) {148 var message = i18n.__("Welcome! Community:") + " " + config.COMMUNITY;149 bot.sendMessage(chatId, i18n.__("Your default language has been saved")).then(function(success) {150 normalKeyboard(chatId, message);151 }, function(err) {});152 }, function(err) {});153 });154 });155}156function start(msg, ref_) {157 const chatIdUser = msg.chat.id;158 const name = msg.chat.first_name;159 util.getLanguage(connection, chatIdUser, function(language) {160 if (language !== true) {161 i18n.setLocale(language);162 } else {163 i18n.setLocale('en');164 }165 util.isNewUser(chatIdUser, function(response) {166 if (response === true) {167 util.saveNewUser(msg, connection, bot, ref_);168 } else {169 var response = i18n.__("Welcome back") + " " + name;170 normalKeyboard(chatIdUser, response);171 util.existingOrder(chatIdUser, connection, function(response) {172 if (response !== false) {173 bot.sendMessage(chatIdUser, i18n.__("You have an existing order to make payment of") + " " +174 response[0].amount + i18n.__("BTC to bitcoin address") + " \n" + response[0].address);175 }176 });177 }178 }, connection, bot);179 });180}181bot.on('message', (msg) => {182 chatId = msg.chat.id;183 if (changeCase.lowerCase(msg.text.trim()) === '/start') {184 start(msg);185 }186});187bot.on('message', (msg) => {188 chatId = msg.chat.id;189 util.getLanguage(connection, chatId, function(language) {190 if (language !== true) {191 i18n.setLocale(language);192 } else {193 i18n.setLocale('en');194 }195 if (changeCase.lowerCase(msg.text.trim()).includes("/start ref_")) {196 var text = changeCase.lowerCase(msg.text.trim());197 var array = text.trim().split('/start ref_');198 var response = array.every(emptyArr);199 if (response) {200 start(msg);201 return;202 }203 if (array.length == 2) {204 var invitedBy = array[1];205 invitedBy = Number(invitedBy);206 if (Number.isNaN(invitedBy)) {207 start(msg);208 return;209 } else {210 util.isNewUser(invitedBy, function(response) {211 if (response === true) {212 start(msg);213 return;214 } else {215 util.isNewUser(chatId, function(results) {216 if (results === true) {217 bot.sendMessage(chatId, i18n.__('Invited By') + " " + response[0].nameUser).then(function(value) {218 start(msg, response[0].chatId);219 return;220 }, function(err) {221 });222 } else {223 start(msg);224 return;225 }226 }, connection, bot);227 }228 }, connection, bot);229 }230 } else {231 start(msg);232 return;233 }234 }235 });236});237bot.on('message', (msg) => {238 chatId = msg.chat.id;239 if (msg.text.indexOf("English") === 0) {240 updateLanguage("en", chatId);241 }242});243bot.on('message', (msg) => {244 chatId = msg.chat.id;245 if (msg.text.indexOf("French") === 0) {246 updateLanguage("fr", chatId);247 }248});249bot.on('message', (msg) => {250 chatId = msg.chat.id;251 if (msg.text.indexOf("Spanish") === 0) {252 updateLanguage("es", chatId);253 }254});255bot.on('message', (msg) => {256 chatId = msg.chat.id;257 if (msg.text.indexOf("German") === 0) {258 updateLanguage("de", chatId);259 }260});261bot.on('message', (msg) => {262 util.getLanguage(connection, msg.chat.id, function(language) {263 if (language !== true) {264 i18n.setLocale(language);265 } else {266 i18n.setLocale('en');267 }268 if (i18n.__(msg.text).trim().indexOf(i18n.__("Invest")) === 0 || i18n.__(msg.text).trim().indexOf(i18n.__("invest")) === 0) {269 var message = i18n.__("How much do you want to invest?");270 var menu = i18n.__("Main menu");271 bot.sendMessage(msg.chat.id, message, {272 "reply_markup": {273 "keyboard": [274 ["0.01BTC", "0.02BTC"],275 ["0.05BTC", "0.5BTC"],276 ["0.1BTC", "1BTC"],277 [menu]278 ]279 }280 });281 }282 });283});284bot.on('message', (msg) => {285 util.getLanguage(connection, msg.chat.id, function(language) {286 if (language !== true) {287 i18n.setLocale(language);288 } else {289 i18n.setLocale('en');290 }291 if (changeCase.lowerCase(msg.text.trim()).indexOf("0.01btc") === 0) {292 var message = i18n.__("Pay") + " " + msg.text + " " + i18n.__("to Bitcoin address") + " ";293 util.createOrder(0.01, config.CALLBACK, msg.chat.id, connection, function(order) {294 if (order === false) {295 } else {296 bot.sendMessage(msg.chat.id, message).then(function(success) {297 bot.sendMessage(msg.chat.id, order.address).then(298 function(success) {299 normalKeyboard(msg.chat.id, i18n.__("Money will be on your deposit after three confirmations."));300 },301 function(err) {302 }303 );304 }, function(error) {305 });306 }307 }, client);308 }309 });310});311bot.on('message', (msg) => {312 util.getLanguage(connection, msg.chat.id, function(language) {313 if (language !== true) {314 i18n.setLocale(language);315 } else {316 i18n.setLocale('en');317 }318 if (changeCase.lowerCase(msg.text.trim()).indexOf("0.02btc") === 0) {319 var message = i18n.__("Pay") + " " + msg.text + " " + i18n.__("to Bitcoin address") + " ";320 util.createOrder(0.02, config.CALLBACK, msg.chat.id, connection, function(order) {321 if (order === false) {322 } else {323 bot.sendMessage(msg.chat.id, message).then(function(success) {324 bot.sendMessage(msg.chat.id, order.address).then(325 function(success) {326 normalKeyboard(msg.chat.id, i18n.__("Money will be on your deposit after three confirmations."));327 },328 function(err) {329 }330 );331 }, function(error) {332 });333 }334 }, client);335 }336 });337});338bot.on('message', (msg) => {339 util.getLanguage(connection, msg.chat.id, function(language) {340 if (language !== true) {341 i18n.setLocale(language);342 } else {343 i18n.setLocale('en');344 }345 if (changeCase.lowerCase(msg.text.trim()).indexOf("0.05btc") === 0) {346 var message = i18n.__("Pay") + " " + msg.text + " " + i18n.__("to Bitcoin address") + " ";347 util.createOrder(0.05, config.CALLBACK, msg.chat.id, connection, function(order) {348 if (order === false) {349 } else {350 bot.sendMessage(msg.chat.id, message).then(function(success) {351 bot.sendMessage(msg.chat.id, order.address).then(352 function(success) {353 normalKeyboard(msg.chat.id, i18n.__("Money will be on your deposit after three confirmations."));354 },355 function(err) {356 }357 );358 }, function(error) {359 });360 }361 }, client);362 }363 });364});365bot.on('message', (msg) => {366 util.getLanguage(connection, msg.chat.id, function(language) {367 if (language !== true) {368 i18n.setLocale(language);369 } else {370 i18n.setLocale('en');371 }372 if (changeCase.lowerCase(msg.text.trim()).indexOf("0.1btc") === 0) {373 var message = i18n.__("Pay") + " " + msg.text + " " + i18n.__("to Bitcoin address") + " ";374 util.createOrder(0.1, config.CALLBACK, msg.chat.id, connection, function(order) {375 if (order === false) {376 } else {377 bot.sendMessage(msg.chat.id, message).then(function(success) {378 bot.sendMessage(msg.chat.id, order.address).then(379 function(success) {380 normalKeyboard(msg.chat.id, i18n.__("Money will be on your deposit after three confirmations."));381 },382 function(err) {383 }384 );385 }, function(error) {386 });387 }388 }, client);389 }390 });391});392bot.on('message', (msg) => {393 util.getLanguage(connection, msg.chat.id, function(language) {394 if (language !== true) {395 i18n.setLocale(language);396 } else {397 i18n.setLocale('en');398 }399 if (changeCase.lowerCase(msg.text.trim()).indexOf("0.5btc") === 0) {400 var message = i18n.__("Pay") + " " + msg.text + " " + i18n.__("to Bitcoin address") + " ";401 util.createOrder(0.5, config.CALLBACK, msg.chat.id, connection, function(order) {402 if (order === false) {403 } else {404 bot.sendMessage(msg.chat.id, message).then(function(success) {405 bot.sendMessage(msg.chat.id, order.address).then(406 function(success) {407 normalKeyboard(msg.chat.id, i18n.__("Money will be on your deposit after three confirmations."));408 },409 function(err) {410 }411 );412 }, function(error) {413 });414 }415 }, client);416 }417 });418});419bot.on('message', (msg) => {420 util.getLanguage(connection, msg.chat.id, function(language) {421 if (language !== true) {422 i18n.setLocale(language);423 } else {424 i18n.setLocale('en');425 }426 if (changeCase.lowerCase(msg.text.trim()).indexOf("1btc") === 0) {427 var message = i18n.__("Pay") + " " + msg.text + " " + i18n.__("to Bitcoin address") + " ";428 util.createOrder(1, config.CALLBACK, msg.chat.id, connection, function(order) {429 if (order === false) {430 } else {431 bot.sendMessage(msg.chat.id, message).then(function(success) {432 bot.sendMessage(msg.chat.id, order.address).then(433 function(success) {434 normalKeyboard(msg.chat.id, i18n.__("Money will be on your deposit after three confirmations."));435 },436 function(err) {437 }438 );439 }, function(error) {440 });441 }442 }, client);443 }444 });445});446bot.on('message', (msg) => {447 util.getLanguage(connection, msg.chat.id, function(language) {448 if (language !== true) {449 i18n.setLocale(language);450 } else {451 i18n.setLocale('en');452 }453 if (changeCase.lowerCase(msg.text.trim()).indexOf("2btc") === 0) {454 var message = i18n.__("Pay") + " " + msg.text + " " + i18n.__("to Bitcoin address") + " ";455 util.createOrder(2, config.CALLBACK, msg.chat.id, connection, function(order) {456 if (order === false) {457 } else {458 bot.sendMessage(msg.chat.id, message).then(function(success) {459 bot.sendMessage(msg.chat.id, order.address).then(460 function(success) {461 normalKeyboard(msg.chat.id, i18n.__("Money will be on your deposit after three confirmations."));462 },463 function(err) {464 }465 );466 }, function(error) {467 });468 }469 }, client);470 }471 });472});473bot.on('message', (msg) => {474 util.getLanguage(connection, msg.chat.id, function(language) {475 if (language !== true) {476 i18n.setLocale(language);477 } else {478 i18n.setLocale('en');479 }480 if (changeCase.lowerCase(i18n.__(msg.text).trim()).indexOf(i18n.__("withdraw")) === 0) {481 var user = msg.chat.id;482 util.getAccount(user, connection, function(account) {483 if (account === true) {484 var message = i18n.__("Your main balance is low. Please invest.");485 bot.sendMessage(user, message);486 } else if (account !== true) {487 if (account.status === config.FROZEN) {488 var message = i18n.__("Your main balance is low. Please invest.");489 bot.sendMessage(user, message);490 } else if (account.status === config.ACTIVE) {491 var message = i18n.__("Total balance is") + " \n" + account.balance + "BTC";492 bot.sendMessage(user, message).then(493 function() {494 parseBTCResponse(user, account);495 },496 function() {497 }498 );499 }500 }501 });502 }503 });504});505bot.on('message', (msg) => {506 util.getLanguage(connection, msg.chat.id, function(language) {507 if (language !== true) {508 i18n.setLocale(language);509 } else {510 i18n.setLocale('en');511 }512 if (changeCase.lowerCase(i18n.__(msg.text).trim()).includes(i18n.__("balance"))) {513 var user = msg.chat.id;514 util.getAccount(user, connection, function(account) {515 if (account === true) {516 normalKeyboard(user, i18n.__("Your account no longer exist!"));517 } else {518 bot.sendMessage(user, i18n.__("Your total balance is") + " " + account.balance + "BTC").then(function(msg) {519 bot.sendMessage(user, i18n.__("Balance available for withdraw is") + " " + account.dailyMax + "BTC");520 }, function(err) {});521 }522 });523 }524 });525});526bot.on('message', (msg) => {527 util.getLanguage(connection, msg.chat.id, function(language) {528 if (language !== true) {529 i18n.setLocale(language);530 } else {531 i18n.setLocale('en');532 }533 if (changeCase.lowerCase(i18n.__(msg.text).trim()).includes(i18n.__("my orders"))) {534 var user = msg.chat.id;535 util.existingOrder(user, connection, function(response) {536 if (response === false) {537 normalKeyboard(user, i18n.__("You have no pending orders"));538 } else {539 bot.sendMessage(user, i18n.__("You have an existing order to make payment of") + " " + response[0].amount + i18n.__("BTC to bitcoin address:")).then(function(msg) {540 normalKeyboard(user, response[0].address);541 }, function(err) {});542 }543 });544 }545 });546});547bot.on('message', (msg) => {548 util.getLanguage(connection, msg.chat.id, function(language) {549 if (language !== true) {550 i18n.setLocale(language);551 } else {552 i18n.setLocale('en');553 }554 if (changeCase.lowerCase(i18n.__(msg.text).trim()).includes(i18n.__("transactions"))) {555 var user = msg.chat.id;556 util.getTransaction(user, connection, function(results) {557 if (results === false) {558 bot.sendMessage(user, i18n.__("You have performed no transaction yet!"));559 } else {560 results.forEach(function(element, index, array) {561 var transaction = element;562 var verb = transaction.verb;563 var date = transaction.date;564 date = moment.unix(date).format("MM/DD/YYYY");565 var transactionJson = transaction.transaction;566 transaction = JSON.parse(transactionJson);567 if (verb === config.NEW_PAYMENT) {568 bot.sendMessage(user, i18n.__("You made a payment of") + " <b>" + transaction.amount + "BTC</b> " + i18n.__("to bitcoin address:") + " \n <b>" +569 transaction.address + "\n </b> on " + date, { parse_mode: "HTML" });570 } else if (verb === config.NEW_WITHDRAWAL) {571 bot.sendMessage(user, i18n.__("You made a withdrawal of") + " <b>" + transaction.amount + "BTC</b> " + i18n.__("to bitcoin address:") + " \n <b>" +572 transaction.address + "\n </b> " + i18n.__("on") + " " + date, { parse_mode: "HTML" });573 }574 });575 }576 });577 }578 });579});580bot.on('message', (msg) => {581 util.getLanguage(connection, msg.chat.id, function(language) {582 if (language !== true) {583 i18n.setLocale(language);584 } else {585 i18n.setLocale('en');586 }587 if (changeCase.lowerCase(i18n.__(msg.text).trim()).includes(i18n.__("referral system"))) {588 var user = msg.chat.id;589 util.isNewUser(user, function(response) {590 if (response === true) {591 } else {592 var me = response[0];593 bot.sendMessage(user, i18n.__("You will earn affiliate commissions up to three levels(8%, 4% and 2%) of any invest and reinvest of members referred.")).then(function(msg) {594 bot.sendMessage(user, i18n.__("Your referral link is") + " \n https://t.me/cryptosmart_bot?start=ref_" + me.chatId);595 }, function(err) {596 });597 }598 }, connection, bot);599 }600 });601});602bot.on('message', (msg) => {603 util.getLanguage(connection, msg.chat.id, function(language) {604 if (language !== true) {605 i18n.setLocale(language);606 } else {607 i18n.setLocale('en');608 }609 if (changeCase.lowerCase(i18n.__(msg.text).trim()).includes(i18n.__("language"))) {610 var user = msg.chat.id;611 var menu = i18n.__("Main menu");612 var message = i18n.__("Choose your default language");613 bot.sendMessage(msg.chat.id, message, {614 "reply_markup": {615 "keyboard": [616 ["English"],617 ["German"],618 ["French"],619 ["Spanish"],620 [menu]621 ]622 }623 });624 }625 });626});627bot.on('message', (msg) => {628 util.getLanguage(connection, msg.chat.id, function(language) {629 if (language !== true) {630 i18n.setLocale(language);631 } else {632 i18n.setLocale('en');633 }634 if (changeCase.lowerCase(i18n.__(msg.text).trim()).includes(i18n.__("support"))) {635 var user = msg.chat.id;636 var message = i18n.__("Write to our 24/7 support mail") + " " + config.EMAIL + "\n Live Chat: https://cryptosmartbot.com";637 normalKeyboard(user, message);638 }639 });640});641bot.on('message', (msg) => {642 util.getLanguage(connection, msg.chat.id, function(language) {643 if (language !== true) {644 i18n.setLocale(language);645 } else {646 i18n.setLocale('en');647 }648 if (changeCase.lowerCase(i18n.__(msg.text).trim()).includes(i18n.__("my team"))) {649 var user = msg.chat.id;650 util.myTeam(connection, user, function(active, inactive) {651 var message = "You have " + active + " active referral and " + inactive + " inactive referral";652 normalKeyboard(user, message);653 });654 }655 });656});657bot.on('message', (msg) => {658 util.getLanguage(connection, msg.chat.id, function(language) {659 if (language !== true) {660 i18n.setLocale(language);661 } else {662 i18n.setLocale('en');663 }664 if (changeCase.lowerCase(i18n.__(msg.text).trim()) === i18n.__("help")) {665 var user = msg.chat.id;666 var message = i18n.__("Select from the menu");667 var howW = i18n.__("How to withdraw");668 var howR = i18n.__("How does referral work");669 var howS = i18n.__("How does Smart Trader work");670 var menu = i18n.__("Main menu");671 bot.sendMessage(chatId, message, {672 "reply_markup": {673 "keyboard": [674 [howW],675 [howR],676 [howS],677 [menu]678 ]679 }680 });681 }682 });683});684bot.on('message', (msg) => {685 util.getLanguage(connection, msg.chat.id, function(language) {686 if (language !== true) {687 i18n.setLocale(language);688 } else {689 i18n.setLocale('en');690 }691 if (changeCase.lowerCase(i18n.__(msg.text).trim()) === i18n.__("how does smart trader work")) {692 var user = msg.chat.id;693 var message = i18n.__("We use your money on digital asset exchange and trading and help grow it within a short period of time and invest in stock market. \n\t We ensure good security by using technical analysis in our trading Platforms.\n\t We are in full control of your investments. We take actions and ensures that we make profits from your trading.\n\t Due to the profits and technical trading of our investors funds and high return nature of our investments, we are able to offer our clients a high-returning safe investment");694 bot.sendMessage(user, message);695 }696 });697});698bot.on('message', (msg) => {699 util.getLanguage(connection, msg.chat.id, function(language) {700 if (language !== true) {701 i18n.setLocale(language);702 } else {703 i18n.setLocale('en');704 }705 if (changeCase.lowerCase(i18n.__(msg.text).trim()) === i18n.__("how does referral work")) {706 var user = msg.chat.id;707 var message = i18n.__("Use your referral link to invite people. Your balance is credited with the five dollar equivalent of bitcoin when the person you invite successfully completes an order. Referral money is added to your daily withdrawal.") + " \n" +708 "https://t.me/mata908_bot?start=ref_" + user;709 bot.sendMessage(user, message);710 }711 });712});713bot.on('message', (msg) => {714 util.getLanguage(connection, msg.chat.id, function(language) {715 if (language !== true) {716 i18n.setLocale(language);717 } else {718 i18n.setLocale('en');719 }720 if (changeCase.lowerCase(i18n.__(msg.text).trim()) === i18n.__("how to withdraw")) {721 var user = msg.chat.id;722 bot.sendMessage(user, i18n.__("Please watch the video to show you how it works")).then(function(suc) {723 bot.sendVideo(user, __dirname + '/assets/tutorial-1.mp4');724 bot.sendChatAction(user, 'upload_video');725 }, function(err) {});726 }727 });728});729bot.on('message', (msg) => {730 util.getLanguage(connection, msg.chat.id, function(language) {731 if (language !== true) {732 i18n.setLocale(language);733 } else {734 i18n.setLocale('en');735 }736 if (changeCase.lowerCase(i18n.__(msg.text).trim()) === i18n.__("main menu")) {737 var user = msg.chat.id;738 var message = i18n.__("Welcome back") + " " + msg.chat.first_name;739 normalKeyboard(user, message);740 }741 });742});743function parseBTCResponse(user, account) {744 util.getLanguage(connection, user, function(language) {745 if (language !== true) {746 i18n.setLocale(language);747 } else {748 i18n.setLocale('en');749 }750 var message = i18n.__("Money available for withdraw is") + "\n" + account.dailyMax + "BTC";751 bot.sendMessage(user, message).then(function() {752 var message = i18n.__("How much BTC do you want to withdraw?") + "\n <i>" + i18n.__("Tip: Send your response by sending a direct reply to this message.") + "</i>";753 bot.sendMessage(user, message, {754 reply_markup: JSON.stringify({755 hide_keyboard: true,756 }),757 parse_mode: "HTML"758 }).then(function(msg) {759 bot.onReplyToMessage(msg.chat.id, msg.message_id, function(msg) {760 var amount = Number(msg.text);761 if (Number.isNaN(amount)) {762 bot.sendMessage(user, i18n.__("Invalid response")).then(function(msg) {763 parseBTCResponse(user, account);764 }, function(err) {765 });766 } else {767 if (account.dailyMax >= amount) {768 processPayment(user, amount);769 } else if (account.dailyMax < amount) {770 parseBTCResponse(user, account);771 }772 }773 });774 }, function(err) {775 });776 }, function() {777 });778 });779}780function processPayment(user, amount) {781 util.getLanguage(connection, user, function(language) {782 if (language !== true) {783 i18n.setLocale(language);784 } else {785 i18n.setLocale('en');786 }787 var opts = {788 reply_markup: JSON.stringify({789 hide_keyboard: true,790 }),791 parse_mode: "HTML"792 };793 bot.sendMessage(user, i18n.__("Enter your bitcoin wallet address") + " \n <i>" + i18n.__("Tip: Send your response by sending a direct reply to this message.") + "</i>", opts).then(794 function(msg) {795 bot.onReplyToMessage(user, msg.message_id, function(msg) {796 if (util.validateBitcoinAddress(msg.text.trim())) {797 var address = msg.text.trim();798 bot.sendMessage(user, i18n.__("You are about to transfer") + " <b>" + amount + "BTC</b>" + " " + i18n.__("to bitcoin wallet address") + " \n<b>" +799 msg.text.trim() +...
public_route.js
Source:public_route.js
...15 // If the locale is not en or fr16 if (locale && (locale !== 'fr' && locale !== 'en' && locale !== 'default')) {17 log('incorrect locale: %o, use %o', locale, 'fr');18 locale = 'fr';19 userManager.setLocale(locale);20 defer.reject({21 cause: 'incorrect-locale',22 params: {23 locale24 }25 });26 }27 // If the locale is not defined in the route28 if (locale === 'default' || !locale) {29 locale = sessionManager.getLocale();30 if (!locale) {31 locale = 'fr';32 sessionManager.setLocale(locale);33 }34 if (this.parent.self.name !== 'public') { // eslint-disable-line35 params = $stateParams ? $stateParams : {};36 params.locale = locale;37 defer.reject({38 cause: 'missing-locale',39 params: {40 state: 'public.' + prepend + this.self.name, // eslint-disable-line41 locale42 }43 });44 log('missing locale, redirect to %o with locale: %o', 'public.' +45 prepend + this.self.name, params.locale); // eslint-disable-line46 }47 }48 if (locale !== sessionManager.getLocale()) {49 userManager.setLocale(locale);50 }51 $rootScope.locale = locale;52 defer.resolve(locale);53 return defer.promise;54 }55 ];56 const categories = (Help) => Help.categories({locale: 'fr'}).$promise;57 return $stateProvider58 .state('public', {})59 .state('base', {60 url: '/?email&password',61 resolve: {62 locale: setLocale63 }...
filter.js
Source:filter.js
...7var it_words_list = require('../../seed/it.js');8var it_words = it_words_list();9describe('#setLocale tests', function(){10 it('Should correctly set and populate en-base when no locale is passed', function(){11 assert.doesNotThrow(function(){filter.setLocale()}, 'Error', 'Verified setLocale does not throw error with empty params');12 filter.setLocale();13 var dict = filter.getDictionary();14 assert.equal(dict.length, en_words.length, 'Verified that without params setLocale inits dictionary as en-base')15 });16 it('Should correctly set and populate when a single locale is passed', function(){17 assert.doesNotThrow(function(){filter.setLocale(['fr'])}, 'Error', 'Verified setLocale does not throw error with empty params');18 filter.setLocale(['fr']);19 var dict = filter.getDictionary();20 assert.equal(dict.length, fr_words.length, 'Verified that with single element setLocale inits dictionary correctly'); 21 });22 it('Should correctly set and populate when multiple valid locales are passed', function(){23 assert.doesNotThrow(function(){filter.setLocale(['fr','it'])}, 'Error', 'Verified setLocale does not throw error with empty params');24 filter.setLocale(['fr', 'it']);25 var dict = filter.getDictionary();26 assert.equal(dict.length, fr_words.length + it_words.length, 'Verified that with multiple element setLocale inits dictionary correctly'); 27 });28 it('Should throw an error when invalid datatype input such as string is passed', function(){29 assert.throws(function(){filter.setLocale('frx')}, "Input to locale should be an array. Eg. ['fr']")30 });31 32 it('Should throw an error when invalid datatype input such as number is passed', function(){33 assert.throws(function(){filter.setLocale(10)}, "Input to locale should be an array. Eg. ['fr']")34 });35 36 it('Should throw an error when unsupported locale is passed', function(){37 assert.throws(function(){filter.setLocale(['fr', 'xoxo'])}, "Invalid locale supplied to setLocale function. Please supply valid locales including : ar,cs,da,de,en-base,en-uk,en-us,eo,es,fa,fi,fr,hi,hu,it,ja,ko,nl,no,pl,pt,ru,sv,th,tlh,tr,zh")38 });39});40describe('#showAvailableLocales tests', function(){41 42 it('Should not throw error when called', function(){43 44 assert.doesNotThrow(function(){45 filter.showAvailableLocales()46 }, 'Error', 'Verified that showAvailableLocales does not throw an error');47 });48 it('Should return array of supported locales', function(){49 var supportedLocales = filter.showAvailableLocales();50 assert.isAbove(supportedLocales.length, 0, 'Verified that showAvailableLocales returns a list of supported locales');51 }); 52});53describe('#getLocale tests', function(){54 it('Should return locale when a locale has been set', function(){55 filter.setLocale(['fr', 'en-uk']);56 var locales = filter.getLocale();57 assert.deepEqual(locales, ['fr', 'en-uk'], 'Verified that getLocales works as expected'); 58 });59 it('Should throw an error whe locale is not set', function(){60 61 assert.throws(function(){filter.setLocale(10)}, "Input to locale should be an array. Eg. ['fr']")62 assert.throws(function(){filter.getLocale()}, "It appears that locale is not set. Perhaps you forgot to call setLocale ?")63 });64});65describe('#getDictionary tests', function(){66 it('Should return an array of words currently loaded on dictionary', function(){67 assert.doesNotThrow(function(){filter.setLocale()}, 'Error', 'Verified setLocale does not throw error with empty params');68 filter.setLocale();69 var dict = filter.getDictionary();70 assert.equal(dict.length, en_words.length, 'Verified that without params setLocale inits dictionary as en-base')71 });72 it('Should return an empty array when setLocale does not set the dictionary', function(){73 74 assert.throws(function(){filter.setLocale(10)}, "Input to locale should be an array. Eg. ['fr']");75 var dict = filter.getDictionary();76 assert.equal(dict.length, 0, 'Verified that dictionary is empty when setLocale throws error or is not called correctly');77 });78});79describe('#addWords tests', function(){80 it('Should add word to the dictionary for valid input', function(){81 filter.setLocale();82 filter.addWords(["peaceandlovearenotbadwords", "sharingandcaringisawesome", "youonlyliveonce"]);83 var dict = filter.getDictionary();84 assert.include(dict, "peaceandlovearenotbadwords", 'Verified that newly added word one is in dictionary')85 assert.include(dict, "sharingandcaringisawesome", 'Verified that newly added word two is in dictionary')86 assert.include(dict, "youonlyliveonce", 'Verified that newly added word three is in dictionary')87 });88 it('Should do nothing when empty input array is passed', function(){89 filter.setLocale();90 var dict = filter.getDictionary();91 filter.addWords([]);92 var newDict = filter.getDictionary();93 assert.equal(dict.length, newDict.length, 'Verified that adding empty array does nothing');94 });95 it('Should throw an error for invalid inputs', function(){96 filter.setLocale();97 assert.throws(function(){filter.addWords(1)}, "Input word array should be of a type array. Eg. ['a', 'man']")98 assert.throws(function(){filter.addWords()}, "Input word array should be of a type array. Eg. ['a', 'man']")99 assert.throws(function(){filter.addWords("oho")}, "Input word array should be of a type array. Eg. ['a', 'man']")100 });101});102describe('#removeWords test', function(){103 104 it('Should remove word if it finds one from the dictionary', function(){105 filter.setLocale();106 filter.addWords(["itsawonderfullife"])107 var dict = filter.getDictionary();108 assert.include(dict, "itsawonderfullife", 'Verified that newly added word one is in dictionary')109 filter.removeWords("itsawonderfullife")110 dict = filter.getDictionary();111 assert.notInclude(dict, "itsawonderfullife", "Verified that the said word has been removed from dictionary")112 });113 114 it('Should do nothing to remove word if nothing is passed', function(){115 filter.setLocale();116 var oriDict = filter.getDictionary();117 assert.doesNotThrow(function(){filter.removeWords()}, 'Error', 'removeWords does nothing with no params are passed to it');118 var dict = filter.getDictionary();119 assert.equal(oriDict.length, dict.length, 'Verified the removeWords does nothing when no params are passed'); 120 });121 it('Should do nothing to remove word if it does not find one from the dictionary', function(){122 filter.setLocale();123 var oriDict = filter.getDictionary();124 assert.doesNotThrow(function(){filter.removeWords("jaimaharashtra")}, 'Error', 'removeWords does nothing with no params are passed to it');125 var dict = filter.getDictionary();126 assert.equal(oriDict.length, dict.length, 'Verified the removeWords does nothing when no params are passed'); 127 });128});129describe('#showReplacementPatterns', function(){130 it('Should sow replacement patterns', function(){131 var repPat = filter.showReplacementPatterns();132 assert.deepEqual(repPat, ['character', 'grawlix', 'word'], 'Verified that showReplacementPatterns works as expected');133 });...
policies.js
Source:policies.js
1/**2 * Policy Mappings3 * (sails.config.policies)4 *5 * Policies are simple functions which run **before** your controllers.6 * You can apply one or more policies to a given controller, or protect7 * its actions individually.8 *9 * Any policy file (e.g. `api/policies/authenticated.js`) can be accessed10 * below by its filename, minus the extension, (e.g. "authenticated")11 *12 * For more information on how policies work, see:13 * http://sailsjs.org/#/documentation/concepts/Policies14 *15 * For more information on configuring policies, check out:16 * http://sailsjs.org/#/documentation/reference/sails.config/sails.config.policies.html17 */18module.exports.policies = {19 /***************************************************************************20 * *21 * Neeedo WebApp policies *22 * *23 * *24 ***************************************************************************/25 IndexController: {26 'index': ['resetUploadedFiles', 'setLocale', 'setRedirectUrl']27 },28 MessageController: {29 '*' : false,30 'create': ['setLocale', 'isLoggedIn'],31 'mailbox': ['setLocale', 'setRedirectUrl', 'isLoggedIn'],32 'viewMessage': ['setLocale', 'setRedirectUrl', 'isLoggedIn'],33 'ajaxGetUnreadMessagesCount':['isLoggedIn'],34 'ajaxLoadMessagesByConversation':['isLoggedIn']35 },36 FavoritesController: {37 '*' : false,38 'favoritesList': ['setLocale', 'setRedirectUrl', 'isLoggedIn'],39 'ajaxToggleFavorite':['isLoggedIn']40 },41 OfferController: {42 '*' : false,43 'view': ['setLocale', 'setRedirectUrl'],44 'ajaxGet': ['setLocale'],45 'ajaxGetSingle': ['setLocale'],46 'create': ['setLocale', 'setRedirectUrl', 'isLoggedIn'],47 'edit': ['setLocale', 'setRedirectUrl', 'isLoggedIn'],48 'delete': ['resetUploadedFiles', 'setLocale', 'setRedirectUrl', 'isLoggedIn']49 },50 DemandController: {51 '*' : false,52 'view' : ['setLocale', 'setRedirectUrl'],53 'ajaxGet': ['setLocale'],54 'create': ['setLocale', 'setRedirectUrl', 'isLoggedIn'],55 'edit': ['setLocale', 'setRedirectUrl', 'isLoggedIn'],56 'delete': ['resetUploadedFiles', 'setLocale', 'setRedirectUrl', 'isLoggedIn'],57 'matching': ['resetUploadedFiles', 'setLocale', 'setRedirectUrl', 'isLoggedIn'],58 'ajaxMatching': ['resetUploadedFiles', 'setLocale', 'isLoggedIn']59 },60 UserController: {61 '*': ['resetUploadedFiles', 'setLocale', 'isLoggedIn'],62 'ajaxGetOffers' : ['resetUploadedFiles', 'setLocale', 'isLoggedIn'],63 'ajaxGetDemands' : ['resetUploadedFiles', 'setLocale', 'isLoggedIn'],64 // setLocale can be accessed public and logged-in65 'setLocale': ['resetUploadedFiles', 'setLocale'],66 'dashboard': ['resetUploadedFiles', 'setLocale', 'isLoggedIn', 'setRedirectUrl']67 },68 LoginController: {69 '*': ['resetUploadedFiles', 'setLocale', false], // default policy for login controller actions70 'login' : ['resetUploadedFiles', 'setLocale', 'isNotLoggedIn'],71 'logout' : ['resetUploadedFiles', 'setLocale', 'isLoggedIn']72 },73 RegistrationController: {74 '*': ['resetUploadedFiles', 'setLocale', false], // default policy for registration controller actions75 'register' : ['resetUploadedFiles', 'setLocale', 'isNotLoggedIn', 'setRedirectUrl']76 },77 StaticViewsController: {78 '*' : ['setLocale', 'setRedirectUrl'],79 'help' : ['setLocale', 'isLoggedIn']80 },81 FileController: {82 '*' : false,83 'upload' : ['hasValidFileType', 'setLocale', 'isLoggedIn'],84 'uploadAjax' : ['hasValidFileType', 'setLocale', 'isLoggedIn']85 }...
lang.js
Source:lang.js
...20import {getLocale as getDateLocale} from '../date';21import {_, setLocale, getLocale, onLanguageChange, _l} from '../lang';22describe('setLocale tests', () => {23 test('should change the i18n locale', () => {24 setLocale('en');25 expect(getLocale()).toEqual('en');26 setLocale('de');27 expect(getLocale()).toEqual('de');28 });29 test('should allow to use en-US for en', () => {30 setLocale('en');31 expect(getLocale()).toEqual('en');32 setLocale('de-CH');33 expect(getLocale()).toEqual('de-CH');34 });35 test('should fallback to en for unknown locales', () => {36 setLocale('en');37 expect(getLocale()).toEqual('en');38 setLocale('foo');39 expect(getLocale()).toEqual('en');40 });41 test('should notify language change listeners', () => {42 const callback = jest.fn();43 setLocale('en');44 expect(getLocale()).toEqual('en');45 const unsubscribe = onLanguageChange(callback);46 expect(isFunction(unsubscribe)).toEqual(true);47 setLocale('de');48 expect(getLocale()).toEqual('de');49 expect(callback).toHaveBeenCalledWith('de', false);50 });51 test('should not be notify when unsubscribed', () => {52 const callback = jest.fn();53 setLocale('en');54 expect(getLocale()).toEqual('en');55 const unsubscribe = onLanguageChange(callback);56 expect(isFunction(unsubscribe)).toEqual(true);57 setLocale('de');58 expect(getLocale()).toEqual('de');59 expect(callback).toHaveBeenCalledWith('de', false);60 callback.mockClear();61 unsubscribe();62 setLocale('en');63 expect(getLocale()).toEqual('en');64 expect(callback).not.toHaveBeenCalled();65 });66 test('should change the date locale too', () => {67 setLocale('en');68 expect(getLocale()).toEqual('en');69 expect(getDateLocale()).toEqual('en');70 setLocale('de');71 expect(getLocale()).toEqual('de');72 expect(getDateLocale()).toEqual('de');73 });74});75describe('translate tests', () => {76 test('should return english "translation"', () => {77 setLocale('en');78 expect(_('Foo')).toEqual('Foo');79 });80});81describe('translateLazy tests', () => {82 test('should lazy translate', () => {83 setLocale('en');84 expect(_l('Foo').toString).toBeDefined();85 expect(_l('Foo').toString()).toEqual('Foo');86 expect('' + _l('Foo')).toEqual('Foo');87 expect(`${_l('Foo')}`).toEqual('Foo');88 });89});...
test.spec.js
Source:test.spec.js
...7})8test('Change locale', test => {9 let tr = new translator()10 test.is(tr.getMessage(418), "I'm a teapot")11 tr.setLocale('fr')12 test.is(tr.getMessage(418), "Je suis une théière")13})14test('Change locale idempotency', test => {15 let tr = new translator()16 tr.setLocale('fr')17 tr.setLocale('azerty')18 tr.setLocale('azerty')19 tr.setLocale('azerty')20 tr.setLocale('azerty')21 tr.setLocale('azerty')22 tr.setLocale('azerty')23 tr.setLocale('azerty')24 tr.setLocale('azerty')25 test.is(tr.getMessage(418), "Je suis une théière")26})27test('Change default locale', test => {28 let tr = new translator('fr')29 test.is(tr.getMessage(418), "Je suis une théière")30 tr.setLocale('en')31 test.is(tr.getMessage(418), "I'm a teapot")32})33test('Unknown locale', test => {34 let tr = new translator()35 test.is(tr.getMessage(418), "I'm a teapot")36 tr.setLocale('azerty')37 test.is(tr.getMessage(418), "I'm a teapot")38})39test('Unknown default locale', test => {40 let tr = new translator('azerty')41 test.is(tr.getMessage(418), "I'm a teapot")42})43test('Unknown code', test => {44 let tr = new translator()45 test.is(tr.getMessage(999), "999")46})47test('Custom default locale file', test => {48 let tr = new translator({49 418: 'Custom message for teapot'50 })51 test.is(tr.getMessage(418), "Custom message for teapot")52 test.is(tr.getMessage(404), "Not Found")53 tr.setLocale('en')54 test.is(tr.getMessage(418), "I'm a teapot")55 test.is(tr.getMessage(404), "Not Found")56})57test('Custom locale file', test => {58 let tr = new translator('fr')59 test.is(tr.getMessage(418), "Je suis une théière")60 test.is(tr.getMessage(404), "Non trouvé")61 tr.setLocale({62 418: 'Custom message for teapot'63 })64 test.is(tr.getMessage(418), "Custom message for teapot")65 test.is(tr.getMessage(404), "Non trouvé")66})67test('Custom locale replacement', test => {68 let tr = new translator()69 tr.setLocale({70 418: 'Custom message for teapot'71 })72 tr.setLocale('fr')73 test.is(tr.getMessage(418), "Je suis une théière")74})75test('Custom locale fallback', test => {76 let tr = new translator()77 tr.setLocale({78 888: 'Custom message!'79 })80 tr.setLocale('fr')81 test.is(tr.getMessage(418), "Je suis une théière")82 test.is(tr.getMessage(888), "Custom message!")83})84test('Custom locale file indepontency', test => {85 let tr = new translator('fr')86 tr.setLocale({87 418: 'Custom message for teapot'88 })89 tr.setLocale('azerty')90 tr.setLocale('azerty')91 tr.setLocale('azerty')92 tr.setLocale('azerty')93 tr.setLocale('azerty')94 tr.setLocale('azerty')95 tr.setLocale('azerty')96 tr.setLocale('azerty')97 tr.setLocale('azerty')98 tr.setLocale('azerty')99 test.is(tr.getMessage(418), "Custom message for teapot")100 test.is(tr.getMessage(404), "Non trouvé")...
index.jsx
Source:index.jsx
1import React from "react";2import HeaderHomePage from "../headerComponents/headerHomePage";3import BannerHomepage from "./components/BannerHomepage";4import SliderHomepage from "./components/SliderHomepage";5import TableHomepage from "./components/TableHomepage";6import ApaItuCrypto from "./components/ApaItuCrypto";7import CalculatorCrypto from "./components/CalculatorKrypto";8import KenapaMemilihCrypto from "./components/KenapaMemilihCrypto";9import NewsHomepage from "./components/NewsHomepage";10import FooterHomePage from "../footerComponents/footerHomePage/FooterHomePage";11import { HomeMarket } from "../../stores/chart/functions";12function Home(props) {13 let [MarketData, setMarketData] = React.useState([]);14 React.useEffect(() => {15 HomeMarket((Market) => {16 setMarketData(Market);17 });18 }, [setMarketData]);19 console.log(MarketData);20 return (21 <div className="navbar-homePage">22 <div className="navbar-top">23 <HeaderHomePage setLocale={props.setLocale} />24 <BannerHomepage setLocale={props.setLocale} />25 <SliderHomepage setLocale={props.setLocale} dataHome={MarketData} />26 <TableHomepage setLocale={props.setLocale} dataHome={MarketData} />27 <ApaItuCrypto setLocale={props.setLocale} />28 <CalculatorCrypto setLocale={props.setLocale} />29 <KenapaMemilihCrypto setLocale={props.setLocale} />30 <NewsHomepage setLocale={props.setLocale} />31 <FooterHomePage setLocale={props.setLocale} />32 </div>33 </div>34 );35}...
LanguageSelection.test.js
Source:LanguageSelection.test.js
1/* global it expect jest */2import React from 'react';3import { shallow } from 'enzyme';4import LanguageSelection from '../LanguageSelection';5it('renders no prompt by default', () => {6 const wrapper = shallow(7 <LanguageSelection setLocale={() => {}} />8 );9 expect(wrapper.find('.prompt').length).toEqual(0);10});11it('renders a prompt when requested', () => {12 const wrapper = shallow(13 <LanguageSelection includePrompt setLocale={() => {}} />14 );15 expect(wrapper.find('.prompt').length).toEqual(1);16});17it('permits selecting Dutch as a locale', () => {18 const setLocale = jest.fn();19 const wrapper = shallow(<LanguageSelection setLocale={setLocale} />);20 wrapper.find('.language-selection button.nl').simulate('click');21 expect(setLocale).toHaveBeenCalledWith('nl');22});23it('permits selecting English as a locale', () => {24 const setLocale = jest.fn();25 const wrapper = shallow(<LanguageSelection setLocale={setLocale} />);26 wrapper.find('.language-selection button.en').simulate('click');27 expect(setLocale).toHaveBeenCalledWith('en');...
Using AI Code Generation
1import { setLocale } from 'storybook-root';2setLocale('en-US');3import { setLocale } from 'storybook-root';4setLocale('en-US');5import { setLocale } from 'storybook-root';6setLocale('en-US');7import { setLocale } from 'storybook-root';8setLocale('en-US');9import { setLocale } from 'storybook-root';10setLocale('en-US');11import { setLocale } from 'storybook-root';12setLocale('en-US');13import { setLocale } from 'storybook-root';14setLocale('en-US');15import { setLocale } from 'storybook-root';16setLocale('en-US');17import { setLocale } from 'storybook-root';18setLocale('en-US');19import { setLocale } from 'storybook-root';20setLocale('en-US');21import { setLocale } from 'storybook-root';22setLocale('en-US');
Using AI Code Generation
1import { setLocale } from 'storybook-root';2setLocale('en-US');3import { storiesOf } from '@storybook/react';4import { withI18n } from 'storybook-addon-i18n';5import { withInfo } from '@storybook/addon-info';6storiesOf('Component', module)7 .addDecorator(8 withI18n({9 languages: {10 },11 })12 .addDecorator(withInfo)13 .add('Default', () => <Component />, {14 info: {15 },16 });
Using AI Code Generation
1export default { title: 'Button' };2export const withText = () => (3 <Button onClick={action('clicked')}>Hello Button</Button>4);5export const withEmoji = () => (6 <Button onClick={action('clicked')}><span role="img" aria-label="so cool">😀 😎 👍 💯</span></Button>7);8import { setLocale } from 'storybook-root';9import { withKnobs } from '@storybook/addon-knobs';10import { withInfo } from '@storybook/addon-info';11import { addDecorator, configure } from '@storybook/react';12import { setDefaults } from '@storybook/addon-info';13import { withOptions } from '@storybook/addon-options';14import { withA11y } from '@storybook/addon-a11y';15import { withConsole } from '@storybook/addon-console';16import { withTests } from '@storybook/addon-jest';17import results from '../.jest-test-results.json';18setDefaults({19});20addDecorator(withKnobs);21addDecorator(withA11y);22addDecorator((storyFn, context) => withConsole()(storyFn)(context));23addDecorator(24 withTests({25 }),26);27addDecorator(28 withOptions({
Using AI Code Generation
1import { setLocale } from 'storybook-root'2setLocale('es')3import { setLocale } from 'storybook-root'4setLocale('es')5import { setLocale } from 'storybook-root'6setLocale('es')7import { setLocale } from 'storybook-root'8setLocale('es')9import { setLocale } from 'storybook-root'10setLocale('es')11import { setLocale } from 'storybook-root'12setLocale('es')13import { setLocale } from 'storybook-root'14setLocale('es')15import { setLocale } from 'storybook-root'16setLocale('es')17import { setLocale } from 'storybook-root'18setLocale('es')19import { setLocale } from 'storybook-root'20setLocale('es')21import { setLocale } from 'storybook-root'22setLocale('es')23import { setLocale } from 'storybook-root'24setLocale('es')25import { setLocale } from 'storybook-root'26setLocale('es')27import { setLocale } from 'storybook-root'28setLocale('es')29import { setLocale } from 'storybook-root'30setLocale('es')31import { setLocale } from 'storybook-root'32setLocale('es')33import { setLocale } from 'storybook-root'34setLocale('es')
Using AI Code Generation
1import { setLocale } from 'storybook-root-addon';2setLocale('fr');3import { configure } from '@storybook/react';4import 'storybook-root-addon/register';5import './test.js';6configure(require.context('../src', true, /\.stories\.js$/), module);7import React from 'react';8import Button from '../Button';9import { setLocale } from 'storybook-root-addon';10export default {11 storyFn => {12 setLocale('fr');13 return storyFn();14 },15};16export const withText = () => <Button>Hello Button</Button>;17export const withEmoji = () => (18);19export const withSomeEmojiAndText = () => (20);21MIT © [Siddharth Kshetrapal](
Using AI Code Generation
1import { setLocale } from 'storybook-addon-intl';2setLocale('fr');3import React from 'react';4import { storiesOf } from '@storybook/react';5import { withIntl } from 'storybook-addon-intl';6import Test from 'Test';7storiesOf('Test', module)8 .addDecorator(withIntl)9 .add('Test', () => <Test />);10import React from 'react';11import { storiesOf } from '@storybook/react';12import { withIntl } from 'storybook-addon-intl';13import { setLocale } from 'storybook-addon-intl';14import Test from 'Test';15storiesOf('Test', module)16 .addDecorator(withIntl)17 .add('Test', () => {18 setLocale('fr');19 return <Test />;20 });
Using AI Code Generation
1import { setLocale } from 'storybook-root';2export const setLocale = (locale) => {3 setLocale(locale);4};5import { setLocale } from 'storybook-root';6export const setLocale = (locale) => {7 setLocale(locale);8};9import { setLocale } from 'storybook-root';10export const setLocale = (locale) => {11 setLocale(locale);12};13import { setLocale } from 'storybook-root';14export const setLocale = (locale) => {15 setLocale(locale);16};17import { setLocale } from 'storybook-root';18export const setLocale = (locale) => {19 setLocale(locale);20};21import { setLocale } from 'storybook-root';22export const setLocale = (locale) => {23 setLocale(locale);24};25import { setLocale } from 'storybook-root';26export const setLocale = (locale) => {27 setLocale(locale);28};29import { setLocale } from 'storybook-root';30export const setLocale = (locale) => {31 setLocale(locale);32};33import { setLocale } from 'storybook-root';34export const setLocale = (locale) => {35 setLocale(locale);36};37import { setLocale } from 'storybook-root';38export const setLocale = (locale) => {39 setLocale(locale);40};41import { setLocale } from 'storybook-root';42export const setLocale = (locale) => {43 setLocale(locale);44};
Using AI Code Generation
1import { setLocale } from 'storybook-root';2setLocale('en-US');3import { setLocale } from 'storybook-root';4setLocale('en-US');5import { setTheme } from 'storybook-root';6setTheme('light');7import { setTheme } from 'storybook-root';8setTheme('light');9import { setTheme } from 'storybook-root';10setTheme('light');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!