Skip to content

Commit

Permalink
PI-1060 move formatMessageForIntegration to a separate function in Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Furkan Yilmaz committed Apr 12, 2017
1 parent d50f9f2 commit 6a8c08f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/FormattedMarkdown/FormattedMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
import marked from 'marked';

import { formatMessageForIntegration } from '../../utils/utils';
import { getConfigValue } from '../../selectors/config.js';

// To support different translations for differents integrations add
Expand All @@ -18,12 +19,11 @@ class FormattedMarkdown extends Component {
const { formatMessage } = this.props.intl;
let { integrationName } = this.props;

let integrationKey = this.props.text + '.' + integrationName;
const messageId = !!this.props.intl.messages[integrationKey]
? integrationKey
: this.props.text;

var formattedMessage = formatMessage({ id: messageId });
var formattedMessage = formatMessageForIntegration(
this.props.intl,
this.props.text,
integrationName
);

return (
<div
Expand Down
15 changes: 15 additions & 0 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,18 @@ export function humanFileSize(bytes) {
export function openWindow720x720(link) {
window.open(link, '_blank', 'toolbar=0,status=0,width=720,height=700');
}

export function formatMessageForIntegration(
intl,
translationId,
integrationName
) {
const { formatMessage } = intl;

let integrationKey = translationId + '.' + integrationName;
const messageId = !!intl.messages[integrationKey]
? integrationKey
: translationId;

return formatMessage({ id: messageId });
}

0 comments on commit 6a8c08f

Please sign in to comment.