Hi, Do anyone know how i can translate a JS string ?
I hope there is a easy way ;) This is the code function budgetTypeToString(type) { var str; switch (type) { case BUDGET_TYPE_DAILY: str = "daily"; break; case BUDGET_TYPE_WEEKLY: str = "weekly"; break; case BUDGET_TYPE_MONTHLY: str = "monthly"; break; case BUDGET_TYPE_YEARLY: str = "yearly"; break; default: str = "unknown"; break; } return str; } /* budgetTypeNoun * * Returns the correct noun for the given budget type. * */ function budgetTypeNoun(type) { var str; switch (type) { case BUDGET_TYPE_DAILY: str = "day"; break; case BUDGET_TYPE_WEEKLY: str = "week"; break; case BUDGET_TYPE_MONTHLY: str = "month"; break; case BUDGET_TYPE_YEARLY: str = "year"; break; default: str = "unknown"; break; } return str; } function budgetTypeValue(type) { var retval; switch(type) { case "daily": retval = BUDGET_TYPE_DAILY; break; case "weekly": retval = BUDGET_TYPE_WEEKLY; break; case "monthly": retval = BUDGET_TYPE_MONTHLY; break; case "yearly": retval = BUDGET_TYPE_YEARLY; break; default: retval = BUDGET_TYPE_DAILY; break; } return retval; } then i read the string as into main main.qml page lbWalletDetails.text = qsTr("you have") + "<b> " + wallet.currency + " " + wallet.budget + "</b> " + qsTr("per") + " " + Util.budgetTypeNoun(wallet.budget_type) + " --- Best regards! Rudi Timmermans. Op 26/06/15 om 10:16 schreef Rudi Timmermans: > Hi Lucien, > > Ok thanks this works perfect ;) > > --- > Best regards! > > Rudi Timmermans. > > Op 26/06/15 om 09:06 schreef Lucien Xu: >> Hi Rudi, >> >> There are plenty of doc scattered on the internet. The secret is to >> use QT_TR_NOOP in the ListElement because you are not allowed to >> script what's inside a ListElement. >> >> See for instance this bug report >> https://bugreports.qt.io/browse/QTBUG-11403. >> >> Especially this example given in the reply. >> >> ListModel { >> ListElement { >> greeting: QT_TR_NOOP("hello") >> } >> } >> ... >> Text { text: qsTr(greeting) } >> >> Regards, >> Lucien >> >> ------------------------------------------------------------------------ >> >> *De: *"Rudi Timmermans" <rudi.tim...@gmx.us> >> *À: *"Sailfish OS Developers" <devel@lists.sailfishos.org> >> *Envoyé: *Vendredi 26 Juin 2015 08:54:47 >> *Objet: *Re: [SailfishDevel] compile error >> >> Hi, >> >> I like to use into ListElement the qsTr. >> >> This is my code: >> >> ListElement{ >> >> page:"ManageWalletsPage.qml" >> >> title:"Managewallets" >> >> subtitle:"Createanewwalletormodifyyourexistingones" >> >> section:"Management" >> >> } >> >> When is use title: qstr("Managewallets") this seems not to work anyone >> has a solution for this ? >> >> I like to translate this text string also, that's the resion of it. >> >> Thanks! >> >> >> >> --- >> Best regards! >> >> Rudi Timmermans. >> >> >> >> _______________________________________________ >> SailfishOS.org Devel mailing list >> To unsubscribe, please send a mail to >> devel-unsubscr...@lists.sailfishos.org >> >> >> >> >> _______________________________________________ >> SailfishOS.org Devel mailing list >> To unsubscribe, please send a mail todevel-unsubscr...@lists.sailfishos.org > _______________________________________________ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
_______________________________________________ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org