-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from edx/abutterworth/add-i18n-pipeline-tools
feat: add i18n pipeline tools
- Loading branch information
Showing
15 changed files
with
154 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
coverage | ||
dist | ||
node_modules | ||
temp | ||
src/i18n/transifex_input.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[main] | ||
host = https://www.transifex.com | ||
|
||
[edx-platform.frontend-component-header] | ||
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 |
---|---|---|
@@ -1,7 +1,58 @@ | ||
transifex_resource = frontend-component-header | ||
transifex_langs = "ar,fr,es_419,zh_CN" | ||
|
||
transifex_utils = ./node_modules/.bin/transifex-utils.js | ||
i18n = ./src/i18n | ||
transifex_input = $(i18n)/transifex_input.json | ||
tx_url1 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/translation/en/strings/ | ||
tx_url2 = https://www.transifex.com/api/2/project/edx-platform/resource/$(transifex_resource)/source/ | ||
|
||
# This directory must match .babelrc . | ||
transifex_temp = ./temp/babel-plugin-react-intl | ||
|
||
build: | ||
rm -rf ./dist | ||
./node_modules/.bin/babel src --out-dir dist --source-maps --ignore **/*.test.jsx,**/__mocks__,**/__snapshots__,**/setupTest.js --copy-files | ||
# --copy-files will bring in everything else that wasn't processed by babel. Remove what we don't want. | ||
rm -rf dist/**/*.test.jsx | ||
rm -rf dist/**/__snapshots__ | ||
rm -rf dist/__mocks__ | ||
@# --copy-files will bring in everything else that wasn't processed by babel. Remove what we don't want. | ||
@rm -rf dist/**/*.test.jsx | ||
@rm -rf dist/**/__snapshots__ | ||
@rm -rf dist/__mocks__ | ||
|
||
requirements: | ||
npm install | ||
|
||
i18n.extract: | ||
# Pulling display strings from .jsx files into .json files... | ||
rm -rf $(transifex_temp) | ||
npm run-script i18n_extract | ||
|
||
i18n.concat: | ||
# Gathering JSON messages into one file... | ||
$(transifex_utils) $(transifex_temp) $(transifex_input) | ||
|
||
extract_translations: | requirements i18n.extract i18n.concat | ||
|
||
# Despite the name, we actually need this target to detect changes in the incoming translated message files as well. | ||
detect_changed_source_translations: | ||
# Checking for changed translations... | ||
git diff --exit-code $(i18n) | ||
|
||
# Pushes translations to Transifex. You must run make extract_translations first. | ||
push_translations: | ||
# Pushing strings to Transifex... | ||
tx push -s | ||
# Fetching hashes from Transifex... | ||
./node_modules/reactifex/bash_scripts/get_hashed_strings.sh $(tx_url1) | ||
# Writing out comments to file... | ||
$(transifex_utils) $(transifex_temp) --comments | ||
# Pushing comments to Transifex... | ||
./node_modules/reactifex/bash_scripts/put_comments.sh $(tx_url2) | ||
|
||
# Pulls translations from Transifex. | ||
pull_translations: | ||
tx pull -f --mode reviewed --language=$(transifex_langs) | ||
|
||
# This target is used by Travis. | ||
validate-no-uncommitted-package-lock-changes: | ||
# Checking for package-lock.json 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
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,8 @@ | ||
# openedx.yaml | ||
|
||
--- | ||
owner: edx/fedx-team | ||
tags: | ||
- library | ||
- component | ||
- react |
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,18 @@ | ||
import arMessages from './messages/ar.json'; | ||
// no need to import en messages-- they are in the defaultMessage field | ||
import es419Messages from './messages/es_419.json'; | ||
import frMessages from './messages/fr.json'; | ||
import kokrMessages from './messages/ko_KR.json'; | ||
import ptbrMessages from './messages/pt_BR.json'; | ||
import zhcnMessages from './messages/zh_CN.json'; | ||
|
||
const messages = { | ||
ar: arMessages, | ||
'es-419': es419Messages, | ||
fr: frMessages, | ||
'zh-cn': zhcnMessages, | ||
'ko-kr': kokrMessages, | ||
'pt-br': ptbrMessages, | ||
}; | ||
|
||
export default messages; |
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,2 @@ | ||
{ | ||
} |
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,2 @@ | ||
{ | ||
} |
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,2 @@ | ||
{ | ||
} |
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,2 @@ | ||
{ | ||
} |
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,2 @@ | ||
{ | ||
} |
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,2 @@ | ||
{ | ||
} |