Merge pull request #258 from intnick/transiflex

fix i18n stuff + string extraction script for Transifex
This commit is contained in:
Jeremy Kauffman 2017-06-19 15:13:19 -04:00 committed by GitHub
commit 02f226e484
9 changed files with 96 additions and 50 deletions

48
ui/extractLocals.js Normal file
View 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!');
});
}
});
}
});

View file

@ -21,7 +21,7 @@ const RewardLink = props => {
: <Link
button={button ? button : "alt"}
disabled={isPending}
label={isPending ? "Claiming..." : "Claim Reward"}
label={isPending ? __("Claiming...") : __("Claim Reward")}
onClick={() => {
claimReward(reward);
}}

View file

@ -34,7 +34,7 @@ class UserEmailVerify extends React.PureComponent {
>
<FormRow
type="text"
label="Verification Code"
label={__("Verification Code")}
placeholder="a94bXXXXXXXXXXXXXX"
name="code"
value={this.state.code}
@ -46,14 +46,13 @@ class UserEmailVerify extends React.PureComponent {
{/* render help separately so it always shows */}
<div className="form-field__helper">
<p>
Email <Link href="mailto:help@lbry.io" label="help@lbry.io" /> if
you did not receive or are having trouble with your code.
{__("Email")} <Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("if you did not receive or are having trouble with your code.")}
</p>
</div>
<div className="form-row-submit form-row-submit--with-footer">
<Link
button="primary"
label="Verify"
label={__("Verify")}
disabled={this.state.submitting}
onClick={event => {
this.handleSubmit(event);

View file

@ -23,7 +23,7 @@ const WalletSend = props => {
<div className="card__content">
<FormRow
label={__("Amount")}
postfix="LBC"
postfix={__("LBC")}
step="0.01"
type="number"
placeholder="1.23"

View file

@ -11,18 +11,17 @@ class WelcomeModal extends React.PureComponent {
return !hasClaimed
? <Modal type="custom" isOpen={true} contentLabel="Welcome to LBRY">
<section>
<h3 className="modal__header">Welcome to LBRY.</h3>
<h3 className="modal__header">{__("Welcome to LBRY.")}</h3>
<p>
Using LBRY is like dating a centaur. Totally normal up top, and
{" "}<em>way different</em> underneath.
{__("Using LBRY is like dating a centaur. Totally normal up top, and")}
{" "}<em>{__("way different")}</em> {__("underneath.")}
</p>
<p>Up top, LBRY is similar to popular media sites.</p>
<p>{__("Up top, LBRY is similar to popular media sites.")}</p>
<p>
Below, LBRY is controlled by users -- you -- via blockchain and
decentralization.
{__("Below, LBRY is controlled by users -- you -- via blockchain and decentralization.")}
</p>
<p>
Thank you for making content freedom possible!
{__("Thank you for making content freedom possible!")}
{" "}{isRewardApproved ? __("Here's a nickel, kid.") : ""}
</p>
<div className="text-center">
@ -31,7 +30,7 @@ class WelcomeModal extends React.PureComponent {
: <Link
button="primary"
onClick={closeModal}
label="Continue"
label={__("Continue")}
/>}
</div>
</section>
@ -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}
>
<section>
<h3 className="modal__header">About Your Reward</h3>
<h3 className="modal__header">{__("About Your Reward")}</h3>
<p>
You earned a reward of
{__("You earned a reward of")}
{" "}<CreditAmount amount={reward.reward_amount} label={false} />
{" "}LBRY
credits, or <em>LBC</em>.
{" "}{__("LBRY credits, or")} <em>{__("LBC")}</em>.
</p>
<p>
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.")}
</p>
<p>
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.")}
</p>
<p>
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.")}
</p>
<p>
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.")}
</p>
</section>
</Modal>;

View file

@ -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) &&
<ToolTip
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"
/>}
</h3>

View file

@ -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 (
<span>
{__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*/
)}
</span>
);
if (this.state.topClaimValue === 1) {
return (
<span>
{__(
'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
)}
</span>
);
} else {
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 {
return "";
}
@ -752,7 +758,7 @@ class PublishPage extends React.PureComponent {
/>
<FormRow
label={__("Deposit")}
postfix="LBC"
postfix={__("LBC")}
step="0.01"
min="0"
type="number"

View file

@ -20,7 +20,7 @@ const RewardTile = props => {
</div>
<div className="card__actions">
{claimed
? <span><Icon icon="icon-check" /> Reward claimed.</span>
? <span><Icon icon="icon-check" /> {__("Reward claimed.")}</span>
: <RewardLink reward_type={reward.reward_type} />}
</div>
<div className="card__content">{reward.reward_description}</div>
@ -59,14 +59,13 @@ const RewardsPage = props => {
<div className="empty">
<p>{__("You are not eligible to claim rewards.")}</p>
<p>
To become eligible, email
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" /> with a
link to a public social media profile.
{__("To become eligible, email")}
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("with a link to a public social media profile.")}
</p>
</div>
);
} else if (fetching) {
content = <BusyMessage message="Fetching rewards" />;
content = <BusyMessage message={__("Fetching rewards")} />;
} else if (rewards.length > 0) {
content = rewards.map(reward =>
<RewardTile key={reward.reward_type} reward={reward} />

View file

@ -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",