From 45cf918ae84f56d5e2a6873933f842a514c4c591 Mon Sep 17 00:00:00 2001 From: navjot Date: Fri, 24 Jul 2020 23:29:49 +0530 Subject: [PATCH] worked on language internationalization --- .../data/locales/en/LC_MESSAGES/langapp.mo | Bin 0 -> 386 bytes .../data/locales/fr/LC_MESSAGES/langapp.mo | Bin 0 -> 509 bytes src/bitmessagekivy/kv/chat_list.kv | 6 +- src/bitmessagekivy/kv/chat_room.kv | 2 +- src/bitmessagekivy/kv/composer.kv | 7 +- src/bitmessagekivy/kv/credits.kv | 6 +- src/bitmessagekivy/kv/login.kv | 16 +- src/bitmessagekivy/kv/maildetail.kv | 10 +- src/bitmessagekivy/kv/myaddress.kv | 2 +- src/bitmessagekivy/kv/network.kv | 24 +-- src/bitmessagekivy/kv/popup.kv | 42 ++--- src/bitmessagekivy/kv/settings.kv | 118 ++++++------- src/bitmessagekivy/main.kv | 36 ++-- src/bitmessagekivy/mpybit.py | 160 ++++++++++++++++-- src/bitmessagekivy/po/en.po | 29 ++++ src/bitmessagekivy/po/fr.po | 29 ++++ src/buildozer.spec | 2 +- 17 files changed, 342 insertions(+), 147 deletions(-) create mode 100644 src/bitmessagekivy/data/locales/en/LC_MESSAGES/langapp.mo create mode 100644 src/bitmessagekivy/data/locales/fr/LC_MESSAGES/langapp.mo create mode 100644 src/bitmessagekivy/po/en.po create mode 100644 src/bitmessagekivy/po/fr.po diff --git a/src/bitmessagekivy/data/locales/en/LC_MESSAGES/langapp.mo b/src/bitmessagekivy/data/locales/en/LC_MESSAGES/langapp.mo new file mode 100644 index 0000000000000000000000000000000000000000..896a32433a73b77e730c100df33f2da93c11e7e3 GIT binary patch literal 386 zcma)%O-sW-5QZyy%F(ljJ$Tcpn-(RmABZ(zp}|r@@7rX$SxtA#?xffs;@|VPIJp$O zh%Y?MVIGEgzfVuT2Am`2j5%kHnMBH{!Lm$jzGSkj<+8~suH~*ED$en3zY?5MHx>fF%2G1;0WP;}#sB~S literal 0 HcmV?d00001 diff --git a/src/bitmessagekivy/data/locales/fr/LC_MESSAGES/langapp.mo b/src/bitmessagekivy/data/locales/fr/LC_MESSAGES/langapp.mo new file mode 100644 index 0000000000000000000000000000000000000000..1e85ba7a1dc75796528c1793b80c4fb2155cfef4 GIT binary patch literal 509 zcma)&%SyvQ6oyBw7vfHE=VJCUHEB^wtfH+g78)!i)Qy{Ia+*w?&cvBXu{$5Yt*_>? zTVKNy1;LGYn2-O!{G8kRp!P;EYRD1NMz)a$q>2LBMV^oyWQFV_FUVknkXO{|{~hx^ z)HUiM>IW*muevB?3)!rap30=KIq4fvNltD-N=@&zktrD&J%_}xLCPjztk5c?LEZPp zP-x>=WHXVnPMKL2>yUb*yO?ziaEC^A!ySaQ;Rj9Tx0oN$;52NW9s3R6MDa2g~~$OnhNKU cYdkWxz$1V6A|0*fx-``3(oqR?p;Zdx6Y}DTS^xk5 literal 0 HcmV?d00001 diff --git a/src/bitmessagekivy/kv/chat_list.kv b/src/bitmessagekivy/kv/chat_list.kv index 2a480abf..e59c32d7 100644 --- a/src/bitmessagekivy/kv/chat_list.kv +++ b/src/bitmessagekivy/kv/chat_list.kv @@ -11,7 +11,7 @@ tab_display_mode:'text' Tab: - text: "Chats" + text: app.tr._("Chats") BoxLayout: id: chat_box orientation: 'vertical' @@ -23,7 +23,7 @@ MDLabel: font_style: 'Caption' theme_text_color: 'Primary' - text: 'No Chat' + text: app.tr._('No Chat') halign: 'center' size_hint_y: None bold: True @@ -47,7 +47,7 @@ # ImageLeftWidget: # source: './images/text_images/A.png' Tab: - text: "Contacts" + text: app.tr._("Contacts") BoxLayout: id: contact_box orientation: 'vertical' diff --git a/src/bitmessagekivy/kv/chat_room.kv b/src/bitmessagekivy/kv/chat_room.kv index 25edfd69..40843c47 100644 --- a/src/bitmessagekivy/kv/chat_room.kv +++ b/src/bitmessagekivy/kv/chat_room.kv @@ -37,7 +37,7 @@ on_text_validate: root.send_msg() MDRaisedButton: - text: "Send" + text: app.tr._("Send") elevation_normal: 2 opposite_colors: True size_hint: (0.3, 1) diff --git a/src/bitmessagekivy/kv/composer.kv b/src/bitmessagekivy/kv/composer.kv index 4931fd56..45afccd2 100644 --- a/src/bitmessagekivy/kv/composer.kv +++ b/src/bitmessagekivy/kv/composer.kv @@ -51,14 +51,17 @@ size_hint_y: None font_size: '15sp' height: self.parent.height/2 - hint_text: 'type, select or scan QR code for recipients address' + hint_text: app.tr._('type, select or scan QR code for recipients address') RV: id: rv MDIconButton: icon: 'qrcode-scan' pos_hint: {'center_x': 0, 'center_y': .8} on_release: - app.root.ids.scr_mngr.current = 'scanscreen' + if root.is_camara_attached(): app.root.ids.scr_mngr.current = 'scanscreen' + else: root.camera_alert() + on_press: + app.root.ids.sc23.get_screen('composer') MyMDTextField: id: subject diff --git a/src/bitmessagekivy/kv/credits.kv b/src/bitmessagekivy/kv/credits.kv index f6d037d2..b5eb3db7 100644 --- a/src/bitmessagekivy/kv/credits.kv +++ b/src/bitmessagekivy/kv/credits.kv @@ -7,7 +7,7 @@ orientation: 'vertical' OneLineListTitle: id: cred - text: "Available Credits" + text: app.tr._("Available Credits") divider: None theme_text_color: 'Primary' _no_ripple_effect: True @@ -15,7 +15,7 @@ OneLineListTitle: id: cred - text: root.available_credits + text: app.tr._(root.available_credits) divider: None font_style: 'H5' theme_text_color: 'Primary' @@ -24,5 +24,5 @@ AnchorLayout: MDRaisedButton: height: dp(38) - text: "+Add more credits" + text: app.tr._("+Add more credits") on_press: app.root.ids.scr_mngr.current = 'payment' diff --git a/src/bitmessagekivy/kv/login.kv b/src/bitmessagekivy/kv/login.kv index 2b923b90..6c78d847 100644 --- a/src/bitmessagekivy/kv/login.kv +++ b/src/bitmessagekivy/kv/login.kv @@ -28,7 +28,7 @@ size_hint_y: None height: dp(50) MDLabel: - text: "Select method to make an address:" + text: app.tr._("Select method to make an address:") bold: True halign: "center" theme_text_color: "Custom" @@ -54,7 +54,7 @@ size_hint_x: None width: dp(200) MDLabel: - text: "Random Number Generator" + text: app.tr._("Random Number Generator") AnchorLayout: size_hint_y: None @@ -74,11 +74,11 @@ size_hint_x: None width: dp(200) MDLabel: - text: "Pseudo Number Generator" + text: app.tr._("Pseudo Number Generator") AnchorLayout: MDFillRoundFlatIconButton: icon: "chevron-double-right" - text: "Proceed Next" + text: app.tr._("Proceed Next") on_release: app.root.ids.scr_mngr.current = 'random' on_press: @@ -160,7 +160,7 @@ size_hint_y: None height: dp(50) MDLabel: - text: "Enter a label to generate address for:" + text: app.tr._("Enter a label to generate address for:") bold: True halign: "center" theme_text_color: "Custom" @@ -185,7 +185,7 @@ AnchorLayout: MDFillRoundFlatIconButton: icon: "chevron-double-right" - text: "Proceed Next" + text: app.tr._("Proceed Next") on_release: app.root.ids.sc7.generateaddress(app) Widget: @@ -245,7 +245,7 @@ MDLabel: theme_text_color: "Custom" text_color: .1,.1,.1,.9 - text: root.section_name + text: app.tr._(root.section_name) bold: True font_style: "Button" @@ -261,4 +261,4 @@ theme_text_color: "Custom" text_color: 0.3,0.3,0.3,1 font_style: "Body1" - text: root.section_text + text: app.tr._(root.section_text) diff --git a/src/bitmessagekivy/kv/maildetail.kv b/src/bitmessagekivy/kv/maildetail.kv index 3d51f657..72473f94 100644 --- a/src/bitmessagekivy/kv/maildetail.kv +++ b/src/bitmessagekivy/kv/maildetail.kv @@ -19,7 +19,7 @@ # on_touch_down: root.allclick(self) OneLineListTitle: id: subj - text: root.subject + text: app.tr._(root.subject) divider: None font_style: 'H5' theme_text_color: 'Primary' @@ -27,14 +27,14 @@ long_press_time: 1 TwoLineAvatarIconListItem: id: subaft - text: root.from_addr - secondary_text: 'to ' + root.to_addr + text: app.tr._(root.from_addr) + secondary_text: app.tr._('to ' + root.to_addr) divider: None on_press: root.detailedPopup() BadgeText: size_hint:(None, None) size:[120, 140] if app.app_platform == 'android' else [64, 80] - text: root.time_tag + text: app.tr._(root.time_tag) halign:'center' font_style:'Caption' pos_hint: {'center_y': .8} @@ -42,7 +42,7 @@ font_size: '11sp' MDChip: size_hint: (.16 if app.app_platform == 'android' else .07 , None) - label: root.page_type + label: app.tr._(root.page_type) icon: '' pos_hint: {'center_x': .91 if app.app_platform == 'android' else .95, 'center_y': .3} radius: 8 diff --git a/src/bitmessagekivy/kv/myaddress.kv b/src/bitmessagekivy/kv/myaddress.kv index 39027b1c..f0ac822f 100644 --- a/src/bitmessagekivy/kv/myaddress.kv +++ b/src/bitmessagekivy/kv/myaddress.kv @@ -14,7 +14,7 @@ height: self.minimum_height MDLabel: id: tag_label - text: 'My Addresses' + text: app.tr._('My Addresses') font_style: 'Subtitle2' FloatLayout: MDScrollViewRefreshLayout: diff --git a/src/bitmessagekivy/kv/network.kv b/src/bitmessagekivy/kv/network.kv index c7cb9a2f..f38c8b96 100644 --- a/src/bitmessagekivy/kv/network.kv +++ b/src/bitmessagekivy/kv/network.kv @@ -5,7 +5,7 @@ tab_display_mode:'text' Tab: - text: "Total connections" + text: app.tr._("Total connections") ScrollView: do_scroll_x: False MDList: @@ -13,7 +13,7 @@ size_hint_y: None height: dp(200) OneLineListItem: - text: "Total Connections" + text: app.tr._("Total Connections") BoxLayout: orientation: 'vertical' size_hint_y: None @@ -27,12 +27,12 @@ pos_hint: {'center_x': .5} MDLabel: font_style: 'H6' - text: root.text_variable_1 + text: app.tr._(root.text_variable_1) font_size: '13sp' color: (1,1,1,1) halign: 'center' Tab: - text: 'Processes' + text: app.tr._('Processes') ScrollView: do_scroll_x: False MDList: @@ -40,7 +40,7 @@ size_hint_y: None height: dp(500) OneLineListItem: - text: "person-to-person" + text: app.tr._("person-to-person") BoxLayout: orientation: 'vertical' size_hint_y: None @@ -54,12 +54,12 @@ pos_hint: {'center_x': .5} MDLabel: font_style: 'H6' - text: root.text_variable_2 + text: app.tr._(root.text_variable_2) font_size: '13sp' color: (1,1,1,1) halign: 'center' OneLineListItem: - text: "Brodcast" + text: app.tr._("Brodcast") BoxLayout: orientation: 'vertical' size_hint_y: None @@ -73,12 +73,12 @@ pos_hint: {'center_x': .5} MDLabel: font_style: 'H6' - text: root.text_variable_3 + text: app.tr._(root.text_variable_3) font_size: '13sp' color: (1,1,1,1) halign: 'center' OneLineListItem: - text: "publickeys" + text: app.tr._("publickeys") BoxLayout: orientation: 'vertical' size_hint_y: None @@ -92,12 +92,12 @@ pos_hint: {'center_x': .5} MDLabel: font_style: 'H6' - text: root.text_variable_4 + text: app.tr._(root.text_variable_4) font_size: '13sp' color: (1,1,1,1) halign: 'center' OneLineListItem: - text: "objects" + text: app.tr._("objects") BoxLayout: orientation: 'vertical' size_hint_y: None @@ -111,7 +111,7 @@ pos_hint: {'center_x': .5} MDLabel: font_style: 'H6' - text: root.text_variable_5 + text: app.tr._(root.text_variable_5) font_size: '13sp' color: (1,1,1,1) halign: 'center' diff --git a/src/bitmessagekivy/kv/popup.kv b/src/bitmessagekivy/kv/popup.kv index 2feaf27d..3a52afb8 100644 --- a/src/bitmessagekivy/kv/popup.kv +++ b/src/bitmessagekivy/kv/popup.kv @@ -25,7 +25,7 @@ MDTextField: id: label multiline: False - hint_text: "Label" + hint_text: app.tr._("Label") required: True helper_text_mode: "on_error" on_text: root.checkLabel_valid(self) @@ -34,7 +34,7 @@ rgba: (0,0,0,1) MDTextField: id: address - hint_text: "Address" + hint_text: app.tr._("Address") required: True helper_text_mode: "on_error" multiline: False @@ -52,7 +52,7 @@ MDLabel font_style: 'Subtitle2' theme_text_color: 'Primary' - text: "Label" + text: app.tr._("Label") font_size: '17sp' halign: 'left' MDTextField: @@ -60,7 +60,7 @@ font_style: 'Body1' font_size: '15sp' halign: 'left' - text: root.address_label + text: app.tr._(root.address_label) theme_text_color: 'Primary' required: True helper_text_mode: "on_error" @@ -71,7 +71,7 @@ MDLabel: font_style: 'Subtitle2' theme_text_color: 'Primary' - text: "Address" + text: app.tr._("Address") font_size: '17sp' halign: 'left' Widget: @@ -83,7 +83,7 @@ id: address font_style: 'Body1' theme_text_color: 'Primary' - text: root.address + text: app.tr._(root.address) font_size: '15sp' halign: 'left' IconRightSampleWidget: @@ -102,7 +102,7 @@ id: myaddr_label font_style: 'Subtitle2' theme_text_color: 'Primary' - text: "Label" + text: app.tr._("Label") font_size: '17sp' halign: 'left' MDLabel: @@ -114,7 +114,7 @@ MDLabel: font_style: 'Subtitle2' theme_text_color: 'Primary' - text: "Address" + text: app.tr._("Address") font_size: '17sp' halign: 'left' BoxLayout: @@ -123,7 +123,7 @@ id: label_address font_style: 'Body1' theme_text_color: 'Primary' - text: root.address + text: app.tr._(root.address) font_size: '15sp' halign: 'left' IconRightSampleWidget: @@ -142,7 +142,7 @@ on_press: root.send_message_from() MDLabel: font_style: 'H6' - text: 'Send message from' + text: app.tr._('Send message from') font_size: '13sp' color: (1,1,1,1) halign: 'center' @@ -153,7 +153,7 @@ on_press: app.root.ids.sc15.qrdisplay(root, root.address) MDLabel: font_style: 'H6' - text: 'Show QR code' + text: app.tr._('Show QR code') font_size: '13sp' color: (1,1,1,1) halign: 'center' @@ -163,7 +163,7 @@ on_press: root.close_pop() MDLabel: font_style: 'H6' - text: 'Cancel' + text: app.tr._('Cancel') font_size: '13sp' color: (1,1,1,1) halign: 'center' @@ -189,7 +189,7 @@ id: popup_label font_style: 'Subtitle2' theme_text_color: 'Primary' - text: "Bitmessage isn't connected to the network.\n If you quit now, it may cause delivery delays.\n Wait until connected and the synchronisation finishes?" + text: app.tr._("Bitmessage isn't connected to the network.\n If you quit now, it may cause delivery delays.\n Wait until connected and the synchronisation finishes?") font_size: '17sp' halign: 'center' BoxLayout: @@ -203,7 +203,7 @@ on_press: app.stop() MDLabel: font_style: 'H6' - text: 'Yes' + text: app.tr._('Yes') font_size: '13sp' color: (1,1,1,1) halign: 'center' @@ -213,7 +213,7 @@ on_press: root.closingAction(self.children[0].text) MDLabel: font_style: 'H6' - text: 'No' + text: app.tr._('No') font_size: '13sp' color: (1,1,1,1) halign: 'center' @@ -224,7 +224,7 @@ on_press: root.closingAction(self.children[0].text) MDLabel: font_style: 'H6' - text: 'Cancel' + text: app.tr._('Cancel') font_size: '13sp' color: (1,1,1,1) halign: 'center' @@ -248,7 +248,7 @@ id: from_add_label font_style: 'Subtitle2' theme_text_color: 'Primary' - text: "From :" + text: app.tr._("From :") font_size: '15sp' halign: 'left' Widget: @@ -262,7 +262,7 @@ id: sd_label font_style: 'Body2' theme_text_color: 'Primary' - text: "[b]" + root.from_addr + "[/b]" + text: app.tr._("[b]" + root.from_addr + "[/b]") font_size: '15sp' halign: 'left' markup: True @@ -288,7 +288,7 @@ MDLabel: font_style: 'Body2' theme_text_color: 'Primary' - text: "Date : " + root.time_tag + text: app.tr._("Date : " + root.time_tag) font_size: '15sp' halign: 'left' BoxLayout: @@ -301,7 +301,7 @@ pos_hint: {'x': 0.8, 'y': 0} MDLabel: font_style: 'H6' - text: 'Cancel' + text: app.tr._('Cancel') font_size: '13sp' color: (1,1,1,1) halign: 'center' @@ -311,7 +311,7 @@ MDLabel: font_style: 'Body2' theme_text_color: 'Primary' - text: root.to_addr + text: app.tr._(root.to_addr) font_size: '15sp' halign: 'left' IconRightSampleWidget: diff --git a/src/bitmessagekivy/kv/settings.kv b/src/bitmessagekivy/kv/settings.kv index 98307c93..164ae346 100644 --- a/src/bitmessagekivy/kv/settings.kv +++ b/src/bitmessagekivy/kv/settings.kv @@ -5,7 +5,7 @@ tab_display_mode:'text' Tab: - text: "User Interface" + text: app.tr._("User Interface") ScrollView: do_scroll_x: False BoxLayout: @@ -27,7 +27,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Start-on-login not yet supported on your OS" + text: app.tr._("Start-on-login not yet supported on your OS") halign: 'left' pos_hint: {'center_x': 0, 'center_y': 0.6} disabled: True @@ -44,7 +44,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Tray" + text: app.tr._("Tray") halign: 'left' bold: True BoxLayout: @@ -58,7 +58,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Start Bitmessage in the tray(don't show main window)" + text: app.tr._("Start Bitmessage in the tray(don't show main window)") halign: 'left' pos_hint: {'x': 0, 'y': .5} BoxLayout: @@ -72,7 +72,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Minimize to tray" + text: app.tr._("Minimize to tray") halign: 'left' pos_hint: {'x': 0, 'y': .5} BoxLayout: @@ -86,7 +86,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Close to tray" + text: app.tr._("Close to tray") halign: 'left' pos_hint: {'x': 0, 'y': .5} BoxLayout: @@ -104,7 +104,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Hide connection notifications" + text: app.tr._("Hide connection notifications") halign: 'left' pos_hint: {'x': 0, 'y': 0.2} BoxLayout: @@ -118,7 +118,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Show notification when message received" + text: app.tr._("Show notification when message received") halign: 'left' pos_hint: {'x': 0, 'y': 0.2} BoxLayout: @@ -132,7 +132,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Run in Portable Mode" + text: app.tr._("Run in Portable Mode") halign: 'left' pos_hint: {'x': 0, 'y': 0.2} BoxLayout: @@ -140,7 +140,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: 'In portable Mode, messages and config files are stored in the same directory as the program rather then the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.' + text: app.tr._('In portable Mode, messages and config files are stored in the same directory as the program rather then the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.') # text: 'huiiiii' halign: 'left' BoxLayout: @@ -157,7 +157,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Willingly include unencrypted destination address when sending to a mobile device" + text: app.tr._("Willingly include unencrypted destination address when sending to a mobile device") halign: 'left' pos_hint: {'x': 0, 'y': 0.2} BoxLayout: @@ -171,7 +171,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Use identicons" + text: app.tr._("Use identicons") halign: 'left' pos_hint: {'x': 0, 'y': 0.2} BoxLayout: @@ -184,7 +184,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Reply below Quote" + text: app.tr._("Reply below Quote") halign: 'left' pos_hint: {'x': 0, 'y': 0.2} Widget: @@ -200,7 +200,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Interface Language" + text: app.tr._("Interface Language") # halign: 'right' bold: True MDDropDownItem: @@ -225,9 +225,9 @@ # padding: [0, 10, 0, 0] spacing: 10 MDRaisedButton: - text: 'Reset' + text: app.tr._('Reset') MDRaisedButton: - text: 'Ok' + text: app.tr._('Ok') Tab: text: 'Network Settings' ScrollView: @@ -243,7 +243,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Listening port" + text: app.tr._("Listening port") halign: 'left' bold: True BoxLayout: @@ -254,14 +254,14 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Listen for connections on port:" + text: app.tr._("Listen for connections on port:") halign: 'left' BoxLayout: orientation: 'horizontal' MDTextFieldRect: size_hint: None, None size: dp(100), dp(30) - text: '8444' + text: app.tr._('8444') pos_hint: {'center_y': .5, 'center_x': .5} input_filter: "int" BoxLayout: @@ -276,7 +276,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "UPnP" + text: app.tr._("UPnP") halign: 'left' pos_hint: {'x': 0, 'y': 0} BoxLayout: @@ -284,7 +284,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Proxy server / Tor" + text: app.tr._("Proxy server / Tor") halign: 'left' bold: True @@ -295,7 +295,7 @@ size_hint_x: None font_style: 'Body1' theme_text_color: 'Primary' - text: "Type:" + text: app.tr._("Type:") halign: 'left' MDDropDownItem: id: dropdown_item2 @@ -314,19 +314,19 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Server hostname:" + text: app.tr._("Server hostname:") halign: 'left' MDTextFieldRect: size_hint: None, None size: dp(app.window_size[0]/4), dp(30) - hint_text: 'localhost' + hint_text: app.tr._('localhost') pos_hint: {'center_y': .5, 'center_x': .5} BoxLayout: orientation: 'horizontal' MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Port:" + text: app.tr._("Port:") halign: 'left' # TextInput: # size_hint: None, None @@ -339,7 +339,7 @@ MDTextFieldRect: size_hint: None, None size: dp(app.window_size[0]/4), dp(30) - hint_text: '9050' + hint_text: app.tr._('9050') pos_hint: {'center_y': .5, 'center_x': .5} input_filter: "int" BoxLayout: @@ -347,7 +347,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Username:" + text: app.tr._("Username:") halign: 'left' MDTextFieldRect: size_hint: None, None @@ -358,7 +358,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Pass:" + text: app.tr._("Pass:") halign: 'left' MDTextFieldRect: size_hint: None, None @@ -376,7 +376,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Authentication" + text: app.tr._("Authentication") halign: 'left' pos_hint: {'x': 0, 'y': 0} BoxLayout: @@ -391,7 +391,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Listen for incoming connections when using proxy" + text: app.tr._("Listen for incoming connections when using proxy") halign: 'left' pos_hint: {'x': 0, 'y': 0} BoxLayout: @@ -406,7 +406,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Only connect to onion services(*.onion)" + text: app.tr._("Only connect to onion services(*.onion)") halign: 'left' pos_hint: {'x': 0, 'y': 0} BoxLayout: @@ -414,7 +414,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Bandwidth limit" + text: app.tr._("Bandwidth limit") halign: 'left' bold: True BoxLayout: @@ -425,7 +425,23 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Maximum download rate (kB/s):[0:unlimited]" + text: app.tr._("Maximum download rate (kB/s):[0:unlimited]") + halign: 'left' + MDTextFieldRect: + size_hint: None, None + size: app.window_size[0]/2, dp(30) + hint_text: app.tr._('0') + pos_hint: {'center_y': .5, 'center_x': .5} + input_filter: "int" + BoxLayout: + size_hint_y: None + orientation: 'horizontal' + padding: [30, 0, 0, 0] + height: dp(30) + self.minimum_height + MDLabel: + font_style: 'Body1' + theme_text_color: 'Primary' + text: app.tr._("Maximum upload rate (kB/s):[0:unlimited]") halign: 'left' MDTextFieldRect: size_hint: None, None @@ -441,23 +457,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Maximum upload rate (kB/s):[0:unlimited]" - halign: 'left' - MDTextFieldRect: - size_hint: None, None - size: app.window_size[0]/2, dp(30) - hint_text: '0' - pos_hint: {'center_y': .5, 'center_x': .5} - input_filter: "int" - BoxLayout: - size_hint_y: None - orientation: 'horizontal' - padding: [30, 0, 0, 0] - height: dp(30) + self.minimum_height - MDLabel: - font_style: 'Body1' - theme_text_color: 'Primary' - text: "Maximum outbound connections:[0:none]" + text: app.tr._("Maximum outbound connections:[0:none]") halign: 'left' MDTextFieldRect: size_hint: None, None @@ -470,9 +470,9 @@ orientation: 'horizontal' # pos_hint: {'x':.76} MDRaisedButton: - text: 'Reset' + text: app.tr._('Reset') MDRaisedButton: - text: 'Ok' + text: app.tr._('Ok') Tab: text: 'Resends Expire' ScrollView: @@ -491,7 +491,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: root.exp_text + text: app.tr._(root.exp_text) halign: 'left' BoxLayout: id: box2_height @@ -501,7 +501,7 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Leave these input fields blank for the default behavior." + text: app.tr._("Leave these input fields blank for the default behavior.") halign: 'left' BoxLayout: size_hint_y: None @@ -513,18 +513,18 @@ MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "Give up after" + text: app.tr._("Give up after") halign: 'left' MDTextFieldRect: size_hint: None, None size: dp(70), dp(30) - text: '0' + text: app.tr._('0') pos_hint: {'center_y': .5, 'center_x': .5} input_filter: "int" MDLabel: font_style: 'Body1' theme_text_color: 'Primary' - text: "days and" + text: app.tr._("days and") halign: 'left' MDTextFieldRect: size_hint: None, None @@ -545,6 +545,6 @@ # pos_hint: {'x':.75} height: dp(50) + self.minimum_height MDRaisedButton: - text: 'Reset' + text: app.tr._('Reset') MDRaisedButton: - text: 'Ok' + text: app.tr._('Ok') diff --git a/src/bitmessagekivy/main.kv b/src/bitmessagekivy/main.kv index c14ebe04..87cd62f7 100644 --- a/src/bitmessagekivy/main.kv +++ b/src/bitmessagekivy/main.kv @@ -16,7 +16,7 @@ #:import MDScrollViewRefreshLayout kivymd.uix.refreshlayout.MDScrollViewRefreshLayout #:import MDSpinner kivymd.uix.spinner.MDSpinner #:import MDTabsBase kivymd.uix.tab.MDTabsBase -#:import ZBarSymbol pyzbar.pyzbar.ZBarSymbol +##:import ZBarSymbol pyzbar.pyzbar.ZBarSymbol #:set color_button (0.784, 0.443, 0.216, 1) # brown @@ -100,7 +100,8 @@ height: self.minimum_height NavigationDrawerDivider: NavigationDrawerSubheader: - text: "Accounts" + text: app.tr._('Accounts') + #text: app.tr._('Hello World') height:"35dp" NavigationItem: # size: 50,50 @@ -127,7 +128,8 @@ ArrowImg: NavigationItem: id: inbox_cnt - text: 'Inbox' + text: app.tr._('Inbox') + #text: app.tr._('Hello World') icon: 'email-open' divider: None on_release: app.root.ids.scr_mngr.current = 'inbox' @@ -135,28 +137,28 @@ on_press: app.load_screen(self) NavigationItem: id: send_cnt - text: 'Sent' + text: app.tr._('Sent') icon: 'send' divider: None on_release: app.root.ids.scr_mngr.current = 'sent' on_release: root.parent.set_state() NavigationItem: id: draft_cnt - text: 'Draft' + text: app.tr._('Draft') icon: 'message-draw' divider: None on_release: app.root.ids.scr_mngr.current = 'draft' on_release: root.parent.set_state() NavigationItem: id: trash_cnt - text: 'Trash' + text: app.tr._('Trash') icon: 'delete' divider: None on_release: app.root.ids.scr_mngr.current = 'trash' on_release: root.parent.set_state() NavigationItem: id: allmail_cnt - text: 'All Mails' + text: app.tr._('All Mails') icon: 'contact-mail' divider: None on_release: app.root.ids.scr_mngr.current = 'allmails' @@ -164,53 +166,53 @@ on_press: app.load_screen(self) NavigationItem: id: chat_rm - text: 'Chat Room' + text: app.tr._('Chat Room') icon: 'wechat' divider: None on_release: app.root.ids.scr_mngr.current = 'chlist' on_release: root.parent.set_state() NavigationDrawerDivider: NavigationDrawerSubheader: - text: "All labels" + text: app.tr._("All labels") NavigationItem: - text: 'Address Book' + text: app.tr._('Address Book') icon: 'book-multiple' divider: None on_release: app.root.ids.scr_mngr.current = 'addressbook' on_release: root.parent.set_state() NavigationItem: - text: 'Settings' + text: app.tr._('Settings') icon: 'settings' divider: None on_release: app.root.ids.scr_mngr.current = 'set' on_release: root.parent.set_state() NavigationItem: - text: 'Purchase' + text: app.tr._('Purchase') icon: 'shopping' divider: None on_release: app.root.ids.scr_mngr.current = 'payment' on_release: root.parent.set_state() NavigationItem: - text: 'Credits' + text: app.tr._('Credits') icon: 'wallet' divider: None on_release: app.root.ids.scr_mngr.current = 'credits' on_release: root.parent.set_state() NavigationItem: - text: 'New address' + text: app.tr._('New address') icon: 'account-plus' divider: None on_release: app.root.ids.scr_mngr.current = 'login' on_release: root.parent.set_state() on_press: app.reset_login_screen() NavigationItem: - text: 'Network status' + text: app.tr._('Network status') icon: 'server-network' divider: None on_release: app.root.ids.scr_mngr.current = 'networkstat' on_release: root.parent.set_state() NavigationItem: - text: 'My addresses' + text: app.tr._('My addresses') icon: 'account-multiple' divider: None on_release: app.root.ids.scr_mngr.current = 'myaddress' @@ -317,7 +319,7 @@ NavigationLayout: size_hint_y: None font_style: 'Body1' theme_text_color: 'Primary' - text: root.address + text: app.tr._(root.address) multiline: True readonly: True line_color_normal: [0,0,0,0] diff --git a/src/bitmessagekivy/mpybit.py b/src/bitmessagekivy/mpybit.py index 439acf05..f255ca49 100644 --- a/src/bitmessagekivy/mpybit.py +++ b/src/bitmessagekivy/mpybit.py @@ -79,11 +79,13 @@ from kivymd.uix.bottomsheet import MDCustomBottomSheet from kivy.effects.dampedscroll import DampedScrollEffect from kivymd.uix.menu import MDDropdownMenu -from kivy_garden.zbarcam import ZBarCam -from pyzbar.pyzbar import ZBarSymbol +from kivy.lang import Observable +import gettext if platform != "android": from kivy.config import Config + from kivy_garden.zbarcam import ZBarCam + from pyzbar.pyzbar import ZBarSymbol Config.set("input", "mouse", "mouse, multitouch_on_demand") elif platform == "android": @@ -183,6 +185,44 @@ def chipTag(text): return obj +class Lang(Observable): + observers = [] + lang = None + + def __init__(self, defaultlang): + super(Lang, self).__init__() + self.ugettext = None + self.lang = defaultlang + self.switch_lang(self.lang) + + def _(self, text): + return self.ugettext(text) + + def fbind(self, name, func, args, **kwargs): + if name == "_": + self.observers.append((func, args, kwargs)) + else: + return super(Lang, self).fbind(name, func, *largs, **kwargs) + + def funbind(self, name, func, args, **kwargs): + if name == "_": + key = (func, args, kwargs) + if key in self.observers: + self.observers.remove(key) + else: + return super(Lang, self).funbind(name, func, *args, **kwargs) + + def switch_lang(self, lang): + # get the right locales directory, and instanciate a gettext + locale_dir = os.path.join(os.path.dirname(__file__), 'data', 'locales') + locales = gettext.translation('langapp', locale_dir, languages=[lang]) + self.ugettext = locales.gettext + + # update all the kv rules attached to this text + for func, largs, kwargs in self.observers: + func(largs, None, None) + + class Inbox(Screen): """Inbox Screen uses screen to show widgets of screens""" @@ -262,8 +302,13 @@ class Inbox(Screen): def set_inboxCount(self, msgCnt): # pylint: disable=no-self-use """This method is used to sent inbox message count""" - src_mng_obj = state.kivyapp.root.ids.content_drawer.ids.inbox_cnt - src_mng_obj.ids.badge_txt.text = showLimitedCnt(int(msgCnt)) + src_mng_obj = state.kivyapp.root.ids.content_drawer.ids + src_mng_obj.inbox_cnt.ids.badge_txt.text = showLimitedCnt(int(msgCnt)) + state.kivyapp.get_sent_count() + state.all_count = str( + int(state.sent_count) + int(state.inbox_count)) + src_mng_obj.allmail_cnt.ids.badge_txt.text = showLimitedCnt(int(state.all_count)) + def inboxDataQuery(self, xAddress, where, what, start_indx=0, end_indx=20): """This method is used for retrieving inbox data""" @@ -367,12 +412,14 @@ class Inbox(Screen): msg_count_objs.trash_cnt.ids.badge_txt.text = showLimitedCnt( int(state.trash_count) + 1 ) - msg_count_objs.allmail_cnt.ids.badge_txt.text = showLimitedCnt( - int(state.all_count) - 1 - ) state.inbox_count = str(int(state.inbox_count) - 1) state.trash_count = str(int(state.trash_count) + 1) - state.all_count = str(int(state.all_count) - 1) + if int(state.all_count) > 0: + msg_count_objs.allmail_cnt.ids.badge_txt.text = showLimitedCnt( + int(state.all_count) - 1 + ) + state.all_count = str(int(state.all_count) - 1) + if int(state.inbox_count) <= 0: # self.ids.identi_tag.children[0].text = '' self.ids.tag_label.text = '' @@ -937,6 +984,9 @@ class DropDownWidget(BoxLayout): state.detailPageType = '' state.send_draft_mail = None self.parent.parent.parent.ids.sc4.update_sent_messagelist() + allmailCnt_obj = state.kivyapp.root.ids.content_drawer.ids.allmail_cnt + allmailCnt_obj.ids.badge_txt.text = showLimitedCnt(int(state.all_count) + 1) + state.all_count = str(int(state.all_count) + 1) Clock.schedule_once(self.callback_for_msgsend, 3) queues.workerQueue.put(('sendmessage', toAddress)) print("sqlExecute successfully #######################") @@ -1000,8 +1050,59 @@ class DropDownWidget(BoxLayout): """This method is used for scanning Qr code""" pass + def is_camara_attached(self): + self.parent.parent.parent.ids.sc23.check_camera() + is_available = self.parent.parent.parent.ids.sc23.camera_avaialbe + return is_available + + def camera_alert(self): + width = .8 if platform == 'android' else .55 + altet_txt = 'Currently this feature is not avaialbe!'if platform == 'android' else 'Camera is not available!' + dialog_box=MDDialog( + text=altet_txt, + size_hint=(width, .25), + buttons=[ + MDFlatButton( + text="Ok", on_release=lambda x: callback_for_menu_items("Ok") + ), + ],) + dialog_box.open() + + def callback_for_menu_items(text_item, *arg): + """Callback of alert box""" + dialog_box.dismiss() + toast(text_item) + class ScanScreen(Screen): + camera_avaialbe = BooleanProperty(False) + previous_open_screen = StringProperty() + pop_up_instance = ObjectProperty() + + def __init__(self, *args, **kwargs): + """Getting AddressBook Details""" + super(ScanScreen, self).__init__(*args, **kwargs) + self.check_camera() + + def check_camera(self): + """This method is used for checking camera avaibility""" + if platform != "android": + import cv2 + cap = cv2.VideoCapture(0) + while(cap.isOpened()): + print('Camera is available!') + self.camera_avaialbe = True + break + else: + print("Camera is not available!") + self.camera_avaialbe = False + + def get_screen(self, screen_name, instance=None): + """This method is used for getting previous screen name""" + self.previous_open_screen = screen_name + if screen_name != 'composer': + self.pop_up_instance = instance + def on_pre_enter(self): """ on_pre_enter works little better on android @@ -1027,7 +1128,6 @@ class ScanScreen(Screen): def on_leave(self): # pass - Clock.schedule_once(self.stop_camera, 0) def start_camera(self, *args): @@ -1748,7 +1848,7 @@ class Setting(Screen): def set_caller(self): self.menu.caller= self.ids.drop_item # self.menu.use_icon_item = False - self.menu.target_height = 150 + self.menu.target_height = 250 def set_item(self, instance): self.ids.drop_item.set_item(instance.text) @@ -1776,6 +1876,7 @@ class NavigateApp(MDApp): #state.imageDir = os.path.join(os.path.abspath(os.path.join(__file__ ,"../../..")),'images', 'kivy') state.imageDir = os.path.join('./images', 'kivy') image_path = state.imageDir + tr = Lang("en") # for changing in franch replace en with fr def build(self): """Method builds the widget""" @@ -1883,7 +1984,8 @@ class NavigateApp(MDApp): on_release=self.close_pop, ), MDRaisedButton( - text="Scan QR code", text_color=self.theme_cls.primary_color + text="Scan QR code", text_color=self.theme_cls.primary_color, + on_release=self.scan_qr_code, ), ], ) @@ -1893,6 +1995,23 @@ class NavigateApp(MDApp): # p = GrashofPopup() # p.open() + def scan_qr_code(self, instance): + """this method is used for showing QR code scanner""" + if self.is_camara_attached(): + self.add_popup.dismiss() + self.root.ids.sc23.get_screen(self.root.ids.scr_mngr.current, self.add_popup) + self.root.ids.scr_mngr.current = 'scanscreen' + else: + altet_txt = 'Currently this feature is not avaialbe!' if platform == 'android' else 'Camera is not available!' + self.add_popup.dismiss() + toast(altet_txt) + + def is_camara_attached(self): + """This method is for checking is camera available or not""" + self.root.ids.sc23.check_camera() + is_available = self.root.ids.sc23.camera_avaialbe + return is_available + def savecontact(self, instance): """Method is used for saving contacts""" pupup_obj = self.add_popup.content_cls @@ -1905,6 +2024,9 @@ class NavigateApp(MDApp): pupup_obj.ids.address.focus = True elif label == '': pupup_obj.ids.label.focus = True + else: + pupup_obj.ids.address.focus = True + # pupup_obj.ids.label.focus = True stored_address = [addr[1] for addr in kivy_helper_search.search_sql( folder="addressbook")] @@ -2446,10 +2568,19 @@ class NavigateApp(MDApp): if platform == 'android': text = cast(CharSequence, String(text)) show_toast(text, Toast.LENGTH_SHORT) - else: + elif self.root.ids.sc23.previous_open_screen == 'composer': self.root.ids.sc3.children[1].ids.txt_input.text = text self.root.ids.scr_mngr.current = 'create' + elif self.root.ids.sc23.previous_open_screen: + back_screen = self.root.ids.sc23.previous_open_screen + self.root.ids.scr_mngr.current = 'inbox' if back_screen == 'scanscreen' else back_screen + add_obj = self.root.ids.sc23.pop_up_instance + add_obj.content_cls.ids.address.text = text + Clock.schedule_once(partial(self.open_popup, add_obj), .5) + def open_popup(self, instance, dt): + """This method is used for opening popup""" + instance.open() class GrashofPopup(BoxLayout): """Moule for save contacts and error messages""" @@ -3159,10 +3290,11 @@ class Allmails(Screen): state.sent_count = str(int(state.sent_count) - 1) nav_lay_obj.sc4.ids.ml.clear_widgets() nav_lay_obj.sc4.loadSent(state.association) + if folder != 'inbox': + msg_count_objs.allmail_cnt.ids.badge_txt.text = showLimitedCnt(int(state.all_count) - 1) + state.all_count = str(int(state.all_count) - 1) msg_count_objs.trash_cnt.ids.badge_txt.text = showLimitedCnt(int(state.trash_count) + 1) - msg_count_objs.allmail_cnt.ids.badge_txt.text = showLimitedCnt(int(state.all_count) - 1) state.trash_count = str(int(state.trash_count) + 1) - state.all_count = str(int(state.all_count) - 1) if int(state.all_count) <= 0: self.ids.tag_label.text = '' nav_lay_obj.sc5.clear_widgets() diff --git a/src/bitmessagekivy/po/en.po b/src/bitmessagekivy/po/en.po new file mode 100644 index 00000000..d2e23f53 --- /dev/null +++ b/src/bitmessagekivy/po/en.po @@ -0,0 +1,29 @@ +# Example for an internationalized Kivy app +# Copyright (C) 2013 Mathieu Virbel +# This file is distributed under the same license as the Kivy package. +# Mathieu Virbel , 2013 +# +msgid "" +msgstr "" +"Project-Id-Version: 1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-08-01 15:36+0200\n" +"PO-Revision-Date: 2013-08-01 15:36+0200\n" +"Last-Translator: Mathieu Virbel \n" +"Language-Team: Mathieu Virbel \n" +"Language: English\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: lang.kv:8 +msgid "Hello World" +msgstr "" + +#: lang.kv:17 +msgid "French" +msgstr "" + +#: lang.kv:21 +msgid "English" +msgstr "" diff --git a/src/bitmessagekivy/po/fr.po b/src/bitmessagekivy/po/fr.po new file mode 100644 index 00000000..64d6a625 --- /dev/null +++ b/src/bitmessagekivy/po/fr.po @@ -0,0 +1,29 @@ +# Example for an internationalized Kivy app +# Copyright (C) 2013 Mathieu Virbel +# This file is distributed under the same license as the Kivy package. +# Mathieu Virbel , 2013 +# +msgid "" +msgstr "" +"Project-Id-Version: 1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-08-01 15:36+0200\n" +"PO-Revision-Date: 2013-08-01 15:36+0200\n" +"Last-Translator: Mathieu Virbel \n" +"Language-Team: Mathieu Virbel \n" +"Language: Francais\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: lang.kv:8 +msgid "Hello World" +msgstr "Bonjour tout le monde" + +#: lang.kv:17 +msgid "French" +msgstr "Francais" + +#: lang.kv:21 +msgid "English" +msgstr "Anglais" diff --git a/src/buildozer.spec b/src/buildozer.spec index 810d2183..a2f07b14 100644 --- a/src/buildozer.spec +++ b/src/buildozer.spec @@ -13,7 +13,7 @@ package.domain = org.test source.dir = . # (list) Source files to include (let empty to include all the files) -source.include_exts = py,png,jpg,kv,atlas,gif,zip, json, css, ttf,java +source.include_exts = py,png,jpg,kv,atlas,gif,zip, json, css, ttf,java, po, mo # (list) List of inclusions using pattern matching #source.include_patterns = assets/*,images/*.png, ../images1/*/*.png