From 0636b5f61e34c3de8ec88352344801846d96569d Mon Sep 17 00:00:00 2001 From: cauemarcondes Date: Tue, 2 Jun 2020 13:25:15 +0200 Subject: [PATCH] fixing i18n --- x-pack/.i18nrc.json | 3 +- .../public/application/index.tsx | 5 +- .../observability/public/pages/home/index.tsx | 62 ++++++++++++------- .../public/pages/home/section.tsx | 13 +--- 4 files changed, 50 insertions(+), 33 deletions(-) diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index a479b08ef9069..78cf464f63d5c 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -48,7 +48,8 @@ "xpack.triggersActionsUI": "plugins/triggers_actions_ui", "xpack.upgradeAssistant": "plugins/upgrade_assistant", "xpack.uptime": ["plugins/uptime"], - "xpack.watcher": "plugins/watcher" + "xpack.watcher": "plugins/watcher", + "xpack.observability": "plugins/observability" }, "translations": [ "plugins/translations/translations/zh-CN.json", diff --git a/x-pack/plugins/observability/public/application/index.tsx b/x-pack/plugins/observability/public/application/index.tsx index 92d762714b8b1..21a9fabf445f1 100644 --- a/x-pack/plugins/observability/public/application/index.tsx +++ b/x-pack/plugins/observability/public/application/index.tsx @@ -11,11 +11,14 @@ import { Home } from '../pages/home'; import { PluginContext } from '../context/plugin_context'; export const renderApp = (core: CoreStart, { element }: AppMountParameters) => { + const i18nCore = core.i18n; const isDarkMode = core.uiSettings.get('theme:darkMode'); ReactDOM.render( - + + + , element diff --git a/x-pack/plugins/observability/public/pages/home/index.tsx b/x-pack/plugins/observability/public/pages/home/index.tsx index 72f11665ad7f4..7880a28076661 100644 --- a/x-pack/plugins/observability/public/pages/home/index.tsx +++ b/x-pack/plugins/observability/public/pages/home/index.tsx @@ -26,38 +26,56 @@ import { usePluginContext } from '../../hooks/use_plugin_context'; const appsSection: ISection[] = [ { id: 'logs', - title: 'Logs', + title: i18n.translate('xpack.observability.section.apps.logs.title', { + defaultMessage: 'Logs', + }), icon: 'logoLogging', - description: - 'The Elastic Stack (sometimes known as the ELK Stack) is the most popular open source logging platform.', + description: i18n.translate('xpack.observability.section.apps.logs.description', { + defaultMessage: + 'The Elastic Stack (sometimes known as the ELK Stack) is the most popular open source logging platform.', + }), }, { id: 'apm', - title: 'APM', + title: i18n.translate('xpack.observability.section.apps.apm.title', { + defaultMessage: 'APM', + }), icon: 'logoAPM', - description: - 'See exactly where your application is spending time so you can quickly fix issues and feel good about the code you push.', + description: i18n.translate('xpack.observability.section.apps.apm.description', { + defaultMessage: + 'See exactly where your application is spending time so you can quickly fix issues and feel good about the code you push.', + }), }, { id: 'metrics', - title: 'Metrics', + title: i18n.translate('xpack.observability.section.apps.metrics.title', { + defaultMessage: 'Metrics', + }), icon: 'logoMetrics', - description: - 'Already using the Elastic Stack for logs? Add metrics in just a few steps and correlate metrics and logs in one place.', + description: i18n.translate('xpack.observability.section.apps.metrics.description', { + defaultMessage: + 'Already using the Elastic Stack for logs? Add metrics in just a few steps and correlate metrics and logs in one place.', + }), }, { id: 'uptime', - title: 'Uptime', + title: i18n.translate('xpack.observability.section.apps.uptime.title', { + defaultMessage: 'Uptime', + }), icon: 'logoUptime', - description: - 'React to availability issues across your apps and services before they affect users.', + description: i18n.translate('xpack.observability.section.apps.uptime.description', { + defaultMessage: + 'React to availability issues across your apps and services before they affect users.', + }), }, ]; const tryItOutItemsSection: ISection[] = [ { id: 'demo', - title: 'Demo Playground', + title: i18n.translate('xpack.observability.section.tryItOut.demo.title', { + defaultMessage: 'Demo Playground', + }), icon: 'play', description: '', href: 'https://demo.elastic.co/', @@ -65,7 +83,9 @@ const tryItOutItemsSection: ISection[] = [ }, { id: 'sampleData', - title: 'Add sample data', + title: i18n.translate('xpack.observability.section.tryItOut.sampleData.title', { + defaultMessage: 'Add sample data', + }), icon: 'documents', description: '', href: '/app/home#/tutorial_directory/sampleData', @@ -97,12 +117,12 @@ export const Home = () => { () => { core.chrome.setBreadcrumbs([ { - text: i18n.translate('observability.home.breadcrumb.observability', { + text: i18n.translate('xpack.observability.home.breadcrumb.observability', { defaultMessage: 'Observability', }), }, { - text: i18n.translate('observability.home.breadcrumb.gettingStarted', { + text: i18n.translate('xpack.observability.home.breadcrumb.gettingStarted', { defaultMessage: 'Getting started', }), }, @@ -124,7 +144,7 @@ export const Home = () => {

- {i18n.translate('observability.home.title', { + {i18n.translate('xpack.observability.home.title', { defaultMessage: 'Observability', })}

@@ -141,14 +161,14 @@ export const Home = () => {

- {i18n.translate('observability.home.sectionTitle', { + {i18n.translate('xpack.observability.home.sectionTitle', { defaultMessage: 'Observability built on the Elastic Stack', })}

- {i18n.translate('observability.home.sectionsubtitle', { + {i18n.translate('xpack.observability.home.sectionsubtitle', { defaultMessage: 'Bring your logs, metrics, and APM traces together at scale in a single stack so you can monitor and react to events happening anywhere in your environment.', })} @@ -189,7 +209,7 @@ export const Home = () => { style={{ width: 175 }} href={core.http.basePath.prepend('/app/home#/tutorial_directory/logging')} > - {i18n.translate('observability.home.getStatedButton', { + {i18n.translate('xpack.observability.home.getStatedButton', { defaultMessage: 'Get started', })} @@ -205,7 +225,7 @@ export const Home = () => {

- {i18n.translate('observability.home.tryItOut', { + {i18n.translate('xpack.observability.home.tryItOut', { defaultMessage: 'Try it out', })}

diff --git a/x-pack/plugins/observability/public/pages/home/section.tsx b/x-pack/plugins/observability/public/pages/home/section.tsx index 1d71662e01551..c7d84ee9bbe5c 100644 --- a/x-pack/plugins/observability/public/pages/home/section.tsx +++ b/x-pack/plugins/observability/public/pages/home/section.tsx @@ -12,7 +12,6 @@ import { EuiText, EuiTitle, } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; import React from 'react'; import styled from 'styled-components'; import { usePluginContext } from '../../hooks/use_plugin_context'; @@ -44,7 +43,7 @@ const Icon = styled(EuiIcon)` export const Section = ({ section }: { section: ISection }) => { const { core } = usePluginContext(); - const { id, icon, title, description, href } = section; + const { icon, title, description, href } = section; const sectionContent = ( @@ -53,18 +52,12 @@ export const Section = ({ section }: { section: ISection }) => {
-

- {i18n.translate(`observability.section.${id}.title`, { - defaultMessage: title, - })} -

+

{title}

{description && ( - {i18n.translate(`observability.section.${id}.description`, { - defaultMessage: description, - })} + {description} )}