Merge pull request #258 from intnick/transiflex
fix i18n stuff + string extraction script for Transifex
This commit is contained in:
commit
02f226e484
9 changed files with 96 additions and 50 deletions
48
ui/extractLocals.js
Normal file
48
ui/extractLocals.js
Normal file
|
@ -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!');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ const RewardLink = props => {
|
||||||
: <Link
|
: <Link
|
||||||
button={button ? button : "alt"}
|
button={button ? button : "alt"}
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
label={isPending ? "Claiming..." : "Claim Reward"}
|
label={isPending ? __("Claiming...") : __("Claim Reward")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
claimReward(reward);
|
claimReward(reward);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class UserEmailVerify extends React.PureComponent {
|
||||||
>
|
>
|
||||||
<FormRow
|
<FormRow
|
||||||
type="text"
|
type="text"
|
||||||
label="Verification Code"
|
label={__("Verification Code")}
|
||||||
placeholder="a94bXXXXXXXXXXXXXX"
|
placeholder="a94bXXXXXXXXXXXXXX"
|
||||||
name="code"
|
name="code"
|
||||||
value={this.state.code}
|
value={this.state.code}
|
||||||
|
@ -46,14 +46,13 @@ class UserEmailVerify extends React.PureComponent {
|
||||||
{/* render help separately so it always shows */}
|
{/* render help separately so it always shows */}
|
||||||
<div className="form-field__helper">
|
<div className="form-field__helper">
|
||||||
<p>
|
<p>
|
||||||
Email <Link href="mailto:help@lbry.io" label="help@lbry.io" /> if
|
{__("Email")} <Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("if you did not receive or are having trouble with your code.")}
|
||||||
you did not receive or are having trouble with your code.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-row-submit form-row-submit--with-footer">
|
<div className="form-row-submit form-row-submit--with-footer">
|
||||||
<Link
|
<Link
|
||||||
button="primary"
|
button="primary"
|
||||||
label="Verify"
|
label={__("Verify")}
|
||||||
disabled={this.state.submitting}
|
disabled={this.state.submitting}
|
||||||
onClick={event => {
|
onClick={event => {
|
||||||
this.handleSubmit(event);
|
this.handleSubmit(event);
|
||||||
|
|
|
@ -23,7 +23,7 @@ const WalletSend = props => {
|
||||||
<div className="card__content">
|
<div className="card__content">
|
||||||
<FormRow
|
<FormRow
|
||||||
label={__("Amount")}
|
label={__("Amount")}
|
||||||
postfix="LBC"
|
postfix={__("LBC")}
|
||||||
step="0.01"
|
step="0.01"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="1.23"
|
placeholder="1.23"
|
||||||
|
|
|
@ -11,18 +11,17 @@ class WelcomeModal extends React.PureComponent {
|
||||||
return !hasClaimed
|
return !hasClaimed
|
||||||
? <Modal type="custom" isOpen={true} contentLabel="Welcome to LBRY">
|
? <Modal type="custom" isOpen={true} contentLabel="Welcome to LBRY">
|
||||||
<section>
|
<section>
|
||||||
<h3 className="modal__header">Welcome to LBRY.</h3>
|
<h3 className="modal__header">{__("Welcome to LBRY.")}</h3>
|
||||||
<p>
|
<p>
|
||||||
Using LBRY is like dating a centaur. Totally normal up top, and
|
{__("Using LBRY is like dating a centaur. Totally normal up top, and")}
|
||||||
{" "}<em>way different</em> underneath.
|
{" "}<em>{__("way different")}</em> {__("underneath.")}
|
||||||
</p>
|
</p>
|
||||||
<p>Up top, LBRY is similar to popular media sites.</p>
|
<p>{__("Up top, LBRY is similar to popular media sites.")}</p>
|
||||||
<p>
|
<p>
|
||||||
Below, LBRY is controlled by users -- you -- via blockchain and
|
{__("Below, LBRY is controlled by users -- you -- via blockchain and decentralization.")}
|
||||||
decentralization.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Thank you for making content freedom possible!
|
{__("Thank you for making content freedom possible!")}
|
||||||
{" "}{isRewardApproved ? __("Here's a nickel, kid.") : ""}
|
{" "}{isRewardApproved ? __("Here's a nickel, kid.") : ""}
|
||||||
</p>
|
</p>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
|
@ -31,7 +30,7 @@ class WelcomeModal extends React.PureComponent {
|
||||||
: <Link
|
: <Link
|
||||||
button="primary"
|
button="primary"
|
||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
label="Continue"
|
label={__("Continue")}
|
||||||
/>}
|
/>}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -40,32 +39,27 @@ class WelcomeModal extends React.PureComponent {
|
||||||
type="alert"
|
type="alert"
|
||||||
overlayClassName="modal-overlay modal-overlay--clear"
|
overlayClassName="modal-overlay modal-overlay--clear"
|
||||||
isOpen={true}
|
isOpen={true}
|
||||||
contentLabel="Welcome to LBRY"
|
contentLabel={__("Welcome to LBRY")}
|
||||||
onConfirmed={closeModal}
|
onConfirmed={closeModal}
|
||||||
>
|
>
|
||||||
<section>
|
<section>
|
||||||
<h3 className="modal__header">About Your Reward</h3>
|
<h3 className="modal__header">{__("About Your Reward")}</h3>
|
||||||
<p>
|
<p>
|
||||||
You earned a reward of
|
{__("You earned a reward of")}
|
||||||
{" "}<CreditAmount amount={reward.reward_amount} label={false} />
|
{" "}<CreditAmount amount={reward.reward_amount} label={false} />
|
||||||
{" "}LBRY
|
{" "}{__("LBRY credits, or")} <em>{__("LBC")}</em>.
|
||||||
credits, or <em>LBC</em>.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
This reward will show in your Wallet momentarily, probably while
|
{__("This reward will show in your Wallet momentarily, probably while you are reading this message.")}
|
||||||
you are reading this message.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
LBC is used to compensate creators, to publish, and to have say in
|
{__("LBC is used to compensate creators, to publish, and to have say in how the network works.")}
|
||||||
how the network works.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
No need to understand it all just yet! Try watching or downloading
|
{__("No need to understand it all just yet! Try watching or downloading something next.")}
|
||||||
something next.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Finally, know that LBRY is an early beta and that it earns the
|
{__("Finally, know that LBRY is an early beta and that it earns the name.")}
|
||||||
name.
|
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
</Modal>;
|
</Modal>;
|
||||||
|
|
|
@ -5,10 +5,8 @@ import FileCard from "component/fileCard";
|
||||||
import { BusyMessage } from "component/common.js";
|
import { BusyMessage } from "component/common.js";
|
||||||
import ToolTip from "component/tooltip.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 FeaturedCategory = props => {
|
||||||
const { category, names } = props;
|
const { category, names } = props;
|
||||||
|
@ -21,7 +19,7 @@ const FeaturedCategory = props => {
|
||||||
category.match(/^community/i) &&
|
category.match(/^community/i) &&
|
||||||
<ToolTip
|
<ToolTip
|
||||||
label={__("What's this?")}
|
label={__("What's this?")}
|
||||||
body={__(communityCategoryToolTipText)}
|
body={__("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!")}
|
||||||
className="tooltip--header"
|
className="tooltip--header"
|
||||||
/>}
|
/>}
|
||||||
</h3>
|
</h3>
|
||||||
|
|
|
@ -433,17 +433,23 @@ class PublishPage extends React.PureComponent {
|
||||||
"You have already used this URL. Publishing to it again will update your previous publish."
|
"You have already used this URL. Publishing to it again will update your previous publish."
|
||||||
);
|
);
|
||||||
} else if (this.state.topClaimValue) {
|
} else if (this.state.topClaimValue) {
|
||||||
return (
|
if (this.state.topClaimValue === 1) {
|
||||||
<span>
|
return (
|
||||||
{__n(
|
<span>
|
||||||
'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.',
|
'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
|
||||||
this.state.topClaimValue /*pluralization param*/,
|
)}
|
||||||
this.state.topClaimValue,
|
</span>
|
||||||
this.state.name /*regular params*/
|
);
|
||||||
)}
|
} else {
|
||||||
</span>
|
return (
|
||||||
);
|
<span>
|
||||||
|
{__(
|
||||||
|
'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
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -752,7 +758,7 @@ class PublishPage extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
<FormRow
|
<FormRow
|
||||||
label={__("Deposit")}
|
label={__("Deposit")}
|
||||||
postfix="LBC"
|
postfix={__("LBC")}
|
||||||
step="0.01"
|
step="0.01"
|
||||||
min="0"
|
min="0"
|
||||||
type="number"
|
type="number"
|
||||||
|
|
|
@ -20,7 +20,7 @@ const RewardTile = props => {
|
||||||
</div>
|
</div>
|
||||||
<div className="card__actions">
|
<div className="card__actions">
|
||||||
{claimed
|
{claimed
|
||||||
? <span><Icon icon="icon-check" /> Reward claimed.</span>
|
? <span><Icon icon="icon-check" /> {__("Reward claimed.")}</span>
|
||||||
: <RewardLink reward_type={reward.reward_type} />}
|
: <RewardLink reward_type={reward.reward_type} />}
|
||||||
</div>
|
</div>
|
||||||
<div className="card__content">{reward.reward_description}</div>
|
<div className="card__content">{reward.reward_description}</div>
|
||||||
|
@ -59,14 +59,13 @@ const RewardsPage = props => {
|
||||||
<div className="empty">
|
<div className="empty">
|
||||||
<p>{__("You are not eligible to claim rewards.")}</p>
|
<p>{__("You are not eligible to claim rewards.")}</p>
|
||||||
<p>
|
<p>
|
||||||
To become eligible, email
|
{__("To become eligible, email")}
|
||||||
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" /> with a
|
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("with a link to a public social media profile.")}
|
||||||
link to a public social media profile.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (fetching) {
|
} else if (fetching) {
|
||||||
content = <BusyMessage message="Fetching rewards" />;
|
content = <BusyMessage message={__("Fetching rewards")} />;
|
||||||
} else if (rewards.length > 0) {
|
} else if (rewards.length > 0) {
|
||||||
content = rewards.map(reward =>
|
content = rewards.map(reward =>
|
||||||
<RewardTile key={reward.reward_type} reward={reward} />
|
<RewardTile key={reward.reward_type} reward={reward} />
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"dev": "webpack-dev-server --devtool eval --progress --colors --inline",
|
"dev": "webpack-dev-server --devtool eval --progress --colors --inline",
|
||||||
"precommit": "lint-staged",
|
"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": [
|
"keywords": [
|
||||||
"lbry"
|
"lbry"
|
||||||
|
@ -60,6 +61,7 @@
|
||||||
"eslint-plugin-jsx-a11y": "^2.2.3",
|
"eslint-plugin-jsx-a11y": "^2.2.3",
|
||||||
"eslint-plugin-react": "^6.7.1",
|
"eslint-plugin-react": "^6.7.1",
|
||||||
"husky": "^0.13.4",
|
"husky": "^0.13.4",
|
||||||
|
"i18n-extract": "^0.4.4",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"lint-staged": "^3.6.0",
|
"lint-staged": "^3.6.0",
|
||||||
"node-sass": "^3.13.0",
|
"node-sass": "^3.13.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue