From d2de0632cdf78bf31e9072b5a2c82e15b8f977fb Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Tue, 9 May 2023 17:03:42 +0300 Subject: [PATCH] feat: add experimental atlas to pull_translations (#1093) This is an experimental off-by-defualt feature for moving the translation files ouside the repos. Run `OPENEDX_ATLAS_PULL=true make translations` to use atlas to pull translations instead of transifex. Refs: FC-12 OEP-58 --- Makefile | 15 +++++++++++++++ src/i18n/{index.jsx => index.js} | 11 +++++++++-- src/index.jsx | 10 ++-------- src/setupTest.js | 4 ++-- 4 files changed, 28 insertions(+), 12 deletions(-) rename src/i18n/{index.jsx => index.js} (81%) diff --git a/Makefile b/Makefile index 5d139dee2e..3008e5bfa1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ export TRANSIFEX_RESOURCE=frontend-app-learning transifex_langs = "ar,fr,es_419,zh_CN,pt,it,de,uk,ru,hi,fa_IR,fr_CA,it_IT,pt_PT,de_DE" +intl_imports = ./node_modules/.bin/intl-imports.js transifex_utils = ./node_modules/.bin/transifex-utils.js i18n = ./src/i18n transifex_input = $(i18n)/transifex_input.json @@ -42,9 +43,23 @@ push_translations: # Pushing comments to Transifex... ./node_modules/@edx/reactifex/bash_scripts/put_comments_v3.sh +ifeq ($(OPENEDX_ATLAS_PULL),) # Pulls translations from Transifex. pull_translations: tx pull -f --mode reviewed --languages=$(transifex_langs) +else +# Experimental: OEP-58 Pulls translations using atlas +pull_translations: + rm -rf src/i18n/messages + mkdir src/i18n/messages + cd src/i18n/messages \ + && atlas pull --filter=$(transifex_langs) \ + translations/frontend-component-header/src/i18n/messages:frontend-component-header \ + translations/frontend-component-footer/src/i18n/messages:frontend-component-footer \ + translations/frontend-app-learning/src/i18n/messages:frontend-app-learning + + $(intl_imports) frontend-component-header frontend-component-footer frontend-app-learning +endif # This target is used by Travis. validate-no-uncommitted-package-lock-changes: diff --git a/src/i18n/index.jsx b/src/i18n/index.js similarity index 81% rename from src/i18n/index.jsx rename to src/i18n/index.js index dd591ef6cb..f2ccf69ca4 100644 --- a/src/i18n/index.jsx +++ b/src/i18n/index.js @@ -1,3 +1,6 @@ +import { messages as footerMessages } from '@edx/frontend-component-footer'; +import { messages as headerMessages } from '@edx/frontend-component-header'; + import arMessages from './messages/ar.json'; import frMessages from './messages/fr.json'; import es419Messages from './messages/es_419.json'; @@ -15,7 +18,7 @@ import ititCAMessages from './messages/it_IT.json'; import ptptCAMessages from './messages/pt_PT.json'; // no need to import en messages-- they are in the defaultMessage field -const messages = { +const appMessages = { ar: arMessages, 'es-419': es419Messages, fr: frMessages, @@ -33,4 +36,8 @@ const messages = { 'pt-pt': ptptCAMessages, }; -export default messages; +export default [ + appMessages, + footerMessages, + headerMessages, +]; diff --git a/src/index.jsx b/src/index.jsx index 7fec13b112..a509e1f6a8 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -11,13 +11,11 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Switch } from 'react-router-dom'; -import { messages as footerMessages } from '@edx/frontend-component-footer'; -import { messages as headerMessages } from '@edx/frontend-component-header'; import { Helmet } from 'react-helmet'; import { fetchDiscussionTab, fetchLiveTab } from './course-home/data/thunks'; import DiscussionTab from './course-home/discussion-tab/DiscussionTab'; -import appMessages from './i18n'; +import messages from './i18n'; import { UserMessagesProvider } from './generic/user-messages'; import './index.scss'; @@ -142,9 +140,5 @@ initialize({ }, 'LearnerAppConfig'); }, }, - messages: [ - appMessages, - footerMessages, - headerMessages, - ], + messages, }); diff --git a/src/setupTest.js b/src/setupTest.js index 82aa7226e0..0e21e899a0 100755 --- a/src/setupTest.js +++ b/src/setupTest.js @@ -19,7 +19,7 @@ import { reducer as coursewareReducer } from './courseware/data/slice'; import { reducer as modelsReducer } from './generic/model-store'; import { UserMessagesProvider } from './generic/user-messages'; -import appMessages from './i18n'; +import messages from './i18n'; import { fetchCourse, fetchSequence } from './courseware/data'; import { appendBrowserTimezoneToUrl, executeThunk } from './utils'; import buildSimpleCourseAndSequenceMetadata from './courseware/data/__factories__/sequenceMetadata.factory'; @@ -78,7 +78,7 @@ export function initializeMockApp() { configureI18n({ config: getConfig(), loggingService, - messages: [appMessages], + messages, }); return { loggingService, authService };