Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use i18n plugin for custom title configuration #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "i18n"]
path = plugins/i18n-plugin
url = https://github.com/abbyhu2000/i18n-plugin.git
2 changes: 1 addition & 1 deletion config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

# Specifies locale to be used for all localizable strings, dates and number formats.
# Supported languages are the following: English - en , by default , Chinese - zh-CN .
#i18n.locale: "en"
i18n.locale: "zh-CN"

# Set the allowlist to check input graphite Url. Allowlist is the default check list.
#vis_type_timeline.graphiteAllowedUrls: ['https://www.hostedgraphite.com/UID/ACCESS_KEY/graphite']
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dashboarding"
],
"private": true,
"version": "3.0.0",
"version": "2.1.0",
"branch": "main",
"types": "./opensearch_dashboards.d.ts",
"tsdocMetadata": "./build/tsdoc-metadata.json",
Expand Down
2 changes: 1 addition & 1 deletion plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ignore everything in this directory
*

# Except this file
!.gitignore
1 change: 1 addition & 0 deletions plugins/i18n-plugin
Submodule i18n-plugin added at c2a6dc
8 changes: 7 additions & 1 deletion src/core/public/chrome/ui/header/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,18 @@ export function CollapsibleNav({
const category = categoryDictionary[categoryName]!;
const opensearchLinkLogo =
category.id === 'opensearchDashboards' ? customSideMenuLogo() : category.euiIconType;
const opensearchTitle =
category.id === 'opensearchDashboards' ?
i18n.translate('core.ui.primaryNavSection.title', {
defaultMessage: 'Opensearch Dashboards',
})
: category.label;

return (
<EuiCollapsibleNavGroup
key={category.id}
iconType={opensearchLinkLogo}
title={category.label}
title={opensearchTitle}
isCollapsible={true}
initialIsOpen={getIsCategoryOpen(category.id, storage)}
onToggle={(isCategoryOpen) => setIsCategoryOpen(category.id, isCategoryOpen, storage)}
Expand Down
3 changes: 2 additions & 1 deletion src/core/server/rendering/rendering_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class RenderingService {
};
const basePath = http.basePath.get(request);
const uiPublicUrl = `${basePath}/ui`;
console.log(uiPublicUrl)
const serverBasePath = http.basePath.serverBasePath;
const settings = {
defaults: uiSettings.getRegistered(),
Expand Down Expand Up @@ -120,7 +121,7 @@ export class RenderingService {
env,
anonymousStatusPage: status.isStatusPageAnonymous(),
i18n: {
translationsUrl: `${basePath}/translations/${i18n.getLocale()}.json`,
translationsUrl: `${basePath}/translations/${i18n.getLocale()}.json`
},
csp: { warnLegacyBrowsers: http.csp.warnLegacyBrowsers },
vars: vars ?? {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
IconType,
} from '@elastic/eui';
import { HomePluginBranding } from '../../../plugin';
import { FormattedMessage } from '@osd/i18n/react';

interface Props {
/**
Expand Down Expand Up @@ -151,7 +152,12 @@ export const SolutionTitle: FC<Props> = ({ title, subtitle, iconType, branding }
data-test-subj="dashboardCustomTitle"
data-test-title={branding.applicationTitle}
>
<h3>{branding.applicationTitle}</h3>
<h3>
<FormattedMessage
id="home.solutionTitle"
defaultMessage={`Welcome to ${branding.applicationTitle}`}
/>
</h3>
</EuiTitle>

<EuiText size="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,14 @@ export const OverviewPageHeader: FC<Props> = ({

<EuiFlexItem>
<EuiTitle size="m">
<h1 id="osdOverviewPageHeader__title">{title}</h1>
<h1 id="osdOverviewPageHeader__title">
{i18n.translate(
'opensearch-dashboards-react.osdOverviewPageHeader.title',
{
defaultMessage: title.toString(),
}
)}
</h1>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down