-
Notifications
You must be signed in to change notification settings - Fork 841
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
Initial go at localizing some components #1450
Changes from 5 commits
547605d
f570e90
71e1a49
ebce6a6
0c509c0
abf4dfb
a0b0d43
a9e3f85
03e6b56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,7 @@ import classNames from 'classnames'; | |||||
import AceEditor from 'react-ace'; | ||||||
|
||||||
import { htmlIdGenerator, keyCodes } from '../../services'; | ||||||
import { EuiI18n } from '../i18n'; | ||||||
|
||||||
function setOrRemoveAttribute(element, attributeName, value) { | ||||||
if (value === null || value === undefined) { | ||||||
|
@@ -141,11 +142,11 @@ export class EuiCodeEditor extends Component { | |||||
filteredCursorStart = cursorStart; | ||||||
} | ||||||
|
||||||
const activityLabel = isReadOnly ? 'Interacting' : 'Editing'; | ||||||
const activity = isReadOnly | ||||||
? 'interacting with the code' | ||||||
: 'editing'; | ||||||
|
||||||
|
||||||
// Don't use EuiKeyboardAccessible here because it doesn't play nicely with onKeyDown. | ||||||
const prompt = ( | ||||||
<div | ||||||
|
@@ -159,11 +160,19 @@ export class EuiCodeEditor extends Component { | |||||
data-test-subj="codeEditorHint" | ||||||
> | ||||||
<p className="euiText"> | ||||||
Press Enter to start {activity}. | ||||||
<EuiI18n | ||||||
token={`euiCodeEditor.start${activityLabel}`} | ||||||
default={`Press Enter to start ${activity}.`} | ||||||
values={{ activity }} | ||||||
/> | ||||||
</p> | ||||||
|
||||||
<p className="euiText"> | ||||||
When you’re done, press Escape to stop {activity}. | ||||||
<EuiI18n | ||||||
token={`euiCodeEditor.stop${activityLabel}`} | ||||||
default={` When you're done, press Escape to stop ${activity}.`} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case whitespace matters:
Suggested change
|
||||||
values={{ activity }} | ||||||
/> | ||||||
</p> | ||||||
</div> | ||||||
); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { EuiText } from '../../text'; | |
import { EuiLoadingSpinner } from '../../loading'; | ||
import { EuiComboBoxOption } from './combo_box_option'; | ||
import { EuiComboBoxTitle } from './combo_box_title'; | ||
import { EuiI18n } from '../../i18n'; | ||
|
||
const positionToClassNameMap = { | ||
top: 'euiComboBoxOptionsList--top', | ||
|
@@ -129,7 +130,7 @@ export class EuiComboBoxOptionsList extends Component { | |
<EuiLoadingSpinner size="m" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
Loading options | ||
<EuiI18n token="euiComboBoxOptionsList.loadingOptions" default="Loading options"/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
|
@@ -139,22 +140,48 @@ export class EuiComboBoxOptionsList extends Component { | |
if (selectedOptionForValue) { | ||
// Disallow duplicate custom options. | ||
emptyStateContent = ( | ||
<p><strong>{selectedOptionForValue.value}</strong> has already been added</p> | ||
<p> | ||
<EuiI18n | ||
token="euiComboBoxOptionsList.alreadyAdded" | ||
default="{label} has already been added" | ||
values={{ label: <strong>{selectedOptionForValue.label}</strong> }} | ||
/> | ||
</p> | ||
); | ||
} else { | ||
emptyStateContent = ( | ||
<p>Hit <EuiCode>ENTER</EuiCode> to add <strong>{searchValue}</strong> as a custom option</p> | ||
<p> | ||
<EuiI18n | ||
token="euiComboBoxOptionsList.createCustomOption" | ||
default="Hit {key} to add {searchValue} as a custom option" | ||
values={{ key: <EuiCode>ENTER</EuiCode>, searchValue: <strong>{searchValue}</strong> }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is still localizable, the consumer can ignore that default value in their formatting:
Since react-intl allows JSX in the translations, the key value can be ignored and the localized value put directly into the message. |
||
/> | ||
</p> | ||
); | ||
} | ||
} else { | ||
emptyStateContent = ( | ||
<p><strong>{searchValue}</strong> doesn’t match any options</p> | ||
<p> | ||
<EuiI18n | ||
token="euiComboBoxOptionsList.noMatchingOptions" | ||
default="{searchValue} doesn't match any options" | ||
values={{ searchValue: <strong>{searchValue}</strong> }} | ||
/> | ||
</p> | ||
); | ||
} | ||
} else if (!options.length) { | ||
emptyStateContent = <p>There aren’t any options available</p>; | ||
emptyStateContent = ( | ||
<p> | ||
<EuiI18n token="euiComboBoxOptionsList.noAvailableOptions" default="There aren't any options available"/> | ||
</p> | ||
); | ||
} else if (areAllOptionsSelected) { | ||
emptyStateContent = <p>You’ve selected all available options</p>; | ||
emptyStateContent = ( | ||
<p> | ||
<EuiI18n token="euiComboBoxOptionsList.allOptionsSelected" default="You've selected all available options"/> | ||
</p> | ||
); | ||
} | ||
|
||
const emptyState = emptyStateContent ? ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this getting localised too? Not obvious that it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
activityLabel
is used in forming the tokens later. However, how I'm using it here breaks the planned static analysis of tokens, I'll refactor.