@edx/frontend-platform 4.6.2 → 4.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/.env.development +0 -30
- package/.env.test +0 -30
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -28
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -13
- package/.github/workflows/add-depr-ticket-to-depr-board.yml +0 -19
- package/.github/workflows/add-remove-label-on-comment.yml +0 -20
- package/.github/workflows/ci.yml +0 -42
- package/.github/workflows/commitlint.yml +0 -10
- package/.github/workflows/lockfileversion-check.yml +0 -13
- package/.github/workflows/manual-publish.yml +0 -43
- package/.github/workflows/npm-deprecate.yml +0 -22
- package/.github/workflows/release.yml +0 -45
- package/.github/workflows/self-assign-issue.yml +0 -12
- package/.github/workflows/update-browserslist-db.yml +0 -12
- package/.nvmrc +0 -1
- package/.releaserc +0 -32
- package/catalog-info.yaml +0 -21
- package/dist/LICENSE +0 -661
- package/dist/README.md +0 -155
- package/dist/package.json +0 -86
- package/docs/addTagsPlugin.js +0 -10
- package/docs/auth-API.md +0 -114
- package/docs/decisions/0001-record-architecture-decisions.rst +0 -32
- package/docs/decisions/0002-frontend-base-design-goals.rst +0 -222
- package/docs/decisions/0003-consolidation-into-frontend-platform.rst +0 -71
- package/docs/decisions/0004-axios-caching-implementation.rst +0 -88
- package/docs/decisions/0005-token-null-after-successful-refresh.rst +0 -69
- package/docs/decisions/0006-middleware-support-for-http-clients.rst +0 -44
- package/docs/decisions/0007-javascript-file-configuration.rst +0 -143
- package/docs/how_tos/automatic-case-conversion.rst +0 -58
- package/docs/how_tos/caching.rst +0 -93
- package/docs/how_tos/i18n.rst +0 -305
- package/docs/removeExport.js +0 -24
- package/docs/template/edx/README.md +0 -12
- package/docs/template/edx/publish.js +0 -713
- package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/template/edx/static/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/template/edx/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/template/edx/static/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/template/edx/static/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/template/edx/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/template/edx/static/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/template/edx/static/scripts/linenumber.js +0 -25
- package/docs/template/edx/static/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/template/edx/static/scripts/prettify/lang-css.js +0 -2
- package/docs/template/edx/static/scripts/prettify/prettify.js +0 -28
- package/docs/template/edx/static/styles/jsdoc-default.css +0 -356
- package/docs/template/edx/static/styles/prettify-jsdoc.css +0 -111
- package/docs/template/edx/static/styles/prettify-tomorrow.css +0 -132
- package/docs/template/edx/tmpl/augments.tmpl +0 -10
- package/docs/template/edx/tmpl/container.tmpl +0 -196
- package/docs/template/edx/tmpl/details.tmpl +0 -143
- package/docs/template/edx/tmpl/example.tmpl +0 -2
- package/docs/template/edx/tmpl/examples.tmpl +0 -13
- package/docs/template/edx/tmpl/exceptions.tmpl +0 -32
- package/docs/template/edx/tmpl/layout.tmpl +0 -39
- package/docs/template/edx/tmpl/mainpage.tmpl +0 -10
- package/docs/template/edx/tmpl/members.tmpl +0 -38
- package/docs/template/edx/tmpl/method.tmpl +0 -131
- package/docs/template/edx/tmpl/modifies.tmpl +0 -14
- package/docs/template/edx/tmpl/params.tmpl +0 -131
- package/docs/template/edx/tmpl/properties.tmpl +0 -108
- package/docs/template/edx/tmpl/returns.tmpl +0 -19
- package/docs/template/edx/tmpl/source.tmpl +0 -8
- package/docs/template/edx/tmpl/tutorial.tmpl +0 -19
- package/docs/template/edx/tmpl/type.tmpl +0 -7
- package/env.config.js +0 -8
- package/jsdoc.json +0 -36
- package/openedx.yaml +0 -12
- package/service-interface.png +0 -0
- package/src/analytics/MockAnalyticsService.js +0 -71
- package/src/analytics/SegmentAnalyticsService.js +0 -243
- package/src/analytics/index.js +0 -12
- package/src/analytics/interface.js +0 -142
- package/src/auth/AxiosCsrfTokenService.js +0 -60
- package/src/auth/AxiosJwtAuthService.js +0 -364
- package/src/auth/AxiosJwtTokenService.js +0 -134
- package/src/auth/LocalForageCache.js +0 -78
- package/src/auth/MockAuthService.js +0 -285
- package/src/auth/index.js +0 -19
- package/src/auth/interceptors/createCsrfTokenProviderInterceptor.js +0 -37
- package/src/auth/interceptors/createJwtTokenProviderInterceptor.js +0 -38
- package/src/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +0 -20
- package/src/auth/interceptors/createRetryInterceptor.js +0 -72
- package/src/auth/interface.js +0 -309
- package/src/auth/utils.js +0 -105
- package/src/config.js +0 -327
- package/src/constants.js +0 -66
- package/src/i18n/countries.js +0 -57
- package/src/i18n/index.js +0 -123
- package/src/i18n/injectIntlWithShim.jsx +0 -45
- package/src/i18n/languages.js +0 -60
- package/src/i18n/lib.js +0 -282
- package/src/i18n/scripts/README.md +0 -29
- package/src/i18n/scripts/intl-imports.js +0 -259
- package/src/i18n/scripts/transifex-utils.js +0 -75
- package/src/index.js +0 -42
- package/src/initialize.js +0 -357
- package/src/logging/MockLoggingService.js +0 -31
- package/src/logging/NewRelicLoggingService.js +0 -181
- package/src/logging/index.js +0 -9
- package/src/logging/interface.js +0 -110
- package/src/pubSub.js +0 -47
- package/src/react/AppContext.jsx +0 -24
- package/src/react/AppProvider.jsx +0 -93
- package/src/react/AuthenticatedPageRoute.jsx +0 -60
- package/src/react/ErrorBoundary.jsx +0 -44
- package/src/react/ErrorPage.jsx +0 -76
- package/src/react/LoginRedirect.jsx +0 -16
- package/src/react/OptionalReduxProvider.jsx +0 -28
- package/src/react/PageRoute.jsx +0 -31
- package/src/react/hooks.js +0 -50
- package/src/react/index.js +0 -16
- package/src/scripts/GoogleAnalyticsLoader.js +0 -53
- package/src/scripts/index.js +0 -2
- package/src/testing/index.js +0 -9
- package/src/testing/initializeMockApp.js +0 -77
- package/src/testing/mockMessages.js +0 -21
- package/src/utils.js +0 -167
- /package/{dist/analytics → analytics}/MockAnalyticsService.js +0 -0
- /package/{dist/analytics → analytics}/MockAnalyticsService.js.map +0 -0
- /package/{dist/analytics → analytics}/SegmentAnalyticsService.js +0 -0
- /package/{dist/analytics → analytics}/SegmentAnalyticsService.js.map +0 -0
- /package/{dist/analytics → analytics}/index.js +0 -0
- /package/{dist/analytics → analytics}/index.js.map +0 -0
- /package/{dist/analytics → analytics}/interface.js +0 -0
- /package/{dist/analytics → analytics}/interface.js.map +0 -0
- /package/{dist/auth → auth}/AxiosCsrfTokenService.js +0 -0
- /package/{dist/auth → auth}/AxiosCsrfTokenService.js.map +0 -0
- /package/{dist/auth → auth}/AxiosJwtAuthService.js +0 -0
- /package/{dist/auth → auth}/AxiosJwtAuthService.js.map +0 -0
- /package/{dist/auth → auth}/AxiosJwtTokenService.js +0 -0
- /package/{dist/auth → auth}/AxiosJwtTokenService.js.map +0 -0
- /package/{dist/auth → auth}/LocalForageCache.js +0 -0
- /package/{dist/auth → auth}/LocalForageCache.js.map +0 -0
- /package/{dist/auth → auth}/MockAuthService.js +0 -0
- /package/{dist/auth → auth}/MockAuthService.js.map +0 -0
- /package/{dist/auth → auth}/index.js +0 -0
- /package/{dist/auth → auth}/index.js.map +0 -0
- /package/{dist/auth → auth}/interceptors/createCsrfTokenProviderInterceptor.js +0 -0
- /package/{dist/auth → auth}/interceptors/createCsrfTokenProviderInterceptor.js.map +0 -0
- /package/{dist/auth → auth}/interceptors/createJwtTokenProviderInterceptor.js +0 -0
- /package/{dist/auth → auth}/interceptors/createJwtTokenProviderInterceptor.js.map +0 -0
- /package/{dist/auth → auth}/interceptors/createProcessAxiosRequestErrorInterceptor.js +0 -0
- /package/{dist/auth → auth}/interceptors/createProcessAxiosRequestErrorInterceptor.js.map +0 -0
- /package/{dist/auth → auth}/interceptors/createRetryInterceptor.js +0 -0
- /package/{dist/auth → auth}/interceptors/createRetryInterceptor.js.map +0 -0
- /package/{dist/auth → auth}/interface.js +0 -0
- /package/{dist/auth → auth}/interface.js.map +0 -0
- /package/{dist/auth → auth}/utils.js +0 -0
- /package/{dist/auth → auth}/utils.js.map +0 -0
- /package/{dist/config.js → config.js} +0 -0
- /package/{dist/config.js.map → config.js.map} +0 -0
- /package/{dist/constants.js → constants.js} +0 -0
- /package/{dist/constants.js.map → constants.js.map} +0 -0
- /package/{dist/i18n → i18n}/countries.js +0 -0
- /package/{dist/i18n → i18n}/countries.js.map +0 -0
- /package/{dist/i18n → i18n}/index.js +0 -0
- /package/{dist/i18n → i18n}/index.js.map +0 -0
- /package/{dist/i18n → i18n}/injectIntlWithShim.js +0 -0
- /package/{dist/i18n → i18n}/injectIntlWithShim.js.map +0 -0
- /package/{dist/i18n → i18n}/languages.js +0 -0
- /package/{dist/i18n → i18n}/languages.js.map +0 -0
- /package/{dist/i18n → i18n}/lib.js +0 -0
- /package/{dist/i18n → i18n}/lib.js.map +0 -0
- /package/{dist/i18n → i18n}/scripts/README.md +0 -0
- /package/{dist/i18n → i18n}/scripts/intl-imports.js +0 -0
- /package/{dist/i18n → i18n}/scripts/intl-imports.js.map +0 -0
- /package/{dist/i18n → i18n}/scripts/transifex-utils.js +0 -0
- /package/{dist/i18n → i18n}/scripts/transifex-utils.js.map +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/initialize.js → initialize.js} +0 -0
- /package/{dist/initialize.js.map → initialize.js.map} +0 -0
- /package/{dist/logging → logging}/MockLoggingService.js +0 -0
- /package/{dist/logging → logging}/MockLoggingService.js.map +0 -0
- /package/{dist/logging → logging}/NewRelicLoggingService.js +0 -0
- /package/{dist/logging → logging}/NewRelicLoggingService.js.map +0 -0
- /package/{dist/logging → logging}/index.js +0 -0
- /package/{dist/logging → logging}/index.js.map +0 -0
- /package/{dist/logging → logging}/interface.js +0 -0
- /package/{dist/logging → logging}/interface.js.map +0 -0
- /package/{dist/pubSub.js → pubSub.js} +0 -0
- /package/{dist/pubSub.js.map → pubSub.js.map} +0 -0
- /package/{dist/react → react}/AppContext.js +0 -0
- /package/{dist/react → react}/AppContext.js.map +0 -0
- /package/{dist/react → react}/AppProvider.js +0 -0
- /package/{dist/react → react}/AppProvider.js.map +0 -0
- /package/{dist/react → react}/AuthenticatedPageRoute.js +0 -0
- /package/{dist/react → react}/AuthenticatedPageRoute.js.map +0 -0
- /package/{dist/react → react}/ErrorBoundary.js +0 -0
- /package/{dist/react → react}/ErrorBoundary.js.map +0 -0
- /package/{dist/react → react}/ErrorPage.js +0 -0
- /package/{dist/react → react}/ErrorPage.js.map +0 -0
- /package/{dist/react → react}/LoginRedirect.js +0 -0
- /package/{dist/react → react}/LoginRedirect.js.map +0 -0
- /package/{dist/react → react}/OptionalReduxProvider.js +0 -0
- /package/{dist/react → react}/OptionalReduxProvider.js.map +0 -0
- /package/{dist/react → react}/PageRoute.js +0 -0
- /package/{dist/react → react}/PageRoute.js.map +0 -0
- /package/{dist/react → react}/hooks.js +0 -0
- /package/{dist/react → react}/hooks.js.map +0 -0
- /package/{dist/react → react}/index.js +0 -0
- /package/{dist/react → react}/index.js.map +0 -0
- /package/{dist/scripts → scripts}/GoogleAnalyticsLoader.js +0 -0
- /package/{dist/scripts → scripts}/GoogleAnalyticsLoader.js.map +0 -0
- /package/{dist/scripts → scripts}/index.js +0 -0
- /package/{dist/scripts → scripts}/index.js.map +0 -0
- /package/{dist/testing → testing}/index.js +0 -0
- /package/{dist/testing → testing}/index.js.map +0 -0
- /package/{dist/testing → testing}/initializeMockApp.js +0 -0
- /package/{dist/testing → testing}/initializeMockApp.js.map +0 -0
- /package/{dist/testing → testing}/mockMessages.js +0 -0
- /package/{dist/testing → testing}/mockMessages.js.map +0 -0
- /package/{dist/utils.js → utils.js} +0 -0
- /package/{dist/utils.js.map → utils.js.map} +0 -0
package/docs/how_tos/i18n.rst
DELETED
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
####################
|
|
2
|
-
React App i18n HOWTO
|
|
3
|
-
####################
|
|
4
|
-
|
|
5
|
-
************
|
|
6
|
-
Introduction
|
|
7
|
-
************
|
|
8
|
-
|
|
9
|
-
This is a step by step guide to making your React app ready to accept translations. The instructions here are very specific to the edX setup.
|
|
10
|
-
|
|
11
|
-
.. contents:: Table of Contents
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*************************************************
|
|
15
|
-
Internationalize your application with react-intl
|
|
16
|
-
*************************************************
|
|
17
|
-
|
|
18
|
-
These steps will allow your application to accept translation strings. See `frontend-app-account <https://github.com/openedx/frontend-app-account/>`_ for an example app to follow.
|
|
19
|
-
|
|
20
|
-
#. Add ``@edx/frontend-platform`` as a dependency to your ``package.json`` . (If you are actually writing a consumable component, add ``@edx/frontend-platform`` as both a dev dependency and peer dependency instead.) ``@edx/frontend-platform/i18n`` is a wrapper around ``react-intl`` that adds some shims. You should only access the ``react-intl`` functions and elements exposed by ``@edx/frontend-platform/i18n``. (They have the same names as in ``react-intl``.)
|
|
21
|
-
|
|
22
|
-
#. In ``App.js``, wrap your entire app in an ``IntlProvider`` element. See `Load up your translation files`_ for details. (Consumable components: Don't do this step, except possibly in tests. Your consuming application will do it for you. Instead, update your `README like this example <https://github.com/openedx/frontend-component-footer/blame/master/README.rst#L23-L27>`__.)
|
|
23
|
-
|
|
24
|
-
#. For places in your code where you need a display string, and it's okay if it's a React element (generally, most messages): use a ``FormattedMessage``.
|
|
25
|
-
|
|
26
|
-
* The ``id`` is required and must be a unique dot-separated string. The first part of it should be your app name. The rest can be whatever you want, though a hierarchical namespacing part followed by some descriptive words is most common.
|
|
27
|
-
|
|
28
|
-
* The ``defaultMessage`` is required, and should be the English display string. Otherwise translators won't know what they're translating.
|
|
29
|
-
|
|
30
|
-
.. note::
|
|
31
|
-
English strings should not include the HTML brackets < or > since those characters will break Transifex.
|
|
32
|
-
|
|
33
|
-
* The ``description`` is a note to the translators that can help them figure out how to translate your text. It is optional, but recommended.
|
|
34
|
-
|
|
35
|
-
Example::
|
|
36
|
-
|
|
37
|
-
<FormattedMessage
|
|
38
|
-
id="myapp.cart.shipping.address"
|
|
39
|
-
defaultMessage="Shipping address"
|
|
40
|
-
description="header above the shipping address form"
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
For additional help, including adding interprolated variables, see the `FormattedMessage documentation <https://formatjs.io/docs/react-intl/components#formattedmessage>`__. It can also handle plurals.
|
|
44
|
-
|
|
45
|
-
#. For places in your code where you need a display string, and it has to be a plain JavaScript string (e.g., a button label), you will need to do the following:
|
|
46
|
-
|
|
47
|
-
#. Inject the ``intl`` object into your component:
|
|
48
|
-
|
|
49
|
-
#. ``import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';``;
|
|
50
|
-
|
|
51
|
-
#. add ``intl: intlShape.isRequired`` to your component's ``propTypes``.
|
|
52
|
-
|
|
53
|
-
#. instead of ``export Foo``, ``export injectIntl(Foo)`` .
|
|
54
|
-
|
|
55
|
-
#. Define your messages using ``defineMessages``. This function doesn't actually do anything; it's just a hook for the translation pipeline to be able to find your translation strings. You can call ``defineMessages`` wherever you want, but if you have a lot of them you might want to move them to a separate file. Either ``MyAppName.messages.js`` (if your entire app has only a few strings) or ``SomeComponent.messages.js`` will work. Your file should look like the example below. For your own sanity, using a short camel-case string for the property name is fine as long as ``id`` is globally unique in the MFE. Example::
|
|
56
|
-
|
|
57
|
-
import { defineMessages } from '@edx/frontend-platform/i18n';
|
|
58
|
-
|
|
59
|
-
const messages = defineMessages({
|
|
60
|
-
'cartPayNow': {
|
|
61
|
-
id: 'myapp.cart.pay.now',
|
|
62
|
-
defaultMessage: 'Pay Now',
|
|
63
|
-
description: 'a button label',
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
export default messages;
|
|
68
|
-
|
|
69
|
-
#. Use the ``intl.formatMessage`` function to get your translated string::
|
|
70
|
-
|
|
71
|
-
import messages from './SomeComponent.messages';
|
|
72
|
-
// ...
|
|
73
|
-
intl.formatMessage(messages.cartPayNow)
|
|
74
|
-
|
|
75
|
-
#. If you want to use ``FormattedMessage`` but your display string is repeated several times, it's probably better to pull it out into a messages file. In this case the messages file will have the ``defaultMessage`` and the ``description``, and you can just give ``FormattedMessage`` the ``id``.
|
|
76
|
-
|
|
77
|
-
#. You should now be able to run your app and see everything behaving normally, with English strings.
|
|
78
|
-
|
|
79
|
-
****************
|
|
80
|
-
Set up Transifex
|
|
81
|
-
****************
|
|
82
|
-
|
|
83
|
-
In your repo, create and commit a file named ``.tx/config``::
|
|
84
|
-
|
|
85
|
-
[main]
|
|
86
|
-
host = https://www.transifex.com
|
|
87
|
-
|
|
88
|
-
[edx-platform.your-resource-name-here]
|
|
89
|
-
file_filter = src/i18n/messages/<lang>.json
|
|
90
|
-
source_file = src/i18n/transifex_input.json
|
|
91
|
-
source_lang = en
|
|
92
|
-
type = KEYVALUEJSON
|
|
93
|
-
|
|
94
|
-
*************************
|
|
95
|
-
Set up the pipeline tools
|
|
96
|
-
*************************
|
|
97
|
-
|
|
98
|
-
The pipeline jobs live in the `ecommerce-scripts <https://github.com/openedx/ecommerce-scripts/tree/master/transifex>`__ repo, but you don't have to modify them. They will interact with your repo through ``make`` targets.
|
|
99
|
-
|
|
100
|
-
#. Copy the `frontend-app-account Makefile <https://github.com/openedx/frontend-app-account/blob/master/Makefile>`__ to your project.
|
|
101
|
-
|
|
102
|
-
* Modify the ``transifex_resource`` variable with your own Transifex resource name.
|
|
103
|
-
|
|
104
|
-
#. The job to push strings to Transifex will call ``make push_translations`` in your repo. This target should do everything necessary to extract your strings, concat them into one file, and put them in ``src/i18n/transifex_input.json``. If you don't have any special requirements, you can just use the default target that is included ``from frontend-i18n``.
|
|
105
|
-
|
|
106
|
-
#. Extraction: We will be using a Babel plugin to find all the strings inside a ``FormattedMessage`` component or inside a call to ``defineMessages``.
|
|
107
|
-
|
|
108
|
-
If you are using @edx/frontend-build...
|
|
109
|
-
|
|
110
|
-
* Add this to ``scripts`` in ``package.json``::
|
|
111
|
-
|
|
112
|
-
"i18n_extract": "BABEL_ENV=i18n fedx-scripts babel src --quiet > /dev/null"
|
|
113
|
-
|
|
114
|
-
* The default babel configuration provided by frontend-build has the needed configuration.
|
|
115
|
-
|
|
116
|
-
If you are NOT using @edx/frontend-build:
|
|
117
|
-
|
|
118
|
-
* Add this to ``scripts`` in ``package.json``::
|
|
119
|
-
|
|
120
|
-
"i18n_extract": "BABEL_ENV=i18n babel src --quiet > /dev/null"
|
|
121
|
-
|
|
122
|
-
* Add ``babel-plugin-react-intl`` to your dev dependencies::
|
|
123
|
-
|
|
124
|
-
npm install babel-plugin-react-intl --save-dev
|
|
125
|
-
|
|
126
|
-
* Add this to ``.babelrc``::
|
|
127
|
-
|
|
128
|
-
"env": {
|
|
129
|
-
"i18n": {
|
|
130
|
-
"plugins": [
|
|
131
|
-
["react-intl", {
|
|
132
|
-
"messagesDir": "./temp/babel-plugin-react-intl",
|
|
133
|
-
"moduleSourceName": "@edx/frontend-platform/i18n"
|
|
134
|
-
}]
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
Then:
|
|
140
|
-
|
|
141
|
-
* Confirm that running ``make i18n.extract`` creates a lot of ``.json`` files in ``your-repo/temp/babel-plugin-react-intl/`` .
|
|
142
|
-
|
|
143
|
-
* Add ``temp`` and ``src/i18n/transifex_input.json`` to your ``.gitignore``.
|
|
144
|
-
|
|
145
|
-
#. Concatenation: All those ``.json`` files need to become one file.
|
|
146
|
-
|
|
147
|
-
* Confirm that running ``make i18n.concat`` creates ``src/i18n/transifex_input.json``, which should be a file of message id / English pairs.
|
|
148
|
-
|
|
149
|
-
* If you are missing any dependencies, like ``glob``, you will need to add these to your dev dependencies.
|
|
150
|
-
|
|
151
|
-
#. Uploading comments: The ``KEYVALUEJSON`` format doesn't have a way to put in translator comments (the ``description`` field in your message definitions), so we work around this by making calls to the Transifex API. There isn't a bulk call available, so it will be one API call per string. (...I know.) As of June 2019, the rate limit is 6000 calls per hour.
|
|
152
|
-
|
|
153
|
-
* Add ``reactifex`` to your dev dependencies::
|
|
154
|
-
|
|
155
|
-
npm install reactifex --save-dev
|
|
156
|
-
|
|
157
|
-
* You can't test this one without Transifex credentials, so at this point it's probably easiest to just make your pipeline job and run that.
|
|
158
|
-
|
|
159
|
-
#. The job to pull translations out of Transifex and commit them to your repo will call ``make pull_translations``.
|
|
160
|
-
|
|
161
|
-
* If the languages you want to pull down differ from the default set, you can update the ``transifex_langs`` variable in your local Makefile.
|
|
162
|
-
|
|
163
|
-
* The user ``edx_transifex_bot`` will need to have permissions to merge an unreviewed pull request into your repo. This means your repo must either allow merging unreviewed pull requests for everyone, or ``edx_transifex_bot`` needs to be an administrator.
|
|
164
|
-
|
|
165
|
-
*******************************************
|
|
166
|
-
Create empty translation files in your repo
|
|
167
|
-
*******************************************
|
|
168
|
-
|
|
169
|
-
#. You must commit an empty language file for each language, or the ``pull`` job will fail. Each file is named ``src/i18n/messages/LANG_CODE.json`` and consists of an empty JSON object (``{}``). See this `example code with empty language files <https://github.com/openedx/frontend-component-footer/commit/46772ecc0e8de2ce1815607fdf2e8f2867dc83cf>`__.
|
|
170
|
-
|
|
171
|
-
***********************************
|
|
172
|
-
Create your pipeline job on Jenkins
|
|
173
|
-
***********************************
|
|
174
|
-
|
|
175
|
-
#. Test your change locally.
|
|
176
|
-
|
|
177
|
-
* __NOTE__: You need the existing project resource on Transifiex or have the priviledge to create it. Otherwise skip to the next step.
|
|
178
|
-
|
|
179
|
-
* Clone https://github.com/openedx/ecommerce-scripts.
|
|
180
|
-
|
|
181
|
-
* Create virtualenv for python.
|
|
182
|
-
|
|
183
|
-
* Install requirements based on the ``requirements`` section on the `tools-edx-jenkins/translation-jobs.yml <https://github.com/edx/edx-internal/blob/master/tools-edx-jenkins/translation-jobs.yml>`__. It should be something similiar to ``pip install -r transifex/requirements/microfrontend-common.txt``.
|
|
184
|
-
|
|
185
|
-
* Run the script that you try to create the jobs.
|
|
186
|
-
|
|
187
|
-
* Examples: ``python transifex/pull.py https://github.com/openedx/edx-platform.git edx/sustaining-team``. You might be required to setup environment variable ``GITHUB_ACCESS_TOKEN`` with your personal github account.
|
|
188
|
-
|
|
189
|
-
* For ``push_translations``, you also need transifex authentication. This action will try to create project resource if it isn't existed yet. If you don't have permission, it will fail.
|
|
190
|
-
|
|
191
|
-
* For ``pull_translations``, it should try to create a pull request and merge it to the repo.
|
|
192
|
-
|
|
193
|
-
#. In the ``edx-internal`` repo, add your job to `tools-edx-jenkins/translation-jobs.yml <https://github.com/edx/edx-internal/blob/master/tools-edx-jenkins/translation-jobs.yml>`__, using one of the existing frontend apps as a model.
|
|
194
|
-
|
|
195
|
-
* Add an opsgenie email address that actually exists :-) so you get notified of failures.
|
|
196
|
-
|
|
197
|
-
* You will need to set up OpsGenie to properly send these alerts, and to auto-close notifications when Jenkins goes back to normal.
|
|
198
|
-
|
|
199
|
-
* In the command lines that run the job, put in your repo name and the GitHub team name that you'd like notifications sent to.
|
|
200
|
-
|
|
201
|
-
* The existing jobs push translation strings to Transifex daily, and pull completed translations once a week, on Sunday. You can pick your own schedule on the ``cron`` line. It's best to move your new job off of 8PM UTC, so we don't have to worry about the Transifex API rate limit described above.
|
|
202
|
-
|
|
203
|
-
* Note that the Jenkins machine uses UTC.
|
|
204
|
-
|
|
205
|
-
#. Open a pull request with your change. If you do't have permission or someone to review, you can `open a devops ticket <https://openedx.atlassian.net/servicedesk/customer/portal/3>`_ requesting them to review your pull request and rerun the seed job. Only devops can merge pull requests in this repo.
|
|
206
|
-
|
|
207
|
-
#. Once the change get merge, you can build https://tools-edx-jenkins.edx.org/job/Seed%20Jobs/job/Translation%20Seed%20Jobs/ to have the change propegated. (You need to connect to the edX VPN)
|
|
208
|
-
|
|
209
|
-
* If you don't have permission, you can wait for the job to propegate. It takes up to one day.
|
|
210
|
-
|
|
211
|
-
#. Connect to the edX VPN to see your two new jobs at https://tools-edx-jenkins.edx.org/job/translations/ . ``push_translations`` extracts the strings from your repo and pushes them to Transifex. ``pull_translations`` pulls the translated strings from Transifex and checks them into your repo. You can test these jobs out by running them manually.
|
|
212
|
-
|
|
213
|
-
* The first job you need to run is ``push_translations``. This would create project resource on Transifex if the resource isn't existed yet.
|
|
214
|
-
|
|
215
|
-
* If you can't see this page, you might need to be added to the ``jenkins-tools-translation-jobs`` team in GitHub.
|
|
216
|
-
|
|
217
|
-
******************************
|
|
218
|
-
Load up your translation files
|
|
219
|
-
******************************
|
|
220
|
-
|
|
221
|
-
.. note:: This step is for applications only. You can skip this for consumable components.
|
|
222
|
-
|
|
223
|
-
You can actually do this step even before you have Transifex and Jenkins set up, by providing your own translation files in ``src/i18n/messages/LANG_CODE.json``.
|
|
224
|
-
|
|
225
|
-
#. Your pipeline job should have updated several translation files in ``src/i18n/messages/LANG_CODE.json`` .
|
|
226
|
-
|
|
227
|
-
#. Create ``src/i18n/index.js`` using `frontend-app-account's index.js <https://github.com/openedx/frontend-app-account/blob/master/src/i18n/index.js>`_ as a model.
|
|
228
|
-
|
|
229
|
-
#. In ``App.jsx``, make the following changes::
|
|
230
|
-
|
|
231
|
-
import { IntlProvider, getMessages, configure } from '@edx/frontend-platform/i18n';
|
|
232
|
-
import messages from './i18n/index'; // A map of all messages by locale
|
|
233
|
-
|
|
234
|
-
configure({
|
|
235
|
-
messages,
|
|
236
|
-
config: getConfig(), // ENVIRONMENT and LANGUAGE_PREFERENCE_COOKIE_NAME are required
|
|
237
|
-
loggingService: getLoggingService(), // An object with logError and logInfo methods
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// ...inside ReactDOM.render...
|
|
241
|
-
<IntlProvider locale={this.props.locale} messages={}>
|
|
242
|
-
|
|
243
|
-
#. As of this writing, ``frontend-platform/i18n`` reads the locale from the user language preference cookie, or, if none is found, from the browser's language setting. You can verify everything is working by changing your language preference in your account settings. If you are not logged in, you can change your browser language to one of the languages you have translations for.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
********************
|
|
247
|
-
Migrating to react-intl@5
|
|
248
|
-
********************
|
|
249
|
-
|
|
250
|
-
Initially ``frontend-platform`` used ``react-intl@2`` but as a part of its ``2.0.0`` release the version has been upgraded to ``react-intl@5``. If your application
|
|
251
|
-
used ``frontend-platform`` < ``2.0.0`` and you decided to upgrade, here's a list of breaking changes that you will need to consider during the upgrade:
|
|
252
|
-
|
|
253
|
-
* ``FormattedRelative`` component has been renamed to ``FormattedRelativeTime`` (and ``formatRelative`` to ``formatRelativeTime``) with changes to its API, read more `here <https://formatjs.io/docs/react-intl/upgrade-guide-3x/#formattedrelativetime>`_
|
|
254
|
-
|
|
255
|
-
* Message Format syntax has been changed. See `Message Format Syntax Changes <https://formatjs.io/docs/react-intl/upgrade-guide-3x#message-format-syntax-changes>`_ for more details.
|
|
256
|
-
|
|
257
|
-
* All tags specified must have corresponding values and will throw error if it's missing, e.g::
|
|
258
|
-
|
|
259
|
-
new IntlMessageFormat('a<b>strong</b>').format({
|
|
260
|
-
b: (...chunks) => <strong>{chunks}</strong>,
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
* Formatting self-closing tags is not supported anymore.
|
|
264
|
-
|
|
265
|
-
* XML/HTML tags are escaped using apostrophe just like other ICU constructs.
|
|
266
|
-
|
|
267
|
-
* Rich text formatting callback function is no longer variadic
|
|
268
|
-
|
|
269
|
-
* Before::
|
|
270
|
-
|
|
271
|
-
new IntlMessageFormat('a<b>strong</b>').format({
|
|
272
|
-
b: (...chunks) => <strong>{chunks}</strong>,
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
* After::
|
|
276
|
-
|
|
277
|
-
new IntlMessageFormat('a<b>strong</b>').format({
|
|
278
|
-
b: chunks => <strong>{chunks}</strong>,
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
* ``FormattedMessage`` render prop is no longer variadic
|
|
282
|
-
|
|
283
|
-
* Before::
|
|
284
|
-
|
|
285
|
-
<FormattedMessage defaultMessage="a<b>strong</b>">
|
|
286
|
-
{(...chunks) => <b>{chunks}</b>}
|
|
287
|
-
</FormattedMessage>
|
|
288
|
-
|
|
289
|
-
* After::
|
|
290
|
-
|
|
291
|
-
<FormattedMessage defaultMessage="a<b>strong</b>">
|
|
292
|
-
{chunks => <b>{chunks}</b>}
|
|
293
|
-
</FormattedMessage>
|
|
294
|
-
|
|
295
|
-
* ``IntlProvider.getChildContext`` has been removed which was used for testing purposes. Use ``createIntl`` instead to create a standalone ``intl`` object outside of React. See `Testing with React Intl <https://formatjs.io/docs/guides/testing>`_ for more details.
|
|
296
|
-
|
|
297
|
-
********************
|
|
298
|
-
For more information
|
|
299
|
-
********************
|
|
300
|
-
|
|
301
|
-
* `ADR for react-intl <https://github.com/openedx/paragon/blob/master/docs/decisions/0002-react-i18n.rst>`_
|
|
302
|
-
|
|
303
|
-
* `Working i18n notes <https://openedx.atlassian.net/wiki/spaces/LOC/pages/946503833/i18n+for+React>`_
|
|
304
|
-
|
|
305
|
-
* `studio-frontend i18n guide <https://github.com/openedx/studio-frontend/tree/master/src/data/i18n>`_
|
package/docs/removeExport.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSDoc plugin.
|
|
3
|
-
*
|
|
4
|
-
* Modifies the source code to remove the "export" keyword before JS doc sees it. This removes
|
|
5
|
-
* "exports." prefixes from documented members.
|
|
6
|
-
*
|
|
7
|
-
* @module plugins/exportKiller
|
|
8
|
-
*/
|
|
9
|
-
exports.handlers = {
|
|
10
|
-
beforeParse(e) {
|
|
11
|
-
e.source = e.source.replace(/(\nexport function)/g, $ => {
|
|
12
|
-
return `\nfunction`;
|
|
13
|
-
});
|
|
14
|
-
e.source = e.source.replace(/(\nexport const)/g, $ => {
|
|
15
|
-
return `\nconst`;
|
|
16
|
-
});
|
|
17
|
-
e.source = e.source.replace(/(\nexport default)/g, $ => {
|
|
18
|
-
return `\n`;
|
|
19
|
-
});
|
|
20
|
-
e.source = e.source.replace(/(\nexport async function)/g, $ => {
|
|
21
|
-
return `\nasync function`;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
The default template for JSDoc 4 uses: the [Underscore Template library](http://underscorejs.org/).
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
## Generating Typeface Fonts
|
|
5
|
-
|
|
6
|
-
The default template uses the [OpenSans](https://www.google.com/fonts/specimen/Open+Sans) typeface. The font files can be regenerated as follows:
|
|
7
|
-
|
|
8
|
-
1. Open the [OpenSans page at Font Squirrel](<http://www.fontsquirrel.com/fonts/open-sans>).
|
|
9
|
-
2. Click on the 'Webfont Kit' tab.
|
|
10
|
-
3. Either leave the subset drop-down as 'Western Latin (Default)', or, if we decide we need more glyphs, than change it to 'No Subsetting'.
|
|
11
|
-
4. Click the 'DOWNLOAD @FONT-FACE KIT' button.
|
|
12
|
-
5. For each typeface variant we plan to use, copy the 'eot', 'svg' and 'woff' files into the 'templates/default/static/fonts' directory.
|