From addf29f3bc1bf6cd3d6be8f427dce8d4a7286662 Mon Sep 17 00:00:00 2001 From: Intnick Date: Thu, 1 Jun 2017 17:02:02 +0200 Subject: [PATCH] global i18n object defined in app.js; smaller translation improvements --- app/locales/en.json | 4 ++-- ui/js/app.js | 9 ++++++++- ui/js/component/app/view.jsx | 2 +- ui/js/component/common.js | 2 +- ui/js/main.js | 6 ------ ui/js/selectors/app.js | 34 ++++++++++++---------------------- 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/app/locales/en.json b/app/locales/en.json index 6baadaac6..a55aa69e1 100644 --- a/app/locales/en.json +++ b/app/locales/en.json @@ -137,7 +137,8 @@ "You haven't downloaded anything from LBRY yet. Go": "You haven't downloaded anything from LBRY yet. Go", "search for your first download": "search for your first download", "Loading": "Loading", - " credits": " credits", + "credit": "credit", + "credits": "credits", "It looks like you haven't published anything to LBRY yet. Go": "It looks like you haven't published anything to LBRY yet. Go", "share your beautiful cats with the world": "share your beautiful cats with the world", "report": "report", @@ -198,7 +199,6 @@ "Confirm Purchase": "Confirm Purchase", "This will purchase": "This will purchase", "for": "for", - "credits": "credits", "Not enough credits": "Not enough credits", "You don't have enough LBRY credits to pay for this stream.": "You don't have enough LBRY credits to pay for this stream.", "Download failed": "Download failed", diff --git a/ui/js/app.js b/ui/js/app.js index b354036ba..3752f43e5 100644 --- a/ui/js/app.js +++ b/ui/js/app.js @@ -1,4 +1,5 @@ import store from 'store.js'; +import lbry from './lbry.js'; const env = ENV; const config = require(`./config/${env}`); @@ -14,5 +15,11 @@ const app = { } } +const language = lbry.getClientSetting('language') ? lbry.getClientSetting('language') : 'en'; +const i18n = require('y18n')({directory: 'app/locales', locale: language}); +window.__ = i18n.__; +window.__n = i18n.__n; +window.i18n = i18n; + global.app = app; -module.exports = app; \ No newline at end of file +module.exports = app; diff --git a/ui/js/component/app/view.jsx b/ui/js/component/app/view.jsx index 2c13c6328..1c7ff4eb4 100644 --- a/ui/js/component/app/view.jsx +++ b/ui/js/component/app/view.jsx @@ -20,7 +20,7 @@ class App extends React.Component { lbry.balanceSubscribe((balance) => { this.props.updateBalance(balance) }) - }y + } render() { const { diff --git a/ui/js/component/common.js b/ui/js/component/common.js index d864a1c48..cc5578f1a 100644 --- a/ui/js/component/common.js +++ b/ui/js/component/common.js @@ -70,7 +70,7 @@ export class CreditAmount extends React.Component { if (this.props.showFree && parseFloat(formattedAmount) == 0) { amountText = __('free'); } else if (this.props.label) { - amountText = formattedAmount + (parseFloat(formattedAmount) == 1 ? __(' credit') : __(' credits')); + amountText = formattedAmount + ' ' + (parseFloat(formattedAmount) == 1 ? __('credit') : __('credits')); } else { amountText = formattedAmount; } diff --git a/ui/js/main.js b/ui/js/main.js index 957921563..0cad9589c 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -2,12 +2,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; import lbry from './lbry.js'; import lbryio from './lbryio.js'; - -const i18n = require('y18n')({directory: 'app/locales'/*, locale: lbry.getClientSetting('language')*/}); -window.__ = i18n.__; -window.__n = i18n.__n; -window.i18n = i18n; - import lighthouse from './lighthouse.js'; import App from 'component/app/index.js'; import SnackBar from 'component/snackBar'; diff --git a/ui/js/selectors/app.js b/ui/js/selectors/app.js index 1e96d66d0..ad1d50149 100644 --- a/ui/js/selectors/app.js +++ b/ui/js/selectors/app.js @@ -38,36 +38,26 @@ export const selectPageTitle = createSelector( selectCurrentParams, (page, params) => { switch (page) { + case 'settings': + case 'help': + case 'report': + case 'wallet': + case 'send': + case 'receive': + case 'rewards': + case 'start': + case 'publish': + case 'help': + case 'developer': + return __(page.charAt(0).toUpperCase() + page.slice(1)) case 'search': return params.query ? __("Search results for %s", params.query) : __('Search') - case 'settings': - return __('Settings') - case 'help': - return __('Help') - case 'report': - return __('Report') - case 'wallet': - return __("Wallet") - case 'send': - return __("Send") - case 'receive': - return __("Receive") - case 'rewards': - return __("Rewards") case 'show': return lbryuri.normalize(params.uri) case 'downloaded': return __('Downloads & Purchases') case 'published': return __('Publishes') - case 'start': - return __('Start') - case 'publish': - return __('Publish') - case 'help': - return __('Help') - case 'developer': - return __('Developer') case 'discover': return __('Home') default: