Skip to content

Commit

Permalink
feat: add experimental atlas to pull_translations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
OmarIthawi committed Apr 4, 2023
1 parent 4cf0c7f commit 5c00ba7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export TRANSIFEX_RESOURCE=frontend-app-learning
transifex_langs = "ar,fr,es_419,zh_CN,pt,it,de,uk,ru,hi,fr_CA"

transifex_utils = ./node_modules/.bin/transifex-utils.js
intl_imports = ./node_modules/.bin/intl-imports.js
i18n = ./src/i18n
transifex_input = $(i18n)/transifex_input.json

Expand Down Expand Up @@ -42,9 +43,26 @@ 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 && mkdir frontend-app-learning && cd frontend-app-learning \
&& atlas pull --directory=translations/frontend-app-learning/src/i18n/messages

cd src/i18n/messages && mkdir frontend-component-footer && cd frontend-component-footer \
&& atlas pull --directory=src/i18n/messages

cd src/i18n/messages && mkdir frontend-component-header && cd frontend-component-header \
&& atlas pull --directory=translations/frontend-component-header/src/i18n/messages

$(intl_imports) frontend-component-header frontend-component-footer frontend-app-learning
endif

# This target is used by Travis.
validate-no-uncommitted-package-lock-changes:
Expand Down
11 changes: 9 additions & 2 deletions src/i18n/index.jsx → src/i18n/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -11,7 +14,7 @@ import hiMessages from './messages/hi.json';
import frCAMessages from './messages/fr_CA.json';
// no need to import en messages-- they are in the defaultMessage field

const messages = {
const appMessages = {
ar: arMessages,
'es-419': es419Messages,
fr: frMessages,
Expand All @@ -25,4 +28,8 @@ const messages = {
uk: ukMessages,
};

export default messages;
export default [
appMessages,
footerMessages,
headerMessages,
];
6 changes: 3 additions & 3 deletions src/i18n/messages/fr_CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@
"tours.existingUserTour.launchTourCheckpoint.body": "Nous avons récemment ajouté des nouvelles fonctions à l'expérience de cours. Vous avez besoin d'aide à les trouver? Prenez un tour guidé pour en apprendre plus.",
"tours.button.dismiss": "Rejeter",
"tours.button.next": "Suivant",
"tours.button.okay": "Okay",
"tours.button.okay": "D'accord",
"tours.button.beginTour": "Commencer la visite guidée",
"tours.button.launchTour": "Lancer la visite guidée",
"tours.newUserModal.body": "Faisons un tour rapide de {siteName} afin que vous puissiez tirer le meilleur parti de votre cours.",
"tours.newUserModal.title.welcome": "Bienvenu à votre",
"tours.newUserModal.title.welcome": "Bienvenue à votre",
"tours.button.skipForNow": "Ignorer pour l'instant",
"tours.datesCheckpoint.body": "Dates importantes afin de vous maintenir sur la bonne voie.",
"tours.datesCheckpoint.title": "Restez au courant des dates importantes",
Expand All @@ -430,7 +430,7 @@
"tours.upgradeCheckpoint.title": "Débloquez votre cours",
"tours.weeklyGoalsCheckpoint.body": "Paramétrer un objectif encourage à compléter votre cours.",
"tours.weeklyGoalsCheckpoint.title": "Paramétrer un objectif de cours",
"tours.newUserModal.title": "{welcome} {siteName} au cours!",
"tours.newUserModal.title": "{welcome} cours sur {siteName} !",
"learning.effortEstimation.combinedEstimate": "{minutes} + {activities}",
"learning.effortEstimation.activities": "{activityCount, plural, one {# activité} many {# activités} other {# activités}}",
"learning.effortEstimation.minutesAbbreviated": "{minuteCount, plural, one {# min} many {# min} other {# min}}",
Expand Down
10 changes: 2 additions & 8 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -139,9 +137,5 @@ initialize({
}, 'LearnerAppConfig');
},
},
messages: [
appMessages,
footerMessages,
headerMessages,
],
messages,
});

0 comments on commit 5c00ba7

Please sign in to comment.