Skip to content

Commit

Permalink
♻️(frontend) remove usage of react-intl-po
Browse files Browse the repository at this point in the history
Using react-intl-po with new version of react-intl was not working
anymore. In order to remove the usage of react-intl-po we entirely our
i18 workflow. Everythin is managed using react-intl cli tool. In a first
step it extract messages, this messages are uploaded on crowdin and then
compiled once translated.
  • Loading branch information
jbpenrath committed Oct 30, 2020
1 parent 4ab8eb7 commit 09bf400
Show file tree
Hide file tree
Showing 23 changed files with 802 additions and 981 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
name: Lint code with bandit
command: ~/.local/bin/bandit -qr src/richie/apps src/richie/plugins sandbox

# Restore front & back POT files containing strings to translate and upload them to our
# Restore back POT & front json files containing strings to translate and upload them to our
# translation management tool
upload-i18n-strings:
docker:
Expand Down Expand Up @@ -457,12 +457,12 @@ jobs:
name: Build application styles
command: yarn sass
- run:
name: Use react-intl-po to generate our frontend.pot file
command: yarn generate-l10n-template
name: Use formatjs-cli to generate frontend.json file
command: yarn extract-translations
- persist_to_workspace:
root: ~/fun
paths:
- src/frontend/i18n/frontend.pot
- src/frontend/i18n/frontend.json
- save_cache:
paths:
- ./node_modules
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ node_modules
yarn-error.log

# Exported strings & generated translation templates
src/frontend/i18n/js
*.pot
src/frontend/i18n/frontend.json

# Documentation related files to ignore
lib/core/metadata.js
Expand Down
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]

### Fixed
- has_connected_lms crashed when course_run is blank

- has_connected_lms crashed when course_run is blank
- Avoid stretching of footer menu items

### Added
- Allow use of columns in footer menu items

- Allow use of columns in footer menu items

### Changed
- Avoid stretching of footer menu items

- Remove react-intl-po
- Rework front i18n workflow

## [2.0.0-beta.16] - 2020-10-23

Expand Down Expand Up @@ -141,7 +146,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- Lowered down global 'h1' and 'h2' font size and added new
'extra-font-size' variable with previous h1 value.
- Adjust title size 'large_banner' variants.
- Fix accordion button 'nested-item\_\_title' alignment to the left.
- Fix accordion button 'nested-item__title' alignment to the left.
- Another attempt to definitively fix the glitch with wave decoration
and Chrome zoom/unzoom.
- Add a little bit of space between banner and title on organization
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ COPY ./src/frontend /builder/src/frontend
WORKDIR /builder/src/frontend

RUN yarn install --frozen-lockfile && \
yarn compile-translations && \
yarn build-production && \
yarn sass-production

Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ build-sass: ## build Sass files to CSS
.PHONY: build-sass

build-ts: ## build TypeScript application
@$(YARN) compile-translations
@$(YARN) build
.PHONY: build-ts

Expand Down Expand Up @@ -258,7 +259,7 @@ i18n-compile-back:
.PHONY: i18n-compile-back

i18n-compile-front:
@$(YARN) generate-translations
@$(YARN) compile-translations
.PHONY: i18n-compile-front

i18n-download-and-compile: ## download all translated messages and compile them to be used by all applications
Expand All @@ -284,7 +285,7 @@ i18n-generate-back:
.PHONY: i18n-generate-back

i18n-generate-front: build-ts
@$(YARN) generate-l10n-template
@$(YARN) extract-translations
.PHONY: i18n-generate-front

