-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial localization of footer
BREAKING CHANGE: Now requires containing app to use `react-intl`. See update to README for details. ARCH-460
- Loading branch information
Showing
14 changed files
with
870 additions
and
239 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
coverage | ||
dist | ||
node_modules | ||
temp | ||
|
||
.idea/ |
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,8 @@ | ||
[main] | ||
host = https://www.transifex.com | ||
|
||
[edx-platform.frontend-component-footer] | ||
file_filter = "src/i18n/messages/<lang>.json" | ||
source_file = "src/i18n/transifex_input.json" | ||
source_lang = en | ||
type = KEYVALUEJSON |
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,36 @@ | ||
extract_translations: ## no prerequisites so we can control order of operations | ||
echo "We have to define this target due to tooling assumptions" | ||
echo "Also we have to npm install using this hook b/c there's no other place for it in the current setup" | ||
npm install | ||
npm run-script i18n_extract | ||
|
||
i18n.extract: | ||
# Pulling display strings from .jsx files into .json files... | ||
npm run-script i18n_extract | ||
|
||
i18n.concat: | ||
# Gathering JSON messages into one file... | ||
./src/i18n/i18n-concat.js ./temp/src ./src/i18n/transifex_input.json | ||
|
||
i18n.pre_validate: | i18n.extract i18n.concat | ||
git diff --exit-code ./src/i18n/transifex_input.json | ||
|
||
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/frontend-component-footer/translation/en/strings/ | ||
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/frontend-component-footer/source/ | ||
|
||
# push translations to Transifex, doing magic so we can include the translator comments | ||
push_translations: | i18n.extract | ||
# Adding translator comments... | ||
# Fetching strings from Transifex... | ||
./node_modules/reactifex/bash_scripts/get_hashed_strings.sh $(tx_url1) | ||
# Writing out comments to file... | ||
./src/i18n/i18n-concat.js ./temp/src --comments | ||
# Adding comments to Transifex... | ||
./node_modules/reactifex/bash_scripts/put_comments.sh $(tx_url2) | ||
|
||
# pull translations from Transifex | ||
pull_translations: ## must be exactly this name for edx tooling support, see ecommerce-scripts/transifex/pull.py | ||
tx pull -f --mode reviewed --language="ar,fr,es_419,zh_CN" | ||
|
||
validate-no-uncommitted-package-lock-changes: | ||
git diff --exit-code package-lock.json |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,57 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* This code originally came from https://github.com/efischer19/reactifex/blob/master/main.js, | ||
* which should be edx/reactifex. It is temporarily being copied here until we find it a new home. | ||
*/ | ||
|
||
// NOTE: This script is called from Jenkins using devDependencies, so eslint is being | ||
// disabled so it doesn't force you to make these real dependencies. | ||
const fs = require('fs'); // eslint-disable-line import/no-extraneous-dependencies | ||
const glob = require('glob'); // eslint-disable-line import/no-extraneous-dependencies | ||
const path = require('path'); // eslint-disable-line import/no-extraneous-dependencies | ||
|
||
// Expected input: a directory, possibly containing subdirectories, with .json files. Each .json | ||
// file is an array of translation triplets (id, description, defaultMessage). | ||
function gatherJson(dir) { | ||
const ret = []; | ||
const files = glob.sync(`${dir}/**/*.json`); | ||
|
||
files.forEach((filename) => { | ||
const messages = JSON.parse(fs.readFileSync(filename)); | ||
ret.push(...messages); | ||
}); | ||
return ret; | ||
} | ||
|
||
const jsonDir = process.argv[2]; | ||
const messageObjects = gatherJson(jsonDir); | ||
|
||
if (process.argv[3] === '--comments') { // prepare to handle the translator notes | ||
const thisFile = path.basename(`${__filename}`); | ||
const bashScriptsPath = './node_modules/reactifex/bash_scripts'; | ||
|
||
process.stdout.write(`${thisFile}: generating bash scripts...\n`); | ||
process.stdout.write(`${thisFile}: info file at ${bashScriptsPath}/hashmap.json\n`); | ||
|
||
const messageInfo = JSON.parse(fs.readFileSync(`${bashScriptsPath}/hashmap.json`)); | ||
const dataPath = `${bashScriptsPath}/hashed_data.txt`; | ||
|
||
process.stdout.write(`${thisFile}: data path is ${dataPath}\n`); | ||
fs.writeFileSync(dataPath, ''); | ||
|
||
messageObjects.forEach((message) => { | ||
const info = messageInfo.find(mi => mi.key === message.id); | ||
if (info) { | ||
fs.appendFileSync(dataPath, `${info.string_hash}|${message.description}\n`); | ||
} else { | ||
process.stdout.write(`${thisFile}: string ${message.id} does not yet exist on transifex!\n`); | ||
} | ||
}); | ||
} else { | ||
const output = {}; | ||
|
||
messageObjects.forEach((message) => { | ||
output[message.id] = message.defaultMessage; | ||
}); | ||
fs.writeFileSync(process.argv[3], JSON.stringify(output, null, 2)); | ||
} |
Oops, something went wrong.