Skip to content

Commit

Permalink
test: testing i18n message merging for federated modules in test-project
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjoy committed Nov 6, 2024
1 parent 768f2e5 commit 8cc92f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test-project/src/authenticated-page/AuthenticatedPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Link } from 'react-router-dom';

import { useAuthenticatedUser, useConfig } from '@openedx/frontend-base';
import { FormattedMessage } from 'react-intl';

export default function AuthenticatedPage() {
const authenticatedUser = useAuthenticatedUser();
Expand All @@ -9,6 +10,7 @@ export default function AuthenticatedPage() {
return (
<main className="p-3">
<h1>{config.SITE_NAME} authenticated page.</h1>
<FormattedMessage id="authenticated.page.content" defaultMessage="This is a localized message. Try it in French." description="This is a test message to prove localization works." />
<p>{authenticatedUser === null ? 'You are not authenticated.' : `Hi there, ${authenticatedUser.username}.`}</p>
<p>Visit <Link to="/">public page</Link>.</p>
</main>
Expand Down
27 changes: 27 additions & 0 deletions test-project/src/authenticated-page/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Placeholder be overridden by `make pull_translations`
export default {
ar: {},
'zh-hk': {},
'zh-cn': {},
uk: {},
'tr-tr': {},
th: {},
te: {},
ru: {},
'pt-pt': {},
'pt-br': {},
'it-it': {},
id: {},
hi: {},
he: {},
'fr-ca': {
'authenticated.page.content': 'This is a localized message in French.'
},
fa: {},
'es-es': {},
'es-419': {},
el: {},
'de-de': {},
da: {},
bo: {},
};
4 changes: 3 additions & 1 deletion test-project/src/authenticated-page/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApplicationModuleConfig, createUrlMenuItem } from '@openedx/frontend-base';
import messages from './i18n';

const config: ApplicationModuleConfig = {
route: {
Expand All @@ -14,7 +15,8 @@ const config: ApplicationModuleConfig = {
primaryLinks: [
createUrlMenuItem('Authenticated Page Link', '#'),
]
}
},
messages,
};

export default config;

0 comments on commit 8cc92f7

Please sign in to comment.