app: add i18n support
parent
5b430ddc95
commit
f4264b9c8c
|
@ -36,6 +36,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Gui Svg QuickControls2)
|
||||
find_package(LibOath REQUIRED)
|
||||
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} REQUIRED)
|
||||
find_package(KF5I18n ${KF5_MIN_VERSION} REQUIRED)
|
||||
|
||||
################ Find testing dependencies ##########
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$XGETTEXT $(find src -name \*.cpp -o -name \*.h -o -name \*.qml) -o $podir/keysmith.pot
|
|
@ -13,6 +13,7 @@ qt5_add_resources(RESOURCES resources.qrc)
|
|||
add_executable(org.kde.keysmith ${keysmith_SRCS} ${RESOURCES})
|
||||
target_link_libraries(org.kde.keysmith
|
||||
Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg
|
||||
KF5::I18n
|
||||
${LIBOATH_LIBRARIES}
|
||||
${keysmith_internal_libs}
|
||||
)
|
||||
|
|
|
@ -40,7 +40,7 @@ Kirigami.Page {
|
|||
|
||||
Kirigami.Action {
|
||||
id: leftAction
|
||||
text: root.hideSensitive ? "Show" : "Hide"
|
||||
text: root.hideSensitive ? i18n("Show") : i18n("Hide")
|
||||
iconName: root.hideSensitive ? "view-visible" : "view-hidden"
|
||||
onTriggered: {
|
||||
root.hideSensitive = !root.hideSensitive;
|
||||
|
@ -50,7 +50,7 @@ Kirigami.Page {
|
|||
|
||||
Kirigami.Action {
|
||||
id: rightAction
|
||||
text: "Generate token"
|
||||
text: i18nc("@action:button", "Generate Token")
|
||||
iconName: "view-refresh"
|
||||
onTriggered: {
|
||||
root.tokenRefresh(account, accountIndex)
|
||||
|
@ -59,7 +59,7 @@ Kirigami.Page {
|
|||
|
||||
Kirigami.Action {
|
||||
id: mainAction
|
||||
text: root.editMode ? "Apply" : "Edit"
|
||||
text: root.editMode ? i18n("Apply") : i18n("Edit")
|
||||
iconName: root.editMode ? "document-save" : "document-edit"
|
||||
onTriggered: {
|
||||
var fromEditor = root.editMode;
|
||||
|
@ -73,7 +73,7 @@ Kirigami.Page {
|
|||
actions.main: mainAction
|
||||
actions.left: editMode ? null : leftAction
|
||||
actions.right: editMode ? null : rightAction
|
||||
title: account ? account.name : "Account Details"
|
||||
title: account ? account.name : i18nc("@title:window", "Account Details")
|
||||
|
||||
ColumnLayout {
|
||||
id: layout
|
||||
|
|
|
@ -39,23 +39,23 @@ Kirigami.FormLayout {
|
|||
|
||||
ColumnLayout {
|
||||
Layout.rowSpan: 2
|
||||
Kirigami.FormData.label: "Account Type:"
|
||||
Kirigami.FormData.label: i18nc("@label:chooser", "Account Type:")
|
||||
Kirigami.FormData.buddyFor: totpRadio
|
||||
Controls.RadioButton {
|
||||
id: totpRadio
|
||||
checked: !account || account.type == Account.TypeTOTP
|
||||
text: "Time-based OTP"
|
||||
text: i18nc("@option:radio", "Time-based OTP")
|
||||
}
|
||||
Controls.RadioButton {
|
||||
id: hotpRadio
|
||||
checked: account && account.type == Account.TypeHOTP
|
||||
text: "Hash-based OTP"
|
||||
text: i18nc("@option:radio", "Hash-based OTP")
|
||||
}
|
||||
}
|
||||
Controls.TextField {
|
||||
id: accountSecret
|
||||
text: account ? account.secret : ""
|
||||
Kirigami.FormData.label: "Secret key:"
|
||||
Kirigami.FormData.label: i18nc("@label:textbox", "Secret key:")
|
||||
validator: Validators.Base32SecretValidator {
|
||||
id: secretValidator
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ Kirigami.FormLayout {
|
|||
}
|
||||
Controls.TextField {
|
||||
id: timerField
|
||||
Kirigami.FormData.label: "Timer:"
|
||||
Kirigami.FormData.label: i18nc("@label:textbox", "Timer:")
|
||||
enabled: totpRadio.checked
|
||||
text: account ? "" + account.timeStep : "30"
|
||||
inputMask: "0009"
|
||||
|
@ -72,7 +72,7 @@ Kirigami.FormLayout {
|
|||
Controls.TextField {
|
||||
id: counterField
|
||||
text: account ? "" + account.counter : ""
|
||||
Kirigami.FormData.label: "Counter:"
|
||||
Kirigami.FormData.label: i18nc("@label:textbox", "Counter:")
|
||||
enabled: hotpRadio.checked
|
||||
validator: Validators.HOTPCounterValidator {
|
||||
id: counterValidator
|
||||
|
@ -87,7 +87,7 @@ Kirigami.FormLayout {
|
|||
*/
|
||||
Controls.SpinBox {
|
||||
id: pinLengthField
|
||||
Kirigami.FormData.label: "Token length:"
|
||||
Kirigami.FormData.label: i18nc("@label:spinbox", "Token length:")
|
||||
from: 6
|
||||
to: 8
|
||||
value: account ? account.pinLength : 6
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.kde.kirigami 2.4 as Kirigami
|
|||
Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
|
||||
title: "Keysmith"
|
||||
title: application.displayName
|
||||
|
||||
pageStack.initialPage: accounts.rowCount() > 0 ? mainPageComponent : addPageComponent
|
||||
|
||||
|
@ -41,7 +41,7 @@ Kirigami.ApplicationWindow {
|
|||
|
||||
Kirigami.Action {
|
||||
id: addAction
|
||||
text: "Add"
|
||||
text: i18n("Add")
|
||||
iconName: "list-add"
|
||||
visible: addActionEnabled
|
||||
onTriggered: {
|
||||
|
@ -53,10 +53,10 @@ Kirigami.ApplicationWindow {
|
|||
Component {
|
||||
id: mainPageComponent
|
||||
Kirigami.ScrollablePage {
|
||||
title: "OTP"
|
||||
title: i18n("OTP")
|
||||
actions.main: addAction
|
||||
Controls.Label {
|
||||
text: "No account set up. Use the add button to add accounts."
|
||||
text: i18nc("Text shown when no accounts are added", "No account set up. Use the Add button to add accounts.")
|
||||
visible: view.count == 0
|
||||
}
|
||||
Kirigami.CardsListView {
|
||||
|
@ -110,7 +110,7 @@ Kirigami.ApplicationWindow {
|
|||
Controls.Button {
|
||||
Layout.alignment: Qt.AlignRight|Qt.AlignVCenter
|
||||
Layout.columnSpan: 2
|
||||
text: "Refresh (" + model.counter + ")"
|
||||
text: i18nc("%1 is current counter numerical value", "Refresh (%1)", model.counter)
|
||||
visible: model.type === Account.TypeHOTP
|
||||
onClicked: {
|
||||
accounts.generateNext(index);
|
||||
|
@ -154,9 +154,9 @@ Kirigami.ApplicationWindow {
|
|||
Component {
|
||||
id: addPageComponent
|
||||
Kirigami.Page {
|
||||
title: "Add new account"
|
||||
title: i18nc("@title:window", "Add new account")
|
||||
actions.main: Kirigami.Action {
|
||||
text: "Add"
|
||||
text: i18n("Add")
|
||||
iconName: "answer-correct"
|
||||
onTriggered: {
|
||||
/*
|
||||
|
@ -213,7 +213,7 @@ Kirigami.ApplicationWindow {
|
|||
|
||||
Controls.TextField {
|
||||
id: accountName
|
||||
Kirigami.FormData.label: "Account Name:"
|
||||
Kirigami.FormData.label: i18nc("@label:textbox", "Account Name:")
|
||||
validator: Validators.AccountNameValidator {
|
||||
id: nameValidator
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#include <QtQml>
|
||||
#include <QUrl>
|
||||
|
||||
#include <KLocalizedContext>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include "accountmodel.h"
|
||||
#include "account.h"
|
||||
#include "validators/qmlsupport.h"
|
||||
|
@ -32,11 +35,15 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||
{
|
||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QApplication app(argc, argv);
|
||||
KLocalizedString::setApplicationDomain("keysmith");
|
||||
|
||||
QCoreApplication::setOrganizationName("KDE");
|
||||
QCoreApplication::setOrganizationDomain("kde.org");
|
||||
QCoreApplication::setApplicationName("Keysmith");
|
||||
QGuiApplication::setApplicationDisplayName(i18nc("@title", "Keysmith"));
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||
|
||||
qmlRegisterType<AccountModel>("Oath", 1, 0, "AccountModel");
|
||||
qmlRegisterUncreatableType<Account>("Oath", 1, 0, "Account", "Use AccountModel::createAccount() to create a new account");
|
||||
|
|
Loading…
Reference in New Issue