This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Extract i18n string into i18n/_defaults (base of translations) #4514
Merged
Merged
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
63becf6
Build script to pull i18n into i18n/_default
jacogr 8ef68d1
Fix header
jacogr eedfd11
Current strings as extracted
jacogr 70b67cb
details_windows without prefix
jacogr 4058159
clean before build
jacogr 05e1edd
Alwasy extract babel strings
jacogr f72dcec
clean & run build before extraction
jacogr 5b5f71d
Update settings messages
jacogr bd96203
Put back template string (PR comment)
jacogr b1c76ad
PR comment cleanups & logging
jacogr e3944a8
Merge branch 'master' into jg-extract-strings
jacogr 64175d4
Less complicated string type check (PR comment)
jacogr ab1bf72
Remove node cache to extract all keys (Thanks @ngotchac)
jacogr 57c6c99
Merge in defaults from i18n/en (Comment by @h3ll0fr13nd)
jacogr 0499ebd
Unique index keys only
jacogr 69418b8
Update with latest master strings
jacogr 3797382
_.defaultsDeep (Thanks to @dehurst)
jacogr d1924ea
Use to-source for string formatting
jacogr 37841dc
Merge branch 'master' into jg-extract-strings
jacogr aac2dff
Sync with toSource output on latest master
jacogr aea08a2
Updated to use/output sorted objects
jacogr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
import i18nstrings from '../.build/i18n/i18n/en.json'; | ||
|
||
const FILE_HEADER = '// Copyright 2015-2017 Parity Technologies (UK) Ltd.\n// This file is part of Parity.\n\n// Parity is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n\n// Parity is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n\n// You should have received a copy of the GNU General Public License\n// along with Parity. If not, see <http://www.gnu.org/licenses/>.\n\n'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could use template string here, would be more readable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually did have it that way around, will put it back. (Don't expect to edit it at all, but still more readable.) |
||
const SECTION_HEADER = 'export default '; | ||
const SECTION_FOOTER = ';\n'; | ||
const INDENT = ' '; | ||
const I18NPATH = path.join(__dirname, '../src/i18n/_default'); | ||
|
||
// FIXME: Expanding it this way is probably not quite optimal, some would say hacky. | ||
// However JSON.stringify (the sane solution) let us end up with both the keys | ||
// and values with "'s which is not intended. We want keys without and values with ` | ||
// (Better idea welcome, at this point not critical since we control inputs) | ||
function createExportString (section, indent) { | ||
if (Object.prototype.toString.call(section) === '[object String]') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (typeof section === 'string') |
||
return `\`${section}\``; | ||
} | ||
|
||
const keys = Object | ||
.keys(section) | ||
.sort() | ||
.map((key) => { | ||
return `${indent}${key}: ${createExportString(section[key], indent + INDENT)}`; | ||
}) | ||
.join(',\n'); | ||
|
||
return `{\n${keys}\n${indent.substr(2)}}`; | ||
} | ||
|
||
const sections = {}; | ||
|
||
// create an object map of the actual inputs | ||
Object.keys(i18nstrings).forEach((fullKey) => { | ||
const defaultMessage = i18nstrings[fullKey].defaultMessage; | ||
const keys = fullKey.split('.'); | ||
let outputs = sections; | ||
|
||
keys.forEach((key, index) => { | ||
if (index === keys.length - 1) { | ||
outputs[key] = defaultMessage; | ||
} else { | ||
if (!outputs[key]) { | ||
outputs[key] = {}; | ||
} | ||
|
||
outputs = outputs[key]; | ||
} | ||
}); | ||
}); | ||
|
||
// create the index.js file | ||
const sectionKeys = Object.keys(sections).sort(); | ||
const exports = sectionKeys | ||
.map((key) => { | ||
return `export ${key} from './${key}';`; | ||
}) | ||
.join('\n'); | ||
|
||
fs.writeFileSync(path.join(I18NPATH, 'index.js'), `${FILE_HEADER}${exports}\n`, 'utf8'); | ||
|
||
// create the individual section files | ||
sectionKeys.forEach((key) => { | ||
// const sectionText = JSON.stringify(sections[key], null, 2); | ||
const sectionText = createExportString(sections[key], INDENT); | ||
|
||
fs.writeFileSync(path.join(I18NPATH, `${key}.js`), `${FILE_HEADER}${SECTION_HEADER}${sectionText}${SECTION_FOOTER}`, 'utf8'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
button: { | ||
delete: `delete account`, | ||
edit: `edit`, | ||
password: `password`, | ||
shapeshift: `shapeshift`, | ||
transfer: `transfer`, | ||
verify: `verify` | ||
}, | ||
header: { | ||
outgoingTransactions: `{count} outgoing transactions`, | ||
uuid: `uuid: {uuid}` | ||
}, | ||
title: `Account Management`, | ||
transactions: { | ||
poweredBy: `Transaction list powered by {etherscan}`, | ||
title: `transactions` | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
summary: { | ||
minedBlock: `Mined at block #{blockNumber}` | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
button: { | ||
add: `Save Address`, | ||
close: `Cancel` | ||
}, | ||
input: { | ||
address: { | ||
hint: `the network address for the entry`, | ||
label: `network address` | ||
}, | ||
description: { | ||
hint: `an expanded description for the entry`, | ||
label: `(optional) address description` | ||
}, | ||
name: { | ||
hint: `a descriptive name for the entry`, | ||
label: `address name` | ||
} | ||
}, | ||
label: `add saved address` | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
abi: { | ||
hint: `the abi for the contract`, | ||
label: `contract abi` | ||
}, | ||
abiType: { | ||
custom: { | ||
description: `Contract created from custom ABI`, | ||
label: `Custom Contract` | ||
}, | ||
multisigWallet: { | ||
description: `Ethereum Multisig contract {link}`, | ||
label: `Multisig Wallet`, | ||
link: `see contract code` | ||
}, | ||
token: { | ||
description: `A standard {erc20} token`, | ||
erc20: `ERC 20`, | ||
label: `Token` | ||
} | ||
}, | ||
address: { | ||
hint: `the network address for the contract`, | ||
label: `network address` | ||
}, | ||
button: { | ||
add: `Add Contract`, | ||
cancel: `Cancel`, | ||
next: `Next`, | ||
prev: `Back` | ||
}, | ||
description: { | ||
hint: `an expanded description for the entry`, | ||
label: `(optional) contract description` | ||
}, | ||
name: { | ||
hint: `a descriptive name for the contract`, | ||
label: `contract name` | ||
}, | ||
title: { | ||
details: `enter contract details`, | ||
type: `choose a contract type` | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
fromEmail: `Verified using email {email}`, | ||
fromRegistry: `{name} (from registry)`, | ||
labels: { | ||
accounts: `accounts`, | ||
contacts: `contacts`, | ||
contracts: `contracts` | ||
}, | ||
noAccount: `No account matches this query...` | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
status: { | ||
consensus: { | ||
capable: `Capable`, | ||
capableUntil: `Capable until #{blockNumber}`, | ||
incapableSince: `Incapable since #{blockNumber}`, | ||
unknown: `Unknown capability` | ||
}, | ||
upgrade: `Upgrade` | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
connectingAPI: `Connecting to the Parity Secure API.`, | ||
connectingNode: `Connecting to the Parity Node. If this informational message persists, please ensure that your Parity node is running and reachable on the network.`, | ||
invalidToken: `invalid signer token`, | ||
noConnection: `Unable to make a connection to the Parity Secure API. To update your secure token or to generate a new one, run {newToken} and supply the token below`, | ||
token: { | ||
hint: `a generated token from Parity`, | ||
label: `secure token` | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2015-2017 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
|
||
// Parity is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
export default { | ||
minedBlock: `Mined at block #{blockNumber}` | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
babel-node
used only for theseimport
s ? If it is, could use require I think...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const/let is supported, so only imports. I would prefer keeping the import just for code-base consistency. (Although there is a slight compiler indirection involved here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really mind but it adds quite some work for not so much. All the other scripts are using standard Node syntax