Switch to use transifex client app
This commit is contained in:
parent
34405b8e61
commit
5d5a664be0
24
.github/CONTRIBUTING.md
vendored
24
.github/CONTRIBUTING.md
vendored
|
@ -4,7 +4,9 @@
|
|||
2. [How to report issues](#how-to-report-issues)
|
||||
3. [Adding translations](#adding-translations)
|
||||
4. [Pull requests](#pull-requests)
|
||||
5. [Contact us](#contact-us)
|
||||
5. [Scripts](#scripts)
|
||||
6. [Updating locale files](#updating-locale-files-admin-only)
|
||||
7. [Contact us](#contact-us)
|
||||
|
||||
## Getting involved
|
||||
|
||||
|
@ -32,6 +34,26 @@ You can help us translate the extension on [Transifex](https://www.transifex.com
|
|||
* Make any changes within a branch of this repository (not the `master` branch).
|
||||
* Submit a pull request and include a reference to the initial issue with the discussion.
|
||||
|
||||
## Scripts
|
||||
|
||||
* `npm run lint` - Run ESLint on all JavaScript files.
|
||||
* `npm run update` - Runs update-node & update-main scripts.
|
||||
* `npm run update-quick` - Updates development dependencies (uses `npm update`; does not include new dependencies).
|
||||
* `npm run update-locales` (admin only)- Updates locale files from Transifex. See the [updating locale files section](#updating-locale-files-admin-only) for more details.
|
||||
* `npm run update-main` - Runs update-versions & update-codemirror.
|
||||
* `npm run update-node` - Update development dependencies, removes & reinstalls `node_modules` folder (slow).
|
||||
* `npm run update-transifex` (admin only) - Upload `en/messages.json` source to Transifex.
|
||||
* `npm run update-vendor` - Update codemirror, codemirror themes & other vendor libraries.
|
||||
* `npm run update-versions` - Update version of `manifest.json` to match `package.json`.
|
||||
* `npm run zip` - Run update-versions, then compress required files into a zip file.
|
||||
|
||||
## Updating locale files (admin only)
|
||||
|
||||
* Make sure you have the Transifex client installed. Follow the instructions on [this page](https://docs.transifex.com/client/installing-the-client).
|
||||
* Contact another admin if you need the `.transifexrc` file in the root folder. It includes the API key to use Transifex's API.
|
||||
* Use `npm run update-locales` in the command line to [update the language files](https://docs.transifex.com/client/pull) in the repo.
|
||||
* Use `npm run update-transifex` in the command line to [upload the source](https://docs.transifex.com/client/push) `en/messages.json` file to Transifex.
|
||||
|
||||
## Contact us
|
||||
|
||||
If you prefer a more informal method of getting in touch or starting a conversation, please [join us on Discord](https://discordapp.com/widget?id=379521691774353408) or leave a comment in the [discussion section](https://add0n.com/stylus.html#reviews). We will monitor any discussions there and join in, and it may be a more appropriate venue for opinions and less urgent suggestions.
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ package-lock.json
|
|||
yarn.lock
|
||||
*.zip
|
||||
.eslintcache
|
||||
.transifexrc
|
||||
|
|
10
.tx/config
Normal file
10
.tx/config
Normal file
|
@ -0,0 +1,10 @@
|
|||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[Stylus.messages]
|
||||
file_filter = _locales/<lang>/messages.json
|
||||
minimum_perc = 0
|
||||
source_file = _locales/en/messages.json
|
||||
source_lang = en_US
|
||||
type = CHROME
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
"semver-bundle": "^0.1.1",
|
||||
"stylelint-bundle": "^8.0.0",
|
||||
"stylus-lang-bundle": "^0.54.5",
|
||||
"unzip": "^0.1.11",
|
||||
"updates": "^4.2.1",
|
||||
"webext-tx-fix": "^0.3.1"
|
||||
},
|
||||
|
@ -25,10 +24,11 @@
|
|||
"lint": "eslint **/*.js --cache || exit 0",
|
||||
"update": "npm run update-node && npm run update-main",
|
||||
"update-quick": "updates -u && npm update && npm run update-main",
|
||||
"update-locales": "node tools/update-locales.js && webext-tx-fix",
|
||||
"update-main": "npm run update-versions && npm run update-codemirror",
|
||||
"update-locales": "tx pull --all && webext-tx-fix",
|
||||
"update-main": "npm run update-versions && npm run update-vendor",
|
||||
"update-node": "updates -u && node tools/remove-modules.js && npm install",
|
||||
"update-codemirror": "node tools/update-libraries.js && node tools/update-codemirror-themes.js",
|
||||
"update-transifex": "tx push -s",
|
||||
"update-vendor": "node tools/update-libraries.js && node tools/update-codemirror-themes.js",
|
||||
"update-versions": "node tools/update-versions",
|
||||
"zip": "npm run update-versions && node tools/zip.js"
|
||||
}
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const unzip = require('unzip');
|
||||
|
||||
const root = path.join(__dirname, '..');
|
||||
const localeFolder = path.join(root, '_locales');
|
||||
const tempFolder = path.join(root, '_temp');
|
||||
const zipFile = path.join(root, 'github-7_Stylus_messages.zip');
|
||||
|
||||
/*
|
||||
* Download transifex zip file into the root folder before running this script
|
||||
* https://docs.transifex.com/projects/downloading-translations#downloading-a-zip-file-with-all-translation-files
|
||||
*/
|
||||
|
||||
async function extractZip() {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
fs
|
||||
.createReadStream(zipFile)
|
||||
.pipe(unzip.Extract({path: tempFolder}))
|
||||
.on('close', () => {
|
||||
resolve()
|
||||
});
|
||||
} catch (error) {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function getFileNames() {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readdir(tempFolder, (error, data) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
// en_US shouldn't ever get updated from Transifex
|
||||
resolve(data.filter(file => !file.includes('en_US')));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function updateMessage(localeFile) {
|
||||
// localeFile ~ "messages_en_GB.json" → en_GB/messages.json
|
||||
const data = await fs.readJson(path.join(tempFolder, localeFile));
|
||||
const localePath = path.join(localeFolder, localeFile.replace('messages_', '').replace('.json', ''));
|
||||
if (!fs.existsSync(localePath)) {
|
||||
fs.mkdirSync(localePath);
|
||||
}
|
||||
return fs.writeFile(
|
||||
path.join(localePath, '/', 'messages.json'),
|
||||
JSON.stringify(cleanup(data), null, 2) + '\n'
|
||||
);
|
||||
}
|
||||
|
||||
// Remove unneeded descriptions
|
||||
function cleanup(data) {
|
||||
Object.keys(data).forEach(entry => {
|
||||
if (data[entry].description) {
|
||||
delete data[entry].description;
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
if (fs.existsSync(zipFile)) {
|
||||
extractZip()
|
||||
.then(() => getFileNames())
|
||||
.then(files => files.map(file => updateMessage(file)))
|
||||
.then(() => fs.remove(tempFolder))
|
||||
.catch(error => console.error(error));
|
||||
} else {
|
||||
console.error('ERROR: Transifex zip file not found in the root folder');
|
||||
}
|
Loading…
Reference in New Issue
Block a user