diff --git a/tutormfe/templates/mfe/build/mfe/Dockerfile b/tutormfe/templates/mfe/build/mfe/Dockerfile index 732000f2..33e88a49 100644 --- a/tutormfe/templates/mfe/build/mfe/Dockerfile +++ b/tutormfe/templates/mfe/build/mfe/Dockerfile @@ -20,16 +20,6 @@ RUN mkdir -p /openedx/app /openedx/env WORKDIR /openedx/app ENV PATH /openedx/app/node_modules/.bin:${PATH} -######## i18n strings -FROM base AS i18n -COPY ./i18n /openedx/i18n -RUN chmod a+x /openedx/i18n/*.js -RUN echo "copying i18n data" \ - {%- for app_name, app in iter_mfes() %} - && mkdir -p /openedx/i18n/{{ app_name }} \ - {%- endfor %} - echo "done." - {% for app_name, app in iter_mfes() %} ####################### {{ app_name }} MFE ######## {{ app_name }} (git) @@ -42,14 +32,6 @@ ADD --keep-git-dir=true {{ app["repository"] }}#{{ app.get("version", MFE_COMMON FROM scratch as {{ app_name }}-src COPY --from={{ app_name }}-git /openedx/app / -######## {{ app_name }} (i18n) -FROM base AS {{ app_name }}-i18n -COPY --from={{ app_name }}-src / /openedx/app -COPY --from=i18n /openedx/i18n/{{ app_name }} /openedx/i18n/{{ app_name }} -COPY --from=i18n /openedx/i18n/i18n-merge.js /openedx/i18n/i18n-merge.js -RUN stat /openedx/app/src/i18n/messages 2> /dev/null || (echo "missing messages folder" && mkdir -p /openedx/app/src/i18n/messages) -RUN /openedx/i18n/i18n-merge.js /openedx/app/src/i18n/messages /openedx/i18n/{{ app_name }} /openedx/app/src/i18n/messages - ######## {{ app_name }} (common) FROM base AS {{ app_name }}-common COPY --from={{ app_name }}-src /package.json /openedx/app/package.json @@ -65,12 +47,11 @@ RUN --mount=type=cache,target=/root/.npm,sharing=shared npm clean-install --no-a {{ patch("mfe-dockerfile-post-npm-install") }} {{ patch("mfe-dockerfile-post-npm-install-{}".format(app_name)) }} COPY --from={{ app_name }}-src / /openedx/app -COPY --from={{ app_name }}-i18n /openedx/app/src/i18n/messages /openedx/app/src/i18n/messages # Whenever a new MFE supports Atlas, it should be added to this list. # When all MFEs support Atlas, this if-statement should be removed. {% if app_name in ["communications"] %} -RUN make OPENEDX_ATLAS_PULL=true pull_translations +RUN make OPENEDX_ATLAS_PULL=true ATLAS_OPTIONS="--repository={{ ATLAS_REPOSITORY }} --branch={{ ATLAS_REVISION }} {{ ATLAS_OPTIONS }}" pull_translations {% endif %} EXPOSE {{ app['port'] }} diff --git a/tutormfe/templates/mfe/build/mfe/i18n/i18n-merge.js b/tutormfe/templates/mfe/build/mfe/i18n/i18n-merge.js deleted file mode 100755 index c8cceda5..00000000 --- a/tutormfe/templates/mfe/build/mfe/i18n/i18n-merge.js +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/env node -// Add to the current folder your custom translation strings, with the following file hierarchy: -// -// i18n/ -// / -// .json -// -// For instance, to override French strings from the payment app: -// -// i18n/ -// payment/ -// fr.json -// -// Your custom translation strings will automatically be compiled in the MFE Docker image. - -const fs = require('fs'); -const path = require('path'); - -function main() { - // Merge the messages from multiple directories and aggregate the content in a single directory. - // This is certainly not great idiomatic nodejs code. Please open a PR to improve this bit! - merge(process.argv[2], process.argv[3], process.argv[4]) -} - -function merge(dir1, dir2, outputDir) { - fs.readdirSync(dir1, { - withFileTypes: true - }).forEach(file1 => { - if (file1.isFile() && file1.name.endsWith(".json")) { - var path1 = path.resolve(path.join(dir1, file1.name)); - var data1 = require(path1); - var path2 = path.resolve(path.join(dir2, file1.name)); - fs.access(path2, (err) => { - if (err) { - return; - } - var pathOutput = path.resolve(path.join(outputDir, file1.name)); - console.log("Merging i18 strings from " + path1 + " with " + path2 + " to " + pathOutput); - var data2 = require(path2); - var final = Object.assign(data1, data2); - fs.writeFileSync(pathOutput, JSON.stringify(final, null, 2)); - }); - } - }); -} - -main()