# -- Misc
Expand Down
6 changes: 3 additions & 3 deletions crowdin/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ files: [
translation : "/richie/locale/%locale_with_underscore%/LC_MESSAGES/django.po",
},
{
source : "/frontend/i18n/frontend.pot",
dest: "/frontend.pot",
translation : "/frontend/js/translations/%locale%.po",
source : "/frontend/i18n/frontend.json",
dest: "/frontend.json",
translation : "/frontend/i18n/locales/%locale%.json",
}
]
5 changes: 4 additions & 1 deletion src/frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"jsx": true
}
},
"plugins": ["@typescript-eslint"],
"plugins": ["formatjs", "@typescript-eslint"],
/* Disable some rules to be iso with tslint which was previously used */
"rules": {
"@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }],
Expand All @@ -37,6 +37,9 @@
"arrow-parens": "error",
"consistent-return": "off",
"default-case": "off",
"formatjs/no-multiple-whitespaces": "error",
"formatjs/enforce-description": "error",
"formatjs/enforce-default-message": "error",
"global-require": "off",
"import/extensions": "off",
"import/no-cycle": ["off"],
Expand Down
1 change: 1 addition & 0 deletions src/frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
js/translations/*
i18n/**/*
public-path.js
4 changes: 3 additions & 1 deletion src/frontend/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ module.exports = {
[
'react-intl',
{
messagesDir: './i18n',
ast: true,
extractFromFormatMessageCall: true,
idInterpolationPattern: '[sha512:contenthash:base64:6]',
},
],
['@babel/plugin-syntax-dynamic-import'],
Expand Down
166 changes: 166 additions & 0 deletions src/frontend/i18n/locales/es-ES.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"components.CourseGlimpse.cover": {
"description": "Placeholder text when the course we are glimpsing at is missing a cover image",
"message": "Portada"
},
"components.CourseGlimpseList.courseCount": {
"description": "Result count & pagination information for course search. Appears right above search results",
"message": "Mostrando {start, number} a {end, number} de {courseCount, number} ¡ {courseCount, plural, one {curso} other {cursos}} que coinciden con su búsqueda"
},
"components.CourseRunEnrollment.enroll": {
"description": "CTA for users who can enroll in the course run or could enroll if they logged in.",
"message": ""
},
"components.CourseRunEnrollment.enrolled": {
"description": "Help text for users who see the \"Go to course\" CTA on course run enrollment",
"message": ""
},
"components.CourseRunEnrollment.enrollmentClosed": {
"description": "Help text replacing the CTA on a course run when enrollment is closed.",
"message": ""
},
"components.CourseRunEnrollment.enrollmentFailed": {
"description": "Help text below the \"Enroll now\" CTA when an enrollment attempt has already failed.",
"message": ""
},
"components.CourseRunEnrollment.goToCourse": {
"description": "CTA for users who are already enrolled in a course run.",
"message": ""
},
"components.CourseRunEnrollment.loadingInitial": {
"description": "Accessible text for the initial loading spinner on the course run enrollment button.",
"message": ""
},
"components.CourseRunEnrollment.loginToEnroll": {
"description": "Helper text in the enroll button for non logged in users",
"message": ""
},
"components.DesktopUserMenu.menuPurpose": {
"description": "Accessible label for user menu button",
"message": ""
},
"components.LanguageSelector.currentlySelected": {
"description": "Accessible hint to mark the currently selected language in the language selector",
"message": ""
},
"components.LanguageSelector.languages": {
"description": "Default text for the language selector button when the current language cannot be identified",
"message": ""
},
"components.LanguageSelector.selectLanguage": {
"description": "Accessible label for the language selector button",
"message": ""
},
"components.LanguageSelector.switchToLanguage": {
"description": "Accessible link title for the language switching links in language selector",
"message": ""
},
"components.PaginateCourseSearch.currentlyReadingLastPageN": {
"description": "Accessibility helper in pagination, shown next to the current page number when it is the last page.",
"message": "Leyendo la última página {page}"
},
"components.PaginateCourseSearch.currentlyReadingPageN": {
"description": "Accessibility helper in pagination, shown next to the current page number when it is not the last page.",
"message": "Actualmente leyendo la página {page}"
},
"components.PaginateCourseSearch.lastPageN": {
"description": "Accessibility helper for pagination, added on the last page link.",
"message": "Última página {page}"
},
"components.PaginateCourseSearch.nextPageN": {
"description": "Accessibility helper for pagination, added on the next page link.",
"message": "Página {page}"
},
"components.PaginateCourseSearch.pageN": {
"description": "Accessibility helper for pagination, added on all page links for screen readers,\n only shown next to \"page 1\" visually.",
"message": "Página {page}"
},
"components.PaginateCourseSearch.pagination": {
"description": "Label for the pagination navigation in course search results.",
"message": "Paginación"
},
"components.PaginateCourseSearch.previousPageN": {
"description": "Accessibility helper for pagination, added on the previous page link.",
"message": "Página anterior {page}"
},
"components.RootSearchSuggestField.searchFieldPlaceholder": {
"description": "Placeholder text displayed in the search field when it is empty.",
"message": "Buscar cursos"
},
"components.Search.errorMessage": {
"description": "Error message for Search view when the request to load courses fails",
"message": ""
},
"components.Search.hideFiltersPane": {
"description": "Accessibility text for the button/icon that toggles *off* the filters pane on mobile",
"message": "Ocultar panel de filtros"
},
"components.Search.showFiltersPane": {
"description": "Accessibility text for the button/icon that toggles *on* the filters pane on mobile",
"message": "Mostrar panel de filtros"
},
"components.Search.spinnerText": {
"description": "Accessibility text for the spinner while search results are being loaded",
"message": "Cargando resultados de búsqueda..."
},
"components.SearchFilterGroupModal.closeModal": {
"description": "Text for the button to close the search filters modal",
"message": "Cerrar"
},
"components.SearchFilterGroupModal.error": {
"description": "Error message when the search for more filter value fails in the search filters modal.",
"message": "Se ha producido un error al buscar {filterName}."
},
"components.SearchFilterGroupModal.modalTitle": {
"description": "Title for the modal to add more filter values in the search filters modal.",
"message": "Añadir filtros para {filterName}"
},
"components.SearchFilterGroupModal.moreOptionsButton": {
"description": "Test for the button to see more filter values than the top N that appear by default.",
"message": "Más opciones"
},
"components.SearchFilterGroupModal.queryTooShort": {
"description": "Users need to enter at least 3 characters to search for more filter values; this message informs them when they start typing.",
"message": "Escriba por lo menos 3 caracteres para iniciar la búsqueda."
},
"components.SearchFilterValueParent.ariaHideChildren": {
"description": "Accessibility message for the button to hide children of the current filter",
"message": "Ocultar filtros adicionales para {filterValueName}"
},
"components.SearchFilterValueParent.ariaShowChildren": {
"description": "Accessibility message for the button to show children of the current filter",
"message": "Mostrar más filtros para {filterValueName}"
},
"components.SearchFiltersPane.clearFilters": {
"description": "Helper button in search filters pane in search page to remove all active filters",
"message": "Retirar {activeFilterCount, number} activo {activeFilterCount, plural, one {filtro} other {filtros}}"
},
"components.SearchFiltersPane.title": {
"description": "Title for the search filters pane in course search.",
"message": "Filtrar cursos"
},
"components.SearchInput.button": {
"description": "Accessibility text for the search button inside the Search input.",
"message": "Buscar"
},
"components.SearchSuggestField.searchFieldPlaceholder": {
"description": "Placeholder text displayed in the search field when it is empty.",
"message": "Buscar cursos, organizaciones, categorías"
},
"components.UserLogin.logIn": {
"description": "Text for the login button.",
"message": "Iniciar sesión"
},
"components.UserLogin.logOut": {
"description": "Text for the logout button.",
"message": "Cerrar sesión"
},
"components.UserLogin.signup": {
"description": "Text for the signup button.",
"message": "Regístrarse"
},
"components.UserLogin.spinnerText": {
"description": "Accessibility text for the spinner in the login area.",
"message": "Cargando estado de inicio de sesión..."
}
}
Loading

0 comments on commit 09bf400

Please sign in to comment.