diff --git a/ui/extractLocals.js b/ui/extractLocals.js new file mode 100644 index 000000000..f67d123e2 --- /dev/null +++ b/ui/extractLocals.js @@ -0,0 +1,48 @@ +var extract = require('i18n-extract'); +const fs = require('fs'); + +var path = '../app/dist/locales/en.json'; + +fs.writeFile(path, '{}', 'utf8', function(err) { + if(err) { + return console.log(err); + } + var enLocale = require(path); + + const keys = extract.extractFromFiles(['js/**/*.{js,jsx}'], { + marker: '__', + }); + + let reports = []; + reports = reports.concat(extract.findMissing(enLocale, keys)); + + if (reports.length > 0) { + fs.readFile(path, 'utf8', function readFileCallback(err, data){ + if (err){ + console.log(err); + } else { + localeObj = JSON.parse(data); + + for (var i = 0; i < reports.length; i++) { + // no need to care for other types than MISSING because starting file will always be empty + if (reports[i].type === 'MISSING') { + localeObj[reports[i].key] = reports[i].key; + } + } + + var json = JSON.stringify(localeObj, null, '\t'); //convert it back to json-string + fs.writeFile(path, json, 'utf8', function callback(err) { + if (err) throw err; + console.log('Extracted all strings!'); + }); + } + }); + } +}); + + + + + + + diff --git a/ui/js/component/rewardLink/view.jsx b/ui/js/component/rewardLink/view.jsx index 6ebd50a20..be3a72f35 100644 --- a/ui/js/component/rewardLink/view.jsx +++ b/ui/js/component/rewardLink/view.jsx @@ -21,7 +21,7 @@ const RewardLink = props => { : { claimReward(reward); }} diff --git a/ui/js/component/userEmailVerify/view.jsx b/ui/js/component/userEmailVerify/view.jsx index c6cc65f34..bf6e9605e 100644 --- a/ui/js/component/userEmailVerify/view.jsx +++ b/ui/js/component/userEmailVerify/view.jsx @@ -34,7 +34,7 @@ class UserEmailVerify extends React.PureComponent { >

- Email if - you did not receive or are having trouble with your code. + {__("Email")} {__("if you did not receive or are having trouble with your code.")}

{ this.handleSubmit(event); diff --git a/ui/js/component/walletSend/view.jsx b/ui/js/component/walletSend/view.jsx index 31fd7d911..4d4de0fd6 100644 --- a/ui/js/component/walletSend/view.jsx +++ b/ui/js/component/walletSend/view.jsx @@ -23,7 +23,7 @@ const WalletSend = props => {
-

Welcome to LBRY.

+

{__("Welcome to LBRY.")}

- Using LBRY is like dating a centaur. Totally normal up top, and - {" "}way different underneath. + {__("Using LBRY is like dating a centaur. Totally normal up top, and")} + {" "}{__("way different")} {__("underneath.")}

-

Up top, LBRY is similar to popular media sites.

+

{__("Up top, LBRY is similar to popular media sites.")}

- Below, LBRY is controlled by users -- you -- via blockchain and - decentralization. + {__("Below, LBRY is controlled by users -- you -- via blockchain and decentralization.")}

- Thank you for making content freedom possible! + {__("Thank you for making content freedom possible!")} {" "}{isRewardApproved ? __("Here's a nickel, kid.") : ""}

@@ -31,7 +30,7 @@ class WelcomeModal extends React.PureComponent { : }
@@ -40,32 +39,27 @@ class WelcomeModal extends React.PureComponent { type="alert" overlayClassName="modal-overlay modal-overlay--clear" isOpen={true} - contentLabel="Welcome to LBRY" + contentLabel={__("Welcome to LBRY")} onConfirmed={closeModal} >
-

About Your Reward

+

{__("About Your Reward")}

- You earned a reward of + {__("You earned a reward of")} {" "} - {" "}LBRY - credits, or LBC. + {" "}{__("LBRY credits, or")} {__("LBC")}.

- This reward will show in your Wallet momentarily, probably while - you are reading this message. + {__("This reward will show in your Wallet momentarily, probably while you are reading this message.")}

- LBC is used to compensate creators, to publish, and to have say in - how the network works. + {__("LBC is used to compensate creators, to publish, and to have say in how the network works.")}

- No need to understand it all just yet! Try watching or downloading - something next. + {__("No need to understand it all just yet! Try watching or downloading something next.")}

- Finally, know that LBRY is an early beta and that it earns the - name. + {__("Finally, know that LBRY is an early beta and that it earns the name.")}

; diff --git a/ui/js/page/discover/view.jsx b/ui/js/page/discover/view.jsx index ea51972eb..a37611cc7 100644 --- a/ui/js/page/discover/view.jsx +++ b/ui/js/page/discover/view.jsx @@ -5,10 +5,8 @@ import FileCard from "component/fileCard"; import { BusyMessage } from "component/common.js"; import ToolTip from "component/tooltip.js"; -const communityCategoryToolTipText = - "Community Content is a public space where anyone can share content with the " + - 'rest of the LBRY community. Bid on the names "one," "two," "three," "four" and ' + - '"five" to put your content here!'; + + const FeaturedCategory = props => { const { category, names } = props; @@ -21,7 +19,7 @@ const FeaturedCategory = props => { category.match(/^community/i) && } diff --git a/ui/js/page/publish/view.jsx b/ui/js/page/publish/view.jsx index 2628e01e8..ce2cc6551 100644 --- a/ui/js/page/publish/view.jsx +++ b/ui/js/page/publish/view.jsx @@ -433,17 +433,23 @@ class PublishPage extends React.PureComponent { "You have already used this URL. Publishing to it again will update your previous publish." ); } else if (this.state.topClaimValue) { - return ( - - {__n( - 'A deposit of at least "%s" credit is required to win "%s". However, you can still get a permanent URL for any amount.', - 'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.', - this.state.topClaimValue /*pluralization param*/, - this.state.topClaimValue, - this.state.name /*regular params*/ - )} - - ); + if (this.state.topClaimValue === 1) { + return ( + + {__( + 'A deposit of at least one credit is required to win "%s". However, you can still get a permanent URL for any amount.', this.state.name + )} + + ); + } else { + return ( + + {__( + 'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.', this.state.topClaimValue, this.state.name + )} + + ); + } } else { return ""; } @@ -752,7 +758,7 @@ class PublishPage extends React.PureComponent { /> {
{claimed - ? Reward claimed. + ? {__("Reward claimed.")} : }
{reward.reward_description}
@@ -59,14 +59,13 @@ const RewardsPage = props => {

{__("You are not eligible to claim rewards.")}

- To become eligible, email - {" "} with a - link to a public social media profile. + {__("To become eligible, email")} + {" "} {__("with a link to a public social media profile.")}

); } else if (fetching) { - content = ; + content = ; } else if (rewards.length > 0) { content = rewards.map(reward => diff --git a/ui/package.json b/ui/package.json index 0eb8fa38e..2ffe670a8 100644 --- a/ui/package.json +++ b/ui/package.json @@ -6,7 +6,8 @@ "test": "echo \"Error: no test specified\" && exit 1", "dev": "webpack-dev-server --devtool eval --progress --colors --inline", "precommit": "lint-staged", - "prettier": "prettier --trailing-comma es5 --write js/**/*.{js,jsx}" + "prettier": "prettier --trailing-comma es5 --write js/**/*.{js,jsx}", + "extract-langs": "node extractLocals.js" }, "keywords": [ "lbry" @@ -60,6 +61,7 @@ "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-react": "^6.7.1", "husky": "^0.13.4", + "i18n-extract": "^0.4.4", "json-loader": "^0.5.4", "lint-staged": "^3.6.0", "node-sass": "^3.13.0",