How to use setLocale method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

index.js

Source:index.js Github

copy

Full Screen

...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() +...

Full Screen

Full Screen

public_route.js

Source:public_route.js Github

copy

Full Screen

...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        }...

Full Screen

Full Screen

filter.js

Source:filter.js Github

copy

Full Screen

...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    });...

Full Screen

Full Screen

policies.js

Source:policies.js Github

copy

Full Screen

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  }...

Full Screen

Full Screen

lang.js

Source:lang.js Github

copy

Full Screen

...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});...

Full Screen

Full Screen

test.spec.js

Source:test.spec.js Github

copy

Full Screen

...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é")...

Full Screen

Full Screen

index.jsx

Source:index.jsx Github

copy

Full Screen

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}...

Full Screen

Full Screen

LanguageSelection.test.js

Source:LanguageSelection.test.js Github

copy

Full Screen

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');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3    .forBrowser('selenium')4    .build();5driver.setLocale("en_GB");6driver.quit();7[debug] [XCUITest]     at ChildProcess.proc.on.code (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/teen_process/lib/exec.js:94:19)8[debug] [XCUITest]     at ChildProcess.emit (events.js:159:13)9[debug] [XCUITest]     at maybeClose (internal/child_process.js:943:16)10[debug] [XCUITest]     at Socket.stream.socket.on (internal/child_process.js:363:11)11[debug] [XCUITest]     at Socket.emit (events.js:159:13)12[debug] [XCUITest]     at Pipe._handle.close [as _onclose] (

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const expect = chai.expect;6describe('Test to change locale', function () {7  this.timeout(300000);8  it('should be able to change locale', async function () {9    await driver.init({10    });11    const locale = 'ar';12    await driver.setLocale(locale);13    const currentLocale = await driver.getLocale();14    expect(currentLocale).to.equal(locale);15  });16});17{18}

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require("webdriverio");2const opts = {3    capabilities: {4    }5};6async function example() {7    let client = await wdio.remote(opts);8    await client.setLocale('fr');9}10example();11const wdio = require("webdriverio");12const opts = {13    capabilities: {14    }15};16async function example() {17    let client = await wdio.remote(opts);18    await client.setLocale('fr');19}20example();21const wdio = require("webdriverio");22const opts = {23    capabilities: {24    }25};26async function example() {27    let client = await wdio.remote(opts);28    await client.setLocale('fr');29}30example();31const wdio = require("webdriverio");32const opts = {33    capabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var setLocale = require('appium-xcuitest-driver').commands.setLocale;2var desiredCaps = {3};4async function main () {5  let driver = await wdio.remote({6  });7  await setLocale(driver, 'en_GB');8  await driver.deleteSession();9}10main();11let commands = {};12 * @typedef {Object} SetLocaleOptions13 * @property {string} language - Language to set as current locale14 * @property {string} locale - Locale to set15 * @param {SetLocaleOptions} opts - Set locale options16 * @returns {string} Current locale17commands.setLocale = async function setLocale (opts = {}) {18  const {language, locale} = opts;19  if (!language || !locale) {20    throw new Error(`Both language and locale should be set`);21  }22  const currentLocale = await this.proxyCommand('/wda/device/locale', 'GET');23  if (currentLocale === locale) {24    return currentLocale;25  }26  await this.proxyCommand('/wda/device/locale', 'POST', {language, locale});27  return locale;28};29module.exports = commands;30commands.getLocale = async function getLocale () {31  const {value} = await this.proxyCommand('/wda/device/locale', 'GET');32  return value;33};34commands.setLocale = async function setLocale (language, locale) {35  await this.proxyCommand('/wda/device/locale', 'POST',

Full Screen

Using AI Code Generation

copy

Full Screen

1const setLocale = require('appium-xcuitest-driver').commands.setLocale;2const { errors } = require('appium-base-driver');3let extensions = {};4extensions.setLocale = async function (locale) {5  if (this.isWebContext()) {6    throw new errors.NotYetImplementedError();7  }8  return await setLocale.call(this, locale);9};10module.exports = extensions;11const wdio = require('webdriverio');12const setLocale = require('./test.js').setLocale;13const opts = {14  capabilities: {15  }16};17async function main () {18  let client = await wdio.remote(opts);19  await client.setLocale('en_GB');20  await client.deleteSession();21}22main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const driver = wd.promiseChainRemote('localhost', 4723);2driver.init({3}).then(function () {4    return driver.setLocale("en_GB");5}).then(function () {6    return driver.quit();7}).catch(function (err) {8    console.log(err);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should change the language of the device', async () => {2    await driver.setLocale('en');3    await driver.setLocale('es');4    await driver.setLocale('de');5});6it('should change the language of the device', async () => {7    await driver.setLocale('en');8    await driver.setLocale('es');9    await driver.setLocale('de');10});11it('should change the language of the device', async () => {12    await driver.setLocale('en');13    await driver.setLocale('es');14    await driver.setLocale('de');15});16it('should change the language of the device', async () => {17    await driver.setLocale('en');18    await driver.setLocale('es');19    await driver.setLocale('de');20});21it('should change the language of the device', async () => {22    await driver.setLocale('en');23    await driver.setLocale('es');24    await driver.setLocale('de');25});26it('should change the language of the device', async () => {27    await driver.setLocale('en');28    await driver.setLocale('es');29    await driver.setLocale('de');30});31it('should change the language of the device', async () => {32    await driver.setLocale('en');33    await driver.setLocale('es');34    await driver.setLocale('de');35});36it('should change the language of the device', async () => {37    await driver.setLocale('en');38    await driver.setLocale('es');39    await driver.setLocale('de');40});41it('should change the language of the device', async () => {42    await driver.setLocale('en');43    await driver.setLocale('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd'),2    assert = require('assert');3var desiredCaps = {4};5var driver = wd.promiseChainRemote('localhost', 4723);6driver.init(desiredCaps)7    .then(function () {8        return driver.setLocale('en_US');9    })10    .then(function () {11        return driver.quit();12    })13    .done();14var wd = require('wd'),15    assert = require('assert');16var desiredCaps = {17};18var driver = wd.promiseChainRemote('localhost', 4723);19driver.init(desiredCaps)20    .then(function () {21        return driver.setLocale('ja_JP');22    })23    .then(function () {24        return driver.quit();25    })26    .done();27var wd = require('wd'),28    assert = require('assert');29var desiredCaps = {30};31var driver = wd.promiseChainRemote('localhost', 4723);32driver.init(desiredCaps)33    .then(function () {34        return driver.setLocale('zh_CN');35    })36    .then(function () {37        return driver.quit();38    })39    .done();40var wd = require('wd'),41    assert = require('assert');42var desiredCaps = {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test to set locale of the device', function() {2  it('should set the locale of the device', function() {3    driver.setLocale('en_GB');4    let locale = driver.getLocale();5    console.log('Locale of the device is: ' + locale);6  });7});8getDeviceTime()9Syntax: getDeviceTime()10describe('Test to get the device time', function() {11  it('should get the device time', function() {12    let deviceTime = driver.getDeviceTime();13    console.log('Device time is: ' + deviceTime);14  });15});16setLocation()17Syntax: setLocation(latitude, longitude, altitude)18describe('Test to set the location of the device', function() {19  it('should set the location of the device', function() {20    driver.setLocation(45.5, -122.6, 100);21    let location = driver.getLocation();22    console.log('Location of the device is: ' + location);23  });24});25getGeoLocation()26Syntax: getGeoLocation()27describe('Test to get the location of the device', function() {28  it('should get the location of the device', function() {29    let location = driver.getGeoLocation();

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful