diff --git a/images/contacts/auction-house.png b/images/contacts/auction-house.png index 59eebce404..fee9fdf9f0 100644 Binary files a/images/contacts/auction-house.png and b/images/contacts/auction-house.png differ diff --git a/resources/default_contacts.json b/resources/default_contacts.json index 5d00c85c85..92ffd08314 100644 --- a/resources/default_contacts.json +++ b/resources/default_contacts.json @@ -1,13 +1,29 @@ -[ - {"id": "wallet", - "name": "Wallet", - "photo-path": "icon_wallet_avatar", - "add-chat?": true, - "dapp?": true}, +{ + "wallet": + { + "name": + { + "en": "Wallet", + "es": "Monedero", + "es-ar": "Monedero", + "ru": "Кошелек" + }, + "photo-path": "icon_wallet_avatar", + "add-chat?": true, + "dapp?": true + }, - {"id": "dapp-auction-house", - "name": "Auction House", - "photo-path": "contacts://auction-house", - "dapp?": true, - "dapp-url": "http://auctionhouse.dappbench.com"} -] + "auction-house": + { + "name": + { + "en": "Auction House" + }, + "photo-path": "contacts://auction-house", + "dapp?": true, + "dapp-url": + { + "en": "http://auctionhouse.dappbench.com" + } + } +} diff --git a/src/status_im/chat/views/message.cljs b/src/status_im/chat/views/message.cljs index 7353b0afb2..c23decb890 100644 --- a/src/status_im/chat/views/message.cljs +++ b/src/status_im/chat/views/message.cljs @@ -29,7 +29,8 @@ [status-im.components.chat-icon.screen :refer [chat-icon-message-status]] [status-im.utils.identicon :refer [identicon]] [status-im.utils.gfycat.core :refer [generate-gfy]] - [status-im.i18n :refer [label]] + [status-im.i18n :refer [label + get-contact-translated]] [status-im.chat.utils :as cu] [clojure.string :as str] [status-im.chat.handlers.console :as console] @@ -55,7 +56,8 @@ :number-of-lines 1} (if (str/blank? @name) (generate-gfy) - (or @name (label :t/chat-name)))] + (or (get-contact-translated @chat-id :name @name) + (label :t/chat-name)))] (when (or status content) [text {:style st/status-text :font :default} diff --git a/src/status_im/chat/views/toolbar_content.cljs b/src/status_im/chat/views/toolbar_content.cljs index 4d9f33dc91..bcabd4ea8d 100644 --- a/src/status_im/chat/views/toolbar_content.cljs +++ b/src/status_im/chat/views/toolbar_content.cljs @@ -6,7 +6,9 @@ [status-im.components.react :refer [view text icon]] - [status-im.i18n :refer [label label-pluralize]] + [status-im.i18n :refer [get-contact-translated + label + label-pluralize]] [status-im.chat.styles.screen :as st] [status-im.components.refreshable-text.view :refer [refreshable-text]] [status-im.utils.datetime :as time] @@ -75,7 +77,8 @@ :font :toolbar-title} (if (str/blank? @name) (generate-gfy) - (or @name (label :t/chat-name)))] + (or (get-contact-translated @chat-id :name @name) + (label :t/chat-name)))] (if @group-chat [group-last-activity {:contacts @contacts :sync-state @sync-state}] diff --git a/src/status_im/chats_list/views/inner_item.cljs b/src/status_im/chats_list/views/inner_item.cljs index 9264322565..70ab294202 100644 --- a/src/status_im/chats_list/views/inner_item.cljs +++ b/src/status_im/chats_list/views/inner_item.cljs @@ -7,7 +7,7 @@ [status-im.models.commands :refer [parse-command-message-content]] [status-im.chats-list.styles :as st] [status-im.utils.utils :refer [truncate-str]] - [status-im.i18n :refer [label label-pluralize]] + [status-im.i18n :refer [get-contact-translated label label-pluralize]] [status-im.utils.datetime :as time] [status-im.utils.gfycat.core :refer [generate-gfy]] [status-im.constants :refer [console-chat-id @@ -80,7 +80,8 @@ online group-chat contacts] :as chat}] (let [last-message (or (first (sort-by :clock-value > (:messages chat))) last-message) - name (or name (generate-gfy))] + name (or (get-contact-translated chat-id :name name) + (generate-gfy))] [view st/chat-container [view st/chat-icon-container [chat-icon-view-chat-list chat-id group-chat name color online]] diff --git a/src/status_im/commands/handlers/jail.cljs b/src/status_im/commands/handlers/jail.cljs index 624c556224..151012900f 100644 --- a/src/status_im/commands/handlers/jail.cljs +++ b/src/status_im/commands/handlers/jail.cljs @@ -9,6 +9,7 @@ [status-im.components.react :as r] [status-im.models.commands :as cm] [status-im.constants :refer [console-chat-id]] + [status-im.i18n :refer [get-contact-translated]] [taoensso.timbre :as log])) (defn render-command @@ -47,7 +48,7 @@ {:keys [dapp? dapp-url]} (get contacts chat-id) hiccup (generate-hiccup markup) web-view-url (if (and (= webViewUrl "dapp-url") dapp? dapp-url) - dapp-url + (get-contact-translated chat-id :dapp-url dapp-url) webViewUrl)] (-> db (assoc-in [:suggestions chat-id] hiccup) diff --git a/src/status_im/commands/handlers/loading.cljs b/src/status_im/commands/handlers/loading.cljs index fd8a85d2d8..aae6f215e6 100644 --- a/src/status_im/commands/handlers/loading.cljs +++ b/src/status_im/commands/handlers/loading.cljs @@ -167,16 +167,16 @@ (reg-handler :load-default-contacts! (u/side-effect! (fn [{:keys [chats]}] - (let [contacts (json->clj js-res/default-contacts-js)] - (doseq [{:keys [id name photo-path public-key add-chat? - dapp? dapp-url dapp-hash] :as contact} contacts] + (doseq [[id {:keys [name photo-path public-key add-chat? + dapp? dapp-url dapp-hash] :as contact}] js-res/default-contacts] + (let [id (clojure.core/name id)] (when-not (chats id) (when add-chat? - (dispatch [:add-chat id {:name name}])) + (dispatch [:add-chat id {:name (:en name)}])) (dispatch [:add-contacts [{:whisper-identity id - :name name + :name (:en name) :photo-path photo-path :public-key public-key :dapp? dapp? - :dapp-url dapp-url + :dapp-url (:en dapp-url) :dapp-hash dapp-hash}]]))))))) diff --git a/src/status_im/contacts/views/contact_inner.cljs b/src/status_im/contacts/views/contact_inner.cljs index eccee6d939..38af0e85c6 100644 --- a/src/status_im/contacts/views/contact_inner.cljs +++ b/src/status_im/contacts/views/contact_inner.cljs @@ -4,7 +4,7 @@ [status-im.components.chat-icon.screen :refer [contact-icon-contacts-tab]] [status-im.contacts.styles :as st] [status-im.utils.gfycat.core :refer [generate-gfy]] - [status-im.i18n :refer [label]])) + [status-im.i18n :refer [get-contact-translated label]])) (defn contact-photo [contact] [view st/contact-photo-container @@ -13,14 +13,14 @@ (defn contact-inner-view ([contact] (contact-inner-view contact nil)) - ([{:keys [name] :as contact} info] + ([{:keys [whisper-identity name] :as contact} info] [view st/contact-inner-container [contact-photo contact] [view st/info-container [text {:style st/name-text :number-of-lines 1} (if (pos? (count (:name contact))) - name + (get-contact-translated whisper-identity :name name) ;; todo is this correct behaviour? (generate-gfy))] (when info diff --git a/src/status_im/i18n.cljs b/src/status_im/i18n.cljs index c270375c81..5070abe0e1 100644 --- a/src/status_im/i18n.cljs +++ b/src/status_im/i18n.cljs @@ -33,7 +33,8 @@ [status-im.translations.zh-hant :as zh-hant] [status-im.translations.zh-wuu :as zh-wuu] [status-im.translations.zh-yue :as zh-yue] - [status-im.utils.utils :as u])) + [status-im.utils.utils :as u] + [status-im.utils.js-resources :refer [default-contacts]])) (def i18n (js/require "react-native-i18n")) (set! (.-fallbacks i18n) true) @@ -91,3 +92,12 @@ (str "t/status-") (keyword) (label))) + +(def locale + (.-locale i18n)) + +(defn get-contact-translated [contact-id key fallback] + (let [translation #(get-in default-contacts [(keyword contact-id) key (keyword %)])] + (or (translation locale) + (translation (subs locale 0 2)) + fallback))) diff --git a/src/status_im/profile/screen.cljs b/src/status_im/profile/screen.cljs index 2fc5a8ea52..b1e208635b 100644 --- a/src/status_im/profile/screen.cljs +++ b/src/status_im/profile/screen.cljs @@ -32,7 +32,8 @@ [status-im.utils.random :refer [id]] [status-im.utils.utils :refer [clean-text]] [status-im.components.image-button.view :refer [show-qr-button]] - [status-im.i18n :refer [label]])) + [status-im.i18n :refer [label + get-contact-translated]])) (defn share [text dialog-title] (let [list-selection-fn (:list-selection-fn platform-specific)] @@ -72,8 +73,11 @@ (r/set-state component {:height height}))] (r/create-class {:reagent-render - (fn [{{:keys [name status photo-path]} :account - edit? :edit?}] + (fn [{{:keys [whisper-identity + name + status + photo-path]} :account + edit? :edit?}] [view st/status-block [view st/user-photo-container @@ -94,7 +98,7 @@ :editable edit? :input-style (st/username-input edit? (s/valid? ::v/name name)) :wrapper-style st/username-wrapper - :value name + :value (get-contact-translated whisper-identity :name name) :on-change-text #(dispatch [:set-in [:profile-edit :name] %])}] (if (or edit? @just-opened?) [text-input {:ref #(reset! input-ref %) diff --git a/src/status_im/utils/js_resources.cljs b/src/status_im/utils/js_resources.cljs index ec162d86ef..9a9b1621e0 100644 --- a/src/status_im/utils/js_resources.cljs +++ b/src/status_im/utils/js_resources.cljs @@ -1,7 +1,9 @@ (ns ^:figwheel-always status-im.utils.js-resources - (:require-macros [status-im.utils.slurp :refer [slurp]])) + (:require-macros [status-im.utils.slurp :refer [slurp]]) + (:require [status-im.utils.types :refer [json->clj]])) -(def default-contacts-js (slurp "resources/default_contacts.json")) +(def default-contacts (-> (slurp "resources/default_contacts.json") + (json->clj))) (def commands-js (slurp "resources/commands.js")) (def console-js (slurp "resources/console.js"